cmd: avoid decimal conversion
PATCH 1/1 cmd: avoid decimal conversion
From: T Karthik Reddy <[email protected]>
This patch uses auto instead of decimal in simple_strtoul().
---
cmd/test.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
cmd/test.c +12 -12
@@ -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 );
Signature · 1 line
2.17.1
PATCH 1/1 cmd: avoid decimal conversion
Quoted 46 lines · Michal Simek
From: T Karthik Reddy <[email protected]>
This patch uses auto instead of decimal in
simple_strtoul().Signed-off-by T Karthik Reddy <[email protected]>Signed-off-by Michal Simek <[email protected]>---
cmd/test.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)cmd/test.c +9
-10@@ -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) >
cmd/test.c static int do_test(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 140
Quoted 10 lines
cmd/test.c +3
-2+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.
Signature · 8 lines
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>
PATCH 1/1 cmd: avoid decimal conversion
Quoted 57 lines · Tom Rini
Quoted 54 lines · Michal Simek
From: T Karthik Reddy <[email protected]>
This patch uses auto instead of decimal in
simple_strtoul().Signed-off-by T Karthik Reddy <[email protected]>Signed-off-by Michal Simek <[email protected]>---
cmd/test.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)cmd/test.c +12
-12@@ -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 ;
Quoted 8 lines
cmd/test.c static int do_test(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 140
Quoted 2 lines
cmd/test.c +0
-0case 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.
Well, I think that this is automatic. There should be a back compatibility with the ABI if base is 10
Michael
Quoted 7 lines
--
Tom
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
--
| Michael Nazzareno Trimarchi Amarula Solutions BV | | COO - Founder Cruquiuskade 47 | | +31(0)851119172 Amsterdam 1018 AM NL | | [`as] http://www.amarulasolutions.com |
PATCH 1/1 cmd: avoid decimal conversion
In reply to Tom RiniQuoted 56 lines · Tom Rini
Quoted 54 lines · Michal Simek
From: T Karthik Reddy <[email protected]>
This patch uses auto instead of decimal in
simple_strtoul().Signed-off-by T Karthik Reddy <[email protected]>Signed-off-by Michal Simek <[email protected]>---
cmd/test.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)cmd/test.c +12
-12@@ -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 ;
Quoted 8 lines
cmd/test.c static int do_test(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 140
Quoted 2 lines
cmd/test.c +0
-0case 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.
I also think that this is not breaking any ABI. test_hush_if_test.py is around for a while to capture issues in this space and I can't see any single failure in connection to this change.
If this accepted then we can add more tests like this
('test 0x2000000 -gt 0x2000001', False),
('test 0x2000000 -gt 0x2000000', False),
('test 0x2000000 -gt 0x1ffffff', True),
('test 2000000 -gt 0x1ffffff', False),
('test 0x2000000 -gt 1ffffff', True),
('test 0x2000000 -lt 1ffffff', False),
('test 0x2000000 -eq 2000000', False),
('test 0x2000000 -ne 2000000', True),where some of them are failing without this patch ... test_hush_if_test[test 0x2000000 -gt 0x1ffffff-True]
... test_hush_if_test[test 2000000 -gt 0x1ffffff-False]
... test_hush_if_test[test 0x2000000 -gt 1ffffff-True]
... test_hush_if_test[test 0x2000000 -lt 1ffffff-False]
Thanks,
Michal
PATCH 1/1 cmd: avoid decimal conversion
Hi Tom,
Quoted 81 lines · Michal Simek
Quoted 56 lines · Tom Rini
Quoted 54 lines · Michal Simek
From: T Karthik Reddy <[email protected]>
This patch uses auto instead of decimal in
simple_strtoul().Signed-off-by T Karthik Reddy <[email protected]>Signed-off-by Michal Simek <[email protected]>---
cmd/test.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)cmd/test.c +12
-12@@ -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 ;Quoted 8 lines
cmd/test.c static int do_test(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 140
Quoted 2 lines
cmd/test.c +0
-0case 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.
I also think that this is not breaking any ABI.
test_hush_if_test.pyis around for a while to capture issues in this space and I can't see any single failure in connection to this change.If this accepted then we can add more tests like this
('test 0x2000000 -gt 0x2000001', False), ('test 0x2000000 -gt 0x2000000', False), ('test 0x2000000 -gt 0x1ffffff', True), ('test 2000000 -gt 0x1ffffff', False), ('test 0x2000000 -gt 1ffffff', True), ('test 0x2000000 -lt 1ffffff', False), ('test 0x2000000 -eq 2000000', False), ('test 0x2000000 -ne 2000000', True),
Quoted 9 lines
where some of them are failing without this patch ... test_hush_if_test[test
0x2000000-gt 0x1ffffff-True]... test_hush_if_test[test 2000000 -gt 0x1ffffff-False]
... test_hush_if_test[test
0x2000000-gt 1ffffff-True]... test_hush_if_test[test
0x2000000-lt 1ffffff-False]
Any comment on this?
Thanks,
Michal
PATCH 1/1 cmd: avoid decimal conversion
Quoted 87 lines · Michal Simek
Hi Tom,
Quoted 84 lines · Michal Simek
Quoted 56 lines · Tom Rini
Quoted 54 lines · Michal Simek
From: T Karthik Reddy <[email protected]>
This patch uses auto instead of decimal in
simple_strtoul().Signed-off-by T Karthik Reddy <[email protected]>Signed-off-by Michal Simek <[email protected]>---
cmd/test.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)cmd/test.c +12
-12@@ -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 ;Quoted 8 lines
cmd/test.c static int do_test(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 140
Quoted 2 lines
cmd/test.c +0
-0case 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.
I also think that this is not breaking any ABI.
test_hush_if_test.pyis around for a while to capture issues in this space and I can't see any single failure in connection to this change.If this accepted then we can add more tests like this
('test 0x2000000 -gt 0x2000001', False), ('test 0x2000000 -gt 0x2000000', False), ('test 0x2000000 -gt 0x1ffffff', True), ('test 2000000 -gt 0x1ffffff', False), ('test 0x2000000 -gt 1ffffff', True), ('test 0x2000000 -lt 1ffffff', False), ('test 0x2000000 -eq 2000000', False), ('test 0x2000000 -ne 2000000', True),where some of them are failing without this patch ... test_hush_if_test[test
0x2000000-gt 0x1ffffff-True]
Quoted 8 lines
Quoted 6 lines
... test_hush_if_test[test 2000000 -gt 0x1ffffff-False]
... test_hush_if_test[test
0x2000000-gt 1ffffff-True]... test_hush_if_test[test
0x2000000-lt 1ffffff-False]Any comment on this?
Sorry, yes, OK, we can take this then. I should have this in my first batch of non-python general changes I grab.
Signature · 8 lines
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/20191009/81ec862b/attachment-0001.sig>
PATCH 1/1 cmd: avoid decimal conversion
Am 09.10.2019 um 18:26 schrieb Tom Rini:
Quoted 92 lines · Michal Simek
Quoted 91 lines
Hi Tom,
Quoted 88 lines · Michal Simek
Quoted 56 lines · Tom Rini
Quoted 54 lines · Michal Simek
From: T Karthik Reddy <[email protected]>
This patch uses auto instead of decimal in
simple_strtoul().Signed-off-by T Karthik Reddy <[email protected]>Signed-off-by Michal Simek <[email protected]>---
cmd/test.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)cmd/test.c +12
-12@@ -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 ;Quoted 8 lines
cmd/test.c static int do_test(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 140
Quoted 2 lines
cmd/test.c +0
-0case 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.
I also think that this is not breaking any ABI.
test_hush_if_test.pyis around for a while to capture issues in this space and I can't see any single failure in connection to this change.If this accepted then we can add more tests like this
('test 0x2000000 -gt 0x2000001', False), ('test 0x2000000 -gt 0x2000000', False), ('test 0x2000000 -gt 0x1ffffff', True), ('test 2000000 -gt 0x1ffffff', False), ('test 0x2000000 -gt 1ffffff', True), ('test 0x2000000 -lt 1ffffff', False), ('test 0x2000000 -eq 2000000', False), ('test 0x2000000 -ne 2000000', True),where some of them are failing without this patch ... test_hush_if_test[test
0x2000000-gt 0x1ffffff-True]... test_hush_if_test[test 2000000 -gt 0x1ffffff-False]
... test_hush_if_test[test
0x2000000-gt 1ffffff-True]
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
... test_hush_if_test[test
0x2000000-lt 1ffffff-False]Any comment on this?
Sorry, yes, OK, we can take this then. I should have this in my first batch of non-python general changes I grab.
But strtoul("010", NULL, 0) is 8 while strtoul("010", NULL, 10) is 10. Do we care for that change?
Regards,
Simon
PATCH 1/1 cmd: avoid decimal conversion
Quoted 100 lines · Simon Goldschmidt
Am 09.10.2019 um 18:26 schrieb Tom Rini:
Quoted 99 lines · Michal Simek
Quoted 98 lines
Hi Tom,
Quoted 94 lines · Michal Simek
Quoted 60 lines · Tom Rini
Quoted 49 lines · Michal Simek
From: T Karthik Reddy <[email protected]>
This patch uses auto instead of decimal in
simple_strtoul().Signed-off-by T Karthik Reddy <[email protected]>Signed-off-by Michal Simek <[email protected]>---
cmd/test.c| 24 ++++++++++++------------1 file changed, 12 insertions(+), 12 deletions(-)cmd/test.c +0
-0@@ -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;
caseOP_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;
caseOP_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;
caseOP_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;
caseOP_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;Quoted 8 lines
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;
caseOP_FILE_EXISTS:
expr =file_exists(ap[1], ap[2], ap[3], FS_TYPE_ANY);Quoted 8 lines
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.I also think that this is not breaking any ABI.
test_hush_if_test.pyis around for a while to capture issues in this space and I can't see any single failure in connection to this change.If this accepted then we can add more tests like this ('test
0x2000000-gt0x2000001', False), ('test0x2000000-gt0x2000000', False), ('test0x2000000-gt0x1ffffff', True), ('test 2000000 -gt0x1ffffff', False), ('test0x2000000-gt 1ffffff', True),('test
0x2000000-lt 1ffffff', False),
('test0x2000000-eq 2000000', False),
('test0x2000000-ne 2000000', True),where some of them are failing without this patch ... test_hush_if_test[test
0x2000000-gt 0x1ffffff-True]... test_hush_if_test[test 2000000 -gt 0x1ffffff-False]
... test_hush_if_test[test
0x2000000-gt 1ffffff-True]... test_hush_if_test[test
0x2000000-lt 1ffffff-False]
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Any comment on this?
Sorry, yes, OK, we can take this then. I should have this in my first batch of non-python general changes I grab.
But
strtoul("010", NULL, 0)is 8 whilestrtoul("010", NULL, 10)is 10. Do we care for that change?
Leading zeroes are problematic
Before the patch this pass
test 010 -eq 10 && echo yes
After the patch this fail.
I can't see any test in test/py/tests/test_hush_if_test.py to cover this case that's why I can't guess if this is used or not.
Thanks,
Michal
PATCH 1/1 cmd: avoid decimal conversion
Quoted 112 lines · Michal Simek
Quoted 100 lines · Simon Goldschmidt
Am 09.10.2019 um 18:26 schrieb Tom Rini:
Quoted 99 lines · Michal Simek
Quoted 98 lines
Hi Tom,
Quoted 94 lines · Michal Simek
Quoted 60 lines · Tom Rini
Quoted 56 lines · Michal Simek
From: T Karthik Reddy <[email protected]>
This patch uses auto instead of decimal in
simple_strtoul().Signed-off-by T Karthik Reddy <[email protected]>Signed-off-by Michal Simek <[email protected]>---
cmd/test.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)cmd/test.c +12
-12@@ -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 :Quoted 1 line
expr = file_exists(ap[1], ap[2], ap[3], FS_TYPE_ANY);Quoted 8 lines
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.I also think that this is not breaking any ABI.
test_hush_if_test.pyis around for a while to capture issues in this space and I can't see any single failure in connection to this change.If this accepted then we can add more tests like this
('test 0x2000000 -gt 0x2000001', False), ('test 0x2000000 -gt 0x2000000', False), ('test 0x2000000 -gt 0x1ffffff', True), ('test 2000000 -gt 0x1ffffff', False), ('test 0x2000000 -gt 1ffffff', True), ('test 0x2000000 -lt 1ffffff', False), ('test 0x2000000 -eq 2000000', False), ('test 0x2000000 -ne 2000000', True),where some of them are failing without this patch ... test_hush_if_test[test
0x2000000-gt 0x1ffffff-True]... test_hush_if_test[test 2000000 -gt 0x1ffffff-False]
... test_hush_if_test[test
0x2000000-gt 1ffffff-True]... test_hush_if_test[test
0x2000000-lt 1ffffff-False]Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Any comment on this?
Sorry, yes, OK, we can take this then. I should have this in my first batch of non-python general changes I grab.
But
strtoul("010", NULL, 0)is 8 whilestrtoul("010", NULL, 10)is 10. Do we care for that change?Leading zeroes are problematic
Quoted 7 lines
Before the patch this pass
test 010 -eq 10 && echo yesAfter the patch this fail.
I can't see any test in
test/py/tests/test_hush_if_test.pyto cover this case that's why I can't guess if this is used or not.
Hmm, it might not be a problem then...?
Regards,
Simon
PATCH 1/1 cmd: avoid decimal conversion
In reply to Michal SimekQuoted 6 lines · Michal Simek
From: T Karthik Reddy <[email protected]>
This patch uses auto instead of decimal in
simple_strtoul().Signed-off-by T Karthik Reddy <[email protected]>Signed-off-by Michal Simek <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
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/20191012/553888ff/attachment.sig>