[pushed] microblaze-tdep: Add ATTRIBUTE_PRINTF to microblaze_debug
Pedro Alves
palves@redhat.com
Mon Sep 25 17:09:00 GMT 2017
On 09/25/2017 05:43 PM, Michael Eager wrote:
> On 09/25/2017 09:06 AM, Pedro Alves wrote:
>>> 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"
>> That doesn't make sense to me.
>
> The argument passed to vprintf_unformatted in microblaze_debug is not a
> string
> literal. The diagnostic message is correct. If you don't want the
> diagnostic,
> turning it off seems correct.
The diagnostic hasn't gone away. Instead, a warning is now emitted one
level up, at the microblaze_debug call sites, iff someone passes a
non-literal string as format string by mistake. That makes total
sense, because microblaze_debug is just a wrapper
around *printf_unfiltered.
> This is somewhat moot. All uses of microblaze_debug use literal string
> formats,
> so adding ATTRIBUTE_PRINTF is OK.
And if someone passes a non-literal format, we'll get a warning then.
If we suppressed the warning inside microblaze_debug as you were
suggesting, then we'd risk passing a non-literal as format string to
vprintf_unfiltered. That's the whole point.
Thanks,
Pedro Alves
More information about the Gdb-patches
mailing list