Re: [U-Boot] [PATCH] Don't do an undefined 32-bit shift on a 32-bit value for a long (4 byte) itest.l command.
On Wed, Jun 15, 2011 at 19:10, Joshua Radel wrote: Without this fix, the following statement erroneously echoed true (at least on the microblaze architecture): if itest.l 0 == 1; then echo true; else echo false; fi (using itest.w or itest.b worked as expected even without this change) the subject should read something like: itest: avoid undefined C semantics with large shift values Signed-off-by: Josh Radel josh.radel_at_intusurg.com your s-o-b tag is invalid. you must have a proper e-mail address here. mode change 100644 = 100755 common/cmd_itest.c this is wrong. i guess you're editing on a windows machine or something. no .c file should be executable. - return (l ((1 (w * 8)) - 1)); + if (w sizeof(long)) { + return (l ((1 (w * 8)) - 1)); + } else { + return (l); + } please add a comment as to why the sizeof(long) test is here. i dont think most people reading the code at a glance will grok what it's doing. -mike ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] Don't do an undefined 32-bit shift on a 32-bit value for a long (4 byte) itest.l command.
Without this fix, the following statement erroneously echoed true (at least on the microblaze architecture): if itest.l 0 == 1; then echo true; else echo false; fi (using itest.w or itest.b worked as expected even without this change) Signed-off-by: Josh Radel josh.radel_at_intusurg.com --- common/cmd_itest.c |6 +- 1 files changed, 5 insertions(+), 1 deletions(-) mode change 100644 = 100755 common/cmd_itest.c diff --git a/common/cmd_itest.c b/common/cmd_itest.c old mode 100644 new mode 100755 index 2a238a4..5f5ac4e --- a/common/cmd_itest.c +++ b/common/cmd_itest.c @@ -79,7 +79,11 @@ static long evalexp(char *s, int w) l = simple_strtoul(s, NULL, 16); } - return (l ((1 (w * 8)) - 1)); + if (w sizeof(long)) { + return (l ((1 (w * 8)) - 1)); + } else { + return (l); + } } static char * evalstr(char *s) -- 1.6.0.4 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot