aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2022-06-27 09:35:07 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2022-06-27 13:57:02 +0200
commitf8f08b3336e380ed1af5f731cc465fe710e64eec (patch)
treeff49f0af62c9ec5f8799243268f98440a859e589 /validation
parentbad12ea3413288aae097bc91dbe4ce1226557966 (diff)
downloadsparse-dev-f8f08b3336e380ed1af5f731cc465fe710e64eec.tar.gz
bitwise: accept all ones as non-restricted value
Currently, the only value bitwise types can act on is 0 because the this value is anyway invariant for all bitwise operations and endianness conversions. But, a bit-pattern of all ones has the same properties and is also very often used. So, accept all ones as a valid value for bitwise operations. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
-rw-r--r--validation/bitwise-cast.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/validation/bitwise-cast.c b/validation/bitwise-cast.c
index 0583461c..1075a3e9 100644
--- a/validation/bitwise-cast.c
+++ b/validation/bitwise-cast.c
@@ -35,6 +35,19 @@ static __be32 quuy(void)
return (__attribute__((force)) __be32) 1730;
}
+/* Implicit casts of all ones, legal */
+static __be32 foo1(void)
+{
+ __be32 x = 0xffffffff;
+ return x;
+}
+
+/* Explicit cast of all ones, legal */
+static __be32 bar1(void)
+{
+ return (__be32)0xffffffff;
+}
+
/*
* check-name: conversions to bitwise types
* check-command: sparse -Wbitwise $file