[PATCH 3/5] bitfield: oversized bitfields are errors

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

 



Till now, a bitfield with a width bigger than its base type
only caused a warning but this should be considered as an error
since it's generally impossible to emit correct IR code for it.

Fix this by issuing an error instead and marking the width
as invalid.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 symbol.c                    | 6 ++++--
 validation/bitfield-sizes.c | 1 -
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/symbol.c b/symbol.c
index 6c1fb2a5195f..40e50874c27f 100644
--- a/symbol.c
+++ b/symbol.c
@@ -258,8 +258,10 @@ static struct symbol *examine_bitfield_type(struct symbol *sym)
 
 	if (!base_type)
 		return sym;
-	if (sym->bit_size > base_type->bit_size)
-		warning(sym->pos, "impossible field-width, %d, for this type",  sym->bit_size);
+	if (sym->bit_size > base_type->bit_size) {
+		sparse_error(sym->pos, "impossible field-width, %d, for this type",  sym->bit_size);
+		sym->bit_size = -1;
+	}
 
 	alignment = base_type->ctype.alignment;
 	if (!sym->ctype.alignment)
diff --git a/validation/bitfield-sizes.c b/validation/bitfield-sizes.c
index e30a3e4c649c..c43bb0a4aeb2 100644
--- a/validation/bitfield-sizes.c
+++ b/validation/bitfield-sizes.c
@@ -19,7 +19,6 @@ 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.
-- 
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