[PATCH v1 1/1] cmd: setexpr: add dec operation for converting variable to decimal
Roland Gaudig (OSS)
roland.gaudig-oss at weidmueller.com
Wed Jun 23 10:53:56 CEST 2021
Dear Wolfgang,
On Wed, 23. Jun 2021 08:03, Wolfgang Denk <wd at denx.de> wrote:
>
> 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" ?
Yes it's possible to add further conversion operations. But I didn't saw a
need for hex in the first place, as hex is currently the default within
U-Boot. But when adding a decimal prefix as Simon proposed, hex conversion
becomes necessary.
Best regards,
Roland Gaudig
More information about the U-Boot
mailing list