Commit 2c79fd401982c7d6c5e77c09bc7035f8a3766c88

Authored by Sebastien Colleur
Committed by Tom Rini
1 parent 2cfe312258

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)