[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 4/9] s390x: Avoid variable size warning in ipl.h
From: |
Daniele Buono |
Subject: |
[PATCH v3 4/9] s390x: Avoid variable size warning in ipl.h |
Date: |
Thu, 5 Nov 2020 17:19:00 -0500 |
S390IPLState contains two IplParameterBlock, which may in turn have
either a IPLBlockPV or a IplBlockFcp, both ending with a variable
sized field (an array).
This causes a warning with clang 11 or greater, which checks that
variable sized type are only allocated at the end of the struct:
In file included from ../qemu-cfi-v3/target/s390x/diag.c:21:
../qemu-cfi-v3/hw/s390x/ipl.h:161:23: error: field 'iplb' with variable sized
type 'IplParameterBlock' (aka 'union IplParameterBlock') not at the end of a
struct or class is a GNU extension
[-Werror,-Wgnu-variable-sized-type-not-at-end]
IplParameterBlock iplb;
^
../qemu-cfi-v3/hw/s390x/ipl.h:162:23: error: field 'iplb_pv' with variable
sized type 'IplParameterBlock' (aka 'union IplParameterBlock') not at the end
of a struct or class is a GNU extension
[-Werror,-Wgnu-variable-sized-type-not-at-end]
IplParameterBlock iplb_pv;
In this case, however, the warning is a false positive, because
IPLBlockPV and IplBlockFcp are allocated in a union wrapped at 4K,
making the union non-variable sized.
Fix the warning by turning the two variable sized arrays into arrays
of size 0. This avoids the compiler error and should produce the
same code.
Signed-off-by: Daniele Buono <dbuono@linux.vnet.ibm.com>
---
There is the possibility of removing IplBlockFcp from
IplParameterBlock, since it is not actually used.
This would also allow to entirely remove the definition of
IplBlockFcp, but we may want to keep it for completeness.
hw/s390x/ipl.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h
index 9e90169695..dfc6dfd89c 100644
--- a/hw/s390x/ipl.h
+++ b/hw/s390x/ipl.h
@@ -32,7 +32,7 @@ struct IPLBlockPV {
uint32_t num_comp; /* 0x74 */
uint64_t pv_header_addr; /* 0x78 */
uint64_t pv_header_len; /* 0x80 */
- struct IPLBlockPVComp components[];
+ struct IPLBlockPVComp components[0];
} QEMU_PACKED;
typedef struct IPLBlockPV IPLBlockPV;
@@ -63,7 +63,7 @@ struct IplBlockFcp {
uint64_t br_lba;
uint32_t scp_data_len;
uint8_t reserved6[260];
- uint8_t scp_data[];
+ uint8_t scp_data[0];
} QEMU_PACKED;
typedef struct IplBlockFcp IplBlockFcp;
--
2.17.1
- [PATCH v3 0/9] Add support for Control-Flow Integrity, Daniele Buono, 2020/11/05
- [PATCH v3 1/9] fuzz: Make fork_fuzz.ld compatible with LLVM's LLD, Daniele Buono, 2020/11/05
- [PATCH v3 2/9] s390x: fix clang 11 warnings in cpu_models.c, Daniele Buono, 2020/11/05
- [PATCH v3 4/9] s390x: Avoid variable size warning in ipl.h,
Daniele Buono <=
- [PATCH v3 6/9] configure,meson: add option to enable LTO, Daniele Buono, 2020/11/05
- [PATCH v3 5/9] scsi: fix overflow in scsi_disk_new_request_dump, Daniele Buono, 2020/11/05
[PATCH v3 7/9] cfi: Initial support for cfi-icall in QEMU, Daniele Buono, 2020/11/05
[PATCH v3 8/9] check-block: enable iotests with cfi-icall, Daniele Buono, 2020/11/05
[PATCH v3 9/9] configure,meson: support Control-Flow Integrity, Daniele Buono, 2020/11/05