X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=cmd%2Fitest.c;h=e1896d9f9728df3f8195d6d4a11321c5f67723b1;hb=7b82a229e56d4f1f7f200e4e712c73be2ef9aea5;hp=60626c7fe9c3d983d247aeee6f89b76548a189b5;hpb=f3c264f9de6a5727c90ecf6d46d4747091c0a57f;p=u-boot 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)