[U-Boot] [PATCH v2 10/25] common/misc: sparse fixes

Henrik Nordström henrik at henriknordstrom.net
Mon Nov 5 22:30:33 CET 2012


mån 2012-10-29 klockan 18:34 -0500 skrev Kim Phillips:

> diff --git a/common/command.c b/common/command.c
> index 50c8429..f51df26 100644
> --- a/common/command.c
> +++ b/common/command.c
> @@ -40,8 +40,15 @@ int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
>  	int i;
>  	int rcode = 0;
>  
> +	if (cmd_items > CONFIG_SYS_MAXARGS) {
> +		printf("%s: cmd_items %d exceeds hardcoded limit %d."
> +		       " Recompile with higher CONFIG_SYS_MAXARGS?\n",
> +		       __func__, cmd_items, CONFIG_SYS_MAXARGS);
> +		return -1;
> +	}
> +
>  	if (argc == 1) {	/*show list of commands */
> -		cmd_tbl_t *cmd_array[cmd_items];
> +		cmd_tbl_t *cmd_array[CONFIG_SYS_MAXARGS];
>  		int i, j, swaps;
>  


This breaks the help command if there is more than 16 commands enabled,
i.e. for everyone.

CONFIG_SYS_MAXARGS is not meant to be the maximum number of commands, it
is the maximum number of arguments to a single command.

Regards
Henrik



More information about the U-Boot mailing list