[U-Boot] [PATCH v3 1/4] Add run_command_list() to run a list of commands
Mike Frysinger
vapier at gentoo.org
Sun Apr 1 21:48:46 CEST 2012
On Saturday 31 March 2012 03:30:55 Simon Glass wrote:
> --- a/common/cmd_pxe.c
> +++ b/common/cmd_pxe.c
>
> + return run_command_list(localcmd, strlen(localcmd), 0);
should be -1 instead of strlen()
> +int run_command_list(const char *cmd, int len, int flag)
> +{
> + int need_buff = 1;
> + char *buff = (char *)cmd; /* cast away const */
> + int rcode = 0;
> +
> + if (len == -1) {
> + len = strlen(cmd);
> +#ifdef CONFIG_SYS_HUSH_PARSER
> + /* hush will never change our string */
> + need_buff = 0;
> +#else
> + /* the built-in parser will change our string if it sees \n */
> + need_buff = strchr(cmd, '\n') != NULL;
> +#endif
> + }
we have memchr(), so you should be able to split the len==-1 and the need_buff
logic into two sep steps
also, should you handle the case where '\n' is the very last char ? or not
bother ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120401/846a2a5e/attachment.pgp>
More information about the U-Boot
mailing list