[U-Boot] [PATCH V3 04/12] cmd_test: use table lookup for parsing

Simon Glass sjg at chromium.org
Mon Feb 3 21:37:00 CET 2014


Hi Stephen,

On 3 February 2014 13:19, Stephen Warren <swarren at wwwdotorg.org> wrote:
>
> On 01/31/2014 05:03 PM, Simon Glass wrote:
> > Hi Stephen,
> >
> > On 27 January 2014 13:49, Stephen Warren <swarren at wwwdotorg.org> wrote:
> >> From: Stephen Warren <swarren at nvidia.com>
> >>
> >> do_test() currently uses strcmp() twice to determine which operator is
> >> present; once to determine how many arguments the operator needs, then
> >> a second time to actually decode the operator and implement it.
> >>
> >> Rewrite the code so that a table lookup is used to translate the operator
> >> string to an integer, and use a more efficient switch statement to decode
> >> and execute the operator.
> >>
> >> This approach also acts as enablement for the following patches.
> >>
> >> This patch should introduce no behavioural change.
> >>
> >> Signed-off-by: Stephen Warren <swarren at nvidia.com>
> >> ---
> >> v3: New patch.
> >
> > Wow that's some interesting code...it took me a while to understand
> > both the old and the new code. It looks correct to me but I wonder if
> > it is deserving of some tests? Something like test/command_ut.c might
> > show a simple way to run some tests.
>
> OK, I'll send V4 of this series with your minor issues addressed, and
> I'll send a separate follow-on series which adds the unit tests, just so
> it doesn't delay or cause revisions to the main series.


Sounds good, thanks.

Regards,
Simon


More information about the U-Boot mailing list