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

Simon Glass sjg at chromium.org
Sat Feb 1 01:03:09 CET 2014


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.

Regards,
Simon


More information about the U-Boot mailing list