Jakub Czapiga has submitted this change. ( https://review.coreboot.org/c/coreboot/+/76815?usp=email )
Change subject: util: Use C99 flexible arrays ......................................................................
util: Use C99 flexible arrays
Use C99 flexible arrays instead of older style of one-element or zero-length arrays. It allows the compiler to generate errors when the flexible array does not occur at the end in the structure.
Change-Id: I6b87680ec9f501945ae266ae4e4927efd2399d56 Signed-off-by: Elyes Haouas ehaouas@noos.fr Reviewed-on: https://review.coreboot.org/c/coreboot/+/76815 Reviewed-by: Felix Singer service+coreboot-gerrit@felixsinger.de Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M util/cbfstool/ifwitool.c M util/cbmem/cbmem.c M util/intelvbttool/intelvbttool.c M util/nvramtool/coreboot_tables.h 4 files changed, 7 insertions(+), 7 deletions(-)
Approvals: Felix Singer: Looks good to me, approved build bot (Jenkins): Verified
diff --git a/util/cbfstool/ifwitool.c b/util/cbfstool/ifwitool.c index efcb594..453d85c 100644 --- a/util/cbfstool/ifwitool.c +++ b/util/cbfstool/ifwitool.c @@ -70,7 +70,7 @@ struct bpdt { struct bpdt_header h; /* In practice, this could be an array of 0 to n entries. */ - struct bpdt_entry e[0]; + struct bpdt_entry e[]; } __packed;
static inline size_t get_bpdt_size(struct bpdt_header *h) @@ -124,7 +124,7 @@ struct subpart_dir { struct subpart_dir_header h; /* In practice, this could be an array of 0 to n entries. */ - struct subpart_dir_entry e[0]; + struct subpart_dir_entry e[]; } __packed;
static inline size_t subpart_dir_size(struct subpart_dir_header *h) diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c index 73c410c..d33b714 100644 --- a/util/cbmem/cbmem.c +++ b/util/cbmem/cbmem.c @@ -1116,7 +1116,7 @@ struct cbmem_console { u32 size; u32 cursor; - u8 body[0]; + u8 body[]; } __attribute__ ((__packed__));
#define CBMC_CURSOR_MASK ((1 << 28) - 1) diff --git a/util/intelvbttool/intelvbttool.c b/util/intelvbttool/intelvbttool.c index c8d7a08..a70b33c 100644 --- a/util/intelvbttool/intelvbttool.c +++ b/util/intelvbttool/intelvbttool.c @@ -157,7 +157,7 @@ * number = (block_size - sizeof(bdb_general_definitions))/ * sizeof(child_device_config); */ - struct common_child_dev_config devices[0]; + struct common_child_dev_config devices[]; } __attribute__ ((packed));
struct bdb_driver_features { diff --git a/util/nvramtool/coreboot_tables.h b/util/nvramtool/coreboot_tables.h index aafeab4..d4db00c 100644 --- a/util/nvramtool/coreboot_tables.h +++ b/util/nvramtool/coreboot_tables.h @@ -90,7 +90,7 @@ struct lb_memory { uint32_t tag; uint32_t size; - struct lb_memory_range map[0]; + struct lb_memory_range map[]; };
#define LB_TAG_HWRPB 0x0002 @@ -106,7 +106,7 @@ uint32_t size; uint8_t vendor_idx; uint8_t part_number_idx; - uint8_t strings[0]; + uint8_t strings[]; };
#define LB_TAG_VERSION 0x0004 @@ -122,7 +122,7 @@ struct lb_string { uint32_t tag; uint32_t size; - uint8_t string[0]; + uint8_t string[]; }; #define LB_TAG_SERIAL 0x000f #define LB_TAG_CONSOLE 0x0010