[U-Boot] [PATCH 2/3] Fix a few gcc warnings.

Mike Frysinger vapier at gentoo.org
Mon Apr 25 00:38:31 CEST 2011


On Sun, Apr 24, 2011 at 6:14 PM, Wolfgang Denk wrote:
> Joakim Tjernlund wrote:
>> --- a/examples/standalone/timer.c
>> +++ b/examples/standalone/timer.c
>> @@ -186,7 +186,7 @@ int timer (int argc, char * const argv[])
>>       /* clear all events */
>>       *hwp->terp = (CPMT_EVENT_CAP | CPMT_EVENT_REF);
>>
>> -     printf (usage);
>> +     printf("%s", usage);
>
> I dislike this change.  Which warning does the old code produce for
> you?

i imagine he is using one of those "security conscious" compilers that
warn when you try to printf with a dynamic argument as the format.  we
probably want to disable this stuff for u-boot since it doesnt make
much sense by adding -Wno-format-nonliteral and -Wno-format-security
when the compiler supports it.

as for this one particular change, it probably makes sense to change
it to puts(usage) anyways since the usage string contains no format
modifiers.  it'll be faster this way.  and the code should be written:
static const char usage[] = "...";

the current usage has useless overhead.
-mike


More information about the U-Boot mailing list