[U-Boot] [PATCH] cmd: avoid decimal conversion

Tom Rini trini at konsulko.com
Fri Sep 13 15:09:05 UTC 2019


On Wed, Sep 11, 2019 at 03:39:53PM +0200, Michal Simek wrote:

> From: T Karthik Reddy <t.karthik.reddy at xilinx.com>
> 
> This patch uses auto instead of decimal in simple_strtoul().
> 
> Signed-off-by: T Karthik Reddy <t.karthik.reddy at xilinx.com>
> Signed-off-by: Michal Simek <michal.simek at xilinx.com>
> ---
> 
>  cmd/test.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/cmd/test.c b/cmd/test.c
> index fa0c349f0827..258bfd880653 100644
> --- a/cmd/test.c
> +++ b/cmd/test.c
> @@ -113,28 +113,28 @@ static int do_test(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>  			expr = strcmp(ap[0], ap[2]) > 0;
>  			break;
>  		case OP_INT_EQ:
> -			expr = simple_strtol(ap[0], NULL, 10) ==
> -					simple_strtol(ap[2], NULL, 10);
> +			expr = simple_strtol(ap[0], NULL, 0) ==
> +					simple_strtol(ap[2], NULL, 0);
>  			break;
>  		case OP_INT_NEQ:
> -			expr = simple_strtol(ap[0], NULL, 10) !=
> -					simple_strtol(ap[2], NULL, 10);
> +			expr = simple_strtol(ap[0], NULL, 0) !=
> +					simple_strtol(ap[2], NULL, 0);
>  			break;
>  		case OP_INT_LT:
> -			expr = simple_strtol(ap[0], NULL, 10) <
> -					simple_strtol(ap[2], NULL, 10);
> +			expr = simple_strtol(ap[0], NULL, 0) <
> +					simple_strtol(ap[2], NULL, 0);
>  			break;
>  		case OP_INT_LE:
> -			expr = simple_strtol(ap[0], NULL, 10) <=
> -					simple_strtol(ap[2], NULL, 10);
> +			expr = simple_strtol(ap[0], NULL, 0) <=
> +					simple_strtol(ap[2], NULL, 0);
>  			break;
>  		case OP_INT_GT:
> -			expr = simple_strtol(ap[0], NULL, 10) >
> -					simple_strtol(ap[2], NULL, 10);
> +			expr = simple_strtol(ap[0], NULL, 0) >
> +					simple_strtol(ap[2], NULL, 0);
>  			break;
>  		case OP_INT_GE:
> -			expr = simple_strtol(ap[0], NULL, 10) >=
> -					simple_strtol(ap[2], NULL, 10);
> +			expr = simple_strtol(ap[0], NULL, 0) >=
> +					simple_strtol(ap[2], NULL, 0);
>  			break;
>  		case OP_FILE_EXISTS:
>  			expr = file_exists(ap[1], ap[2], ap[3], FS_TYPE_ANY);

I'm going to NAK this, but could be argued around to changing my mind.
While it's true that in general command inputs are hex and not decimal,
this has been decimal since introduction in 2009.  So changing it now is
breaking ABI and other peoples test scripts, so I don't think we can do
this, sorry.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190913/da42964f/attachment.sig>


More information about the U-Boot mailing list