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

Joakim Tjernlund joakim.tjernlund at transmode.se
Mon Apr 25 10:30:08 CEST 2011


vapierfilter at gmail.com wrote on 2011/04/25 06:13:20:
>
> On Sun, Apr 24, 2011 at 7:42 PM, Joakim Tjernlund wrote:
> > vapierfilter at gmail.com wrote on 2011/04/25 00:38:31:
> >> 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
> >
> > Yes, if gcc 4.4.5 counst as "security conscious" :)
>
> your distro probably enables some default warning flags from the vanilla one
>
> >> 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.
> >
> > Yes, but puts() adds an newline so you can't just replace the above printf
> > with puts()
>
> no, it doesnt.  u-boot's put() doesnt act the same as the standard C library.

Ah, didn't know that. I am not sure I like that especially
when there is a fputs in u-boot too.

   Jocke



More information about the U-Boot mailing list