[U-Boot] [PATCH 1/4] cmdline: Add linux command line munging tools
Doug Anderson
dianders at chromium.org
Thu Oct 20 03:23:39 CEST 2011
On Wed, Oct 19, 2011 at 3:46 PM, Mike Frysinger <vapier at gentoo.org> wrote:
> On Wednesday 19 October 2011 18:30:56 Doug Anderson wrote:
> > --- /dev/null
> > +++ b/common/cmdline.c
> >
> > +/*
> > + * To run unit tests in this file:
> > + * gcc -DRUN_UNITTESTS -Wall -Werror common/cmdline.c -o cmdline &&
> > ./cmdline
> > + */
> > +#ifdef RUN_UNITTESTS
>
> i'm not sure this part should be merged ... better to keep on the back
> burner
> while Simon sorts out testing framework with new sandbox arch.
Fair enough. I will take out for the next version.
> bufsize should be size_t
> cmdline_len should be size_t
>
Will do in all cases. Thanks for catching!
> hmm, i feel like this should be simpler and not need that branch
>
> if (cmdline_len)
> cmdline[cmdline_len++] = ' ';
> if (bufsize <= cmdline_len)
> return;
> memcpy(&cmdline[cmdline_len], toappend, bufsize - cmdline_len - 1);
> cmdline[bufsize] = '\0';
>
There is one case that this doesn't catch I think: where cmdline_len was
exactly the same size as the original string (so we shouldn't append
anything).
...but then, as I look at this, I realize that I somehow sent you 1 rev back
of my patch. Aack! I will resend a new one tomorrow morning.
Thanks!
-Doug
More information about the U-Boot
mailing list