From: Sebastien Colleur Date: Fri, 10 Feb 2017 12:59:15 +0000 (+0300) Subject: cmd: itest: correct calculus for long format X-Git-Tag: baikal/mips/sdk5.9~5391 X-Git-Url: https://git.baikalelectronics.ru/?a=commitdiff_plain;h=1825f74d09c49289a44c4aabf7cd8d5f6ad70371;p=uboot.git 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 Reviewed-by: Simon Glass --- 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)