[PATCH 1/5] bitfield: add testcases for invalid bitfield width

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add some testcases before making related changes.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 validation/bitfield-sizes.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 validation/bitfield-sizes.c

diff --git a/validation/bitfield-sizes.c b/validation/bitfield-sizes.c
new file mode 100644
index 000000000000..e30a3e4c649c
--- /dev/null
+++ b/validation/bitfield-sizes.c
@@ -0,0 +1,31 @@
+struct a {
+	int  a:31;
+	int  b:32;
+	long c:63;
+	long d:64;
+	int  x:33;		// KO
+	long y:65;		// KO
+};
+static struct a a;
+
+struct b {
+	int m1:-1;		// KO
+	int x1:2147483648;	// KO
+	int :0;
+	int a0:0;		// KO
+};
+static struct b b;
+
+/*
+ * check-name: bitfield-sizes
+ * check-command: sparse -m64 $file
+ * check-known-to-fail
+ *
+ * check-error-start
+bitfield-sizes.c:12:18: error: invalid bitfield width, -1.
+bitfield-sizes.c:13:26: error: invalid bitfield width, 2147483648.
+bitfield-sizes.c:15:17: error: invalid named zero-width bitfield `a0'
+bitfield-sizes.c:6:15: error: impossible field-width, 33, for this type
+bitfield-sizes.c:7:15: error: impossible field-width, 65, for this type
+ * check-error-end
+ */
-- 
2.24.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux