This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: use of %n in genmodes.c causes trouble on Vista



Or, if we think that other systems are likely to also start disabling
%n by default, then it would make sense for us to change the code.  It
would be easy to replace it with strlen calls, or, as you suggest, by
checking the return value of printf.  The return value of printf is
portable (unlike the return value of sprintf).

This would be pretty easy:


2007-06-06 Paolo Bonzini <bonzini@gnu.org>

	* genmodes.c (tagged_printf, emit_insn_modes_h): Don't
	use %n on printf.

Index: genmodes.c
===================================================================
--- genmodes.c  (revision 125260)
+++ genmodes.c  (working copy)
@@ -786,8 +786,7 @@ calc_wider_mode (void)
 /* Output routines.  */

 #define tagged_printf(FMT, ARG, TAG) do {              \
-  int count_;                                          \
-  printf ("  " FMT ",%n", ARG, &count_);               \
+  int count_ = printf ("  " FMT ",", ARG);             \
   printf ("%*s/* %s */\n", 27 - count_, "", TAG);      \
 } while (0)

@@ -821,8 +820,7 @@ enum machine_mode\n{");
   for (c = 0; c < MAX_MODE_CLASS; c++)
     for (m = modes[c]; m; m = m->next)
       {
-       int count_;
-       printf ("  %smode,%n", m->name, &count_);
+       int count_ = printf ("  %smode,", m->name);
        printf ("%*s/* %s:%d */\n", 27 - count_, "",
                 trim_filename (m->file), m->line);
       }

Tested with "make s-modes s-modes-h s-modes-m" and comparing the MD5 of the *modes*.* files before and after (since the only changes would be in spacing).

I went ahead and committed this as obvious.

Paolo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]