[pushed] microblaze-tdep: Add ATTRIBUTE_PRINTF to microblaze_debug

Michael Eager eager@eagerm.com
Mon Sep 25 14:14:00 GMT 2017


On 09/21/2017 05:11 AM, Simon Marchi wrote:
> I am getting this warning with clang:
> 
> /home/emaisin/src/binutils-gdb/gdb/microblaze-tdep.c:94:28: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
>         vprintf_unfiltered (fmt, args);
>                             ^~~
> 
> Adding ATTRIBUTE_PRINTF to microblaze_debug gets rid of it. Strangely, > gcc doesn't warn about non-literal format strings when calling vprintf
> (or a vprintf-style function, like vprintf_unfiltered).  I filed this
> gcc bug:
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82206

I'll admit to not being familiar with the nuances of __attribute__ ((format ...)),
or why adding this to the function declaration of microblaze_debug() would suppress
a diagnostic on the call to vprintf_unfiltered(), but the better fix seems to me to
be to turn off the obviously inappropriate -Wformat-nonliteral option in microblaze_debug()
using
#pragma GCC diagnostic ignored "-Wformat-nonliteral"

See https://stackoverflow.com/questions/12171132/avoid-warning-in-wrapper-around-printf

-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077



More information about the Gdb-patches mailing list