[U-Boot] [PATCH] Don't do an undefined 32-bit shift on a 32-bit value for a long (4 byte) itest.l command.

Joshua Radel josh.radel at intusurg.com
Thu Jun 16 01:10:42 CEST 2011


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


More information about the U-Boot mailing list