[PATCH 08/13] flex-array: identify structures with a flexible array member

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

 



Structures containing a flexible array must not be nested.
So, as a preparatory step, detect structures or union containing
a flexible array, possibly recursively and mark the corresponding
type with a dedicated flag.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 symbol.c | 6 ++++++
 symbol.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/symbol.c b/symbol.c
index b4c5e471372b..bffdc135ba69 100644
--- a/symbol.c
+++ b/symbol.c
@@ -87,6 +87,7 @@ struct struct_union_info {
 	unsigned long max_align;
 	unsigned long bit_size;
 	int align_size;
+	char has_flex_array;
 	struct symbol *flex_array;
 };
 
@@ -206,6 +207,11 @@ static struct symbol * examine_struct_union_type(struct symbol *sym, int advance
 		bit_align = bytes_to_bits(sym->ctype.alignment)-1;
 		bit_size = (bit_size + bit_align) & ~bit_align;
 	}
+	if (info.flex_array) {
+		info.has_flex_array = 1;
+	}
+	if (info.has_flex_array)
+		sym->has_flex_array = 1;
 	sym->bit_size = bit_size;
 	return sym;
 }
diff --git a/symbol.h b/symbol.h
index a3ed95678ee5..287df0a3a0ee 100644
--- a/symbol.h
+++ b/symbol.h
@@ -185,6 +185,7 @@ struct symbol {
 					examined:1,
 					expanding:1,
 					evaluated:1,
+					has_flex_array:1,
 					string:1,
 					designated_init:1,
 					forced_arg:1,
-- 
2.28.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