[U-Boot] [PATCH 1/4] common: add run_command2 for running simple or hush commands

Wolfgang Denk wd at denx.de
Mon Jun 6 21:16:00 CEST 2011


Dear "Jason Hobbs",

In message <1307386599-4256-2-git-send-email-jason.hobbs at calxeda.com> you wrote:
> Signed-off-by: Jason Hobbs <jason.hobbs at calxeda.com>
> ---
>  common/hush.c    |    2 +-
>  common/main.c    |   46 +++++++++++++++++++---------------------------
>  include/common.h |    1 +
>  include/hush.h   |    2 +-
>  4 files changed, 22 insertions(+), 29 deletions(-)
...
> index dcbacc9..7da6604 100644
> --- a/common/main.c
> +++ b/common/main.c
> @@ -342,12 +342,7 @@ void main_loop (void)
>  		int prev = disable_ctrlc(1);	/* disable Control C checking */
>  # endif
>  
> -# ifndef CONFIG_SYS_HUSH_PARSER
> -		run_command (p, 0);
> -# else
> -		parse_string_outer(p, FLAG_PARSE_SEMICOLON |
> -				    FLAG_EXIT_FROM_LOOP);
> -# endif
> +	run_command2(p, 0);

Indentation looks incorrect here?

> -# endif
> -	    }
> +	    if (s)
> +		run_command2(s, 0);

Indentation always by TABs please.

> +int run_command2(const char *cmd, int flag)
> +{
> +#ifndef CONFIG_SYS_HUSH_PARSER
> +	if (run_command(cmd, flag) == -1)
> +		return 1;
> +#else
> +	if (parse_string_outer(cmd,
> +	    FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP) != 0)
> +		return 1;
> +#endif
> +	return 0;

Why do you make this function return int when there is no tesing of
the return code anywhere?

And why do you make this not an inline function (or macro) so the
compiler could avoid the function call overhead?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The more sins you confess, the more books you will sell.


More information about the U-Boot mailing list