Commit
2c79fd401982c7d6c5e77c09bc7035f8a3766c88
Exists in
smarc_8mq_lf_v2020.04
and in
18 other branches
8qm-imx_v2020.04_5.4.70_2.3.0, emb_lf_v2022.04, emb_lf_v2023.04, pitx_8mp_lf_v2020.04, smarc-8m-android-10.0.0_2.6.0, smarc-8m-android-11.0.0_2.0.0, smarc-8mp-android-11.0.0_2.0.0, smarc-imx6_v2018.03_4.14.98_2.0.0_ga, smarc-imx7_v2018.03_4.14.98_2.0.0_ga, smarc-imx_v2018.03_4.14.78_1.0.0_ga, smarc_8m-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8m-imx_v2019.04_4.19.35_1.1.0, smarc_8m_00d0-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8mm-imx_v2019.04_4.19.35_1.1.0, smarc_8mm-imx_v2020.04_5.4.24_2.1.0, smarc_8mp_lf_v2020.04, smarc_8mq-imx_v2020.04_5.4.24_2.1.0
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>
Showing
1 changed file
with
2 additions
and
1 deletions
Side-by-side Diff
... |
... |
@@ -80,7 +80,8 @@ |
80
|
80 |
l = simple_strtoul(s, NULL, 16); |
81
|
81 |
} |
82
|
82 |
|
83
|
|
- return l & ((1UL << (w * 8)) - 1); |
|
83 |
+ /* avoid overflow on mask calculus */ |
|
84 |
+ return (w >= sizeof(long)) ? l : (l & ((1UL << (w * 8)) - 1)); |
84
|
85 |
} |
85
|
86 |
|
86
|
87 |
static char * evalstr(char *s) |