summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorSebastien Colleur <sebastienx.colleur@intel.com>2017-02-10 15:59:15 +0300
committerTom Rini <trini@konsulko.com>2017-03-17 14:15:10 -0400
commit2c79fd401982c7d6c5e77c09bc7035f8a3766c88 (patch)
tree1e4d8cc905494d2520d738e676420d0efed7474a /cmd
parent2cfe312258457c5c94c61e813448505d200fdc14 (diff)
cmd: itest: correct calculus for long format
itest shell command doesn't work correctly in long format when doing comparaison due to wrong mask value calculus that overflow on 32 bits values. Signed-off-by: Sebastien Colleur <sebastienx.colleur@intel.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/itest.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/cmd/itest.c b/cmd/itest.c
index 60626c7fe9..e1896d9f97 100644
--- a/cmd/itest.c
+++ b/cmd/itest.c
@@ -80,7 +80,8 @@ static long evalexp(char *s, int w)
l = simple_strtoul(s, NULL, 16);
}
- return l & ((1UL << (w * 8)) - 1);
+ /* avoid overflow on mask calculus */
+ return (w >= sizeof(long)) ? l : (l & ((1UL << (w * 8)) - 1));
}
static char * evalstr(char *s)