[PATCH v1 1/1] cmd: setexpr: add dec operation for converting variable to decimal

Wolfgang Denk wd at denx.de
Wed Jun 23 08:03:01 CEST 2021


Dear Roland,

In message <20210622135042.133904-2-roland.gaudig-oss at weidmueller.com> you wrote:
>
> This patch extends the setexpr command with a dec operator to
> convert an input value to decimal.
...
> +	/* hexadecimal to decimal conversion: "setexpr name dec value" */
> +	if (argc == 4 && (strcmp(argv[2], "dec") == 0)) {
> +		w = cmd_get_data_size(argv[3], 4);
> +		a = get_arg(argv[3], w);
> +		return env_set_ulong(argv[1], a);
> +	}

Should there not be a test for 4 arguments and the third _not_ being
"dec" ?  Like "setexpr foo hex 42" ?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
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
A wise man asks himself the reason for his  mistakes,  while  a  fool
will ask others.


More information about the U-Boot mailing list