diff options
author | Linus Torvalds <torvalds@penguin.transmeta.com> | 2003-04-14 18:34:27 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:00:31 -0700 |
commit | 37c56b2bd1f6a59af7ef6c88e7d2cbc7e747602f (patch) | |
tree | bfe7061e0e60fc0ed171539290ce16b5ed281f7b | |
parent | Evaluate array initializers (type fixing and array index (diff) | |
download | sparse-37c56b2bd1f6a59af7ef6c88e7d2cbc7e747602f.tar.gz sparse-37c56b2bd1f6a59af7ef6c88e7d2cbc7e747602f.tar.bz2 sparse-37c56b2bd1f6a59af7ef6c88e7d2cbc7e747602f.zip |
Peter points out that the type masking shifts can overflow
if sizeof(long long) == sizeof(long) (and furter if it's
also the same size as 'int', all perfectly legal C). Fix
it by his suggestion.
-rw-r--r-- | expression.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/expression.c b/expression.c index bc36563..6658312 100644 --- a/expression.c +++ b/expression.c @@ -123,12 +123,12 @@ static void get_int_value(struct expression *expr, const char *str) bits = BITS_IN_LONGLONG; extramod = 0; if (!(modifiers & MOD_LONGLONG)) { - if (value & (~0ULL << BITS_IN_LONG)) { + if (value & (~1ULL << (BITS_IN_LONG-1))) { extramod = MOD_LONGLONG | MOD_LONG; } else { bits = BITS_IN_LONG; if (!(modifiers & MOD_LONG)) { - if (value & (~0ULL << BITS_IN_INT)) { + if (value & (~1ULL << (BITS_IN_INT-1))) { extramod = MOD_LONG; } else bits = BITS_IN_INT; |