Patch for format non-literal warnings
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Sun Dec 26 06:20:00 GMT 1999
I'm pretty sure these transformations are equivalent, and they
eliminate several "format is a non-literal" warnings.
Okay to install?
--Kaveh
1999-12-24 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* diagnostic.c (v_message_with_decl): Use .* format specifier
instead of building the format specifier width manually.
* final.c (asm_fprintf): When processing, call vfprintf not fprintf.
diff -rup orig/egcs-CVS19991224/gcc/diagnostic.c egcs-CVS19991224/gcc/diagnostic.c
--- orig/egcs-CVS19991224/gcc/diagnostic.c Fri Dec 17 20:45:40 1999
+++ egcs-CVS19991224/gcc/diagnostic.c Sat Dec 25 04:59:23 1999
@@ -198,14 +198,7 @@ v_message_with_decl (decl, warn, msgid,
}
if (p > _(msgid)) /* Print the left-hand substring. */
- {
- char fmt[sizeof "%.255s"];
- long width = p - _(msgid);
-
- if (width > 255L) width = 255L; /* arbitrary */
- sprintf (fmt, "%%.%lds", width);
- fprintf (stderr, fmt, _(msgid));
- }
+ fprintf (stderr, "%.*s", (int)(p - _(msgid)), _(msgid));
if (*p == '%') /* Print the name. */
{
diff -rup orig/egcs-CVS19991224/gcc/final.c egcs-CVS19991224/gcc/final.c
--- orig/egcs-CVS19991224/gcc/final.c Fri Dec 24 09:00:36 1999
+++ egcs-CVS19991224/gcc/final.c Fri Dec 24 04:30:48 1999
@@ -3792,7 +3792,7 @@ asm_fprintf VPROTO((FILE *file, const ch
case 'o':
*q++ = c;
*q = 0;
- fprintf (file, buf, va_arg (argptr, int));
+ vfprintf (file, buf, argptr);
break;
case 'w':
@@ -3812,14 +3812,14 @@ asm_fprintf VPROTO((FILE *file, const ch
*q++ = *p++;
*q = 0;
- fprintf (file, buf, va_arg (argptr, HOST_WIDE_INT));
+ vfprintf (file, buf, argptr);
break;
case 'l':
*q++ = c;
*q++ = *p++;
*q = 0;
- fprintf (file, buf, va_arg (argptr, long));
+ vfprintf (file, buf, argptr);
break;
case 'e':
@@ -3827,13 +3827,13 @@ asm_fprintf VPROTO((FILE *file, const ch
case 'g':
*q++ = c;
*q = 0;
- fprintf (file, buf, va_arg (argptr, double));
+ vfprintf (file, buf, argptr);
break;
case 's':
*q++ = c;
*q = 0;
- fprintf (file, buf, va_arg (argptr, char *));
+ vfprintf (file, buf, argptr);
break;
case 'O':
More information about the Gcc-patches
mailing list