提交 2c79fd40 编写于 作者: S Sebastien Colleur 提交者: Tom Rini

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: NSebastien Colleur <sebastienx.colleur@intel.com>
Reviewed-by: NSimon Glass <sjg@chromium.org>
上级 2cfe3122
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册