diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2022-08-23 11:44:32 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2022-08-23 11:44:32 -0700 |
commit | d618d8e6043e229de0358b24bc793ef10e3e041b (patch) | |
tree | 470df5b66c81ceaedf56cbda9fca3a1397dee483 | |
parent | dbaf1d1fe95efa2c2d9360a09a76e0e94b7bee85 (diff) | |
download | sparse-d618d8e6043e229de0358b24bc793ef10e3e041b.tar.gz |
bitwise: allow all-bits-set as a restricted value
We've always allowed zero ("no bits set") as a special case for bitwise
restricted types. For the exact same reason we should allow the "all
bits set" case, but it was just harder to test for, since that case
wasn't just a simple constant value.
The previous commit now made it a simple constant value, and we can
easily handle that case too.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | evaluate.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -418,8 +418,10 @@ static int restricted_value(struct expression *v, struct symbol *type) { if (v->type != EXPR_VALUE) return 1; - if (v->value != 0) - return 1; + if (v->value != 0) { + unsigned long long mask = bits_mask(type->bit_size); + return (v->value & mask) != mask; + } return 0; } |