Skip to content
Snippets Groups Projects
Commit 2c79fd40 authored by Sebastien Colleur's avatar Sebastien Colleur Committed by Tom Rini
Browse files

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: default avatarSebastien Colleur <sebastienx.colleur@intel.com>
Reviewed-by: default avatarSimon Glass <sjg@chromium.org>
parent 2cfe3122
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment