mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-28 15:41:40 +00:00
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>
This commit is contained in:
parent
2cfe312258
commit
2c79fd4019
1 changed files with 2 additions and 1 deletions
|
@ -80,7 +80,8 @@ static long evalexp(char *s, int w)
|
||||||
l = simple_strtoul(s, NULL, 16);
|
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)
|
static char * evalstr(char *s)
|
||||||
|
|
Loading…
Reference in a new issue