GCC10 emits warnings like: msft.c: In function ‘msft_cmd_smart_get_media_temperature’: msft.c:146:28: warning: array subscript 0 is outside the bounds of an interior zero-length array ‘struct ndn_msft_smart_data[0]’ [-Wzero-length-bounds]
hpe1.c: In function ‘hpe1_cmd_smart_get_flags’: hpe1.c:111:33: warning: array subscript 0 is outside the bounds of an interior zero-length array ‘struct ndn_hpe1_smart_data[0]’ [-Wzero-length-bounds] ars.c: In function ‘ndctl_cmd_ars_get_record_addr’: ars.c:274:38: warning: array subscript ‘(<unknown>) + 4294967295’ is outside the bounds of an interior zero-length array ‘struct nd_ars_record[0]’ [-Wzero-length-bounds] In the case of the 'msft' and 'hpe1' implementation the zero-length array is not needed because they are declared with a union of a buffer of the same size as a single element. Fix those cases by just declaring a single element array. The ARS case is different, it's complaining about an internal zero-length member. Switch to the recommended [1] flexible-array syntax for that case. [1]: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html Signed-off-by: Dan Williams <[email protected]> --- ndctl/lib/hpe1.h | 4 ++-- ndctl/lib/msft.h | 2 +- ndctl/ndctl.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ndctl/lib/hpe1.h b/ndctl/lib/hpe1.h index b050831ec2c4..1afa54f127a6 100644 --- a/ndctl/lib/hpe1.h +++ b/ndctl/lib/hpe1.h @@ -111,7 +111,7 @@ struct ndn_hpe1_smart { __u32 status; union { __u8 buf[124]; - struct ndn_hpe1_smart_data data[0]; + struct ndn_hpe1_smart_data data[1]; }; } __attribute__((packed)); @@ -136,7 +136,7 @@ struct ndn_hpe1_smart_threshold { __u32 status; union { __u8 buf[32]; - struct ndn_hpe1_smart_threshold_data data[0]; + struct ndn_hpe1_smart_threshold_data data[1]; }; } __attribute__((packed)); diff --git a/ndctl/lib/msft.h b/ndctl/lib/msft.h index 0a1c7c6a0907..c45981edd8d7 100644 --- a/ndctl/lib/msft.h +++ b/ndctl/lib/msft.h @@ -46,7 +46,7 @@ struct ndn_msft_smart { __u32 status; union { __u8 buf[9]; - struct ndn_msft_smart_data data[0]; + struct ndn_msft_smart_data data[1]; }; } __attribute__((packed)); diff --git a/ndctl/ndctl.h b/ndctl/ndctl.h index 008f81cdeb9f..e3605b3d64b4 100644 --- a/ndctl/ndctl.h +++ b/ndctl/ndctl.h @@ -91,7 +91,7 @@ struct nd_cmd_ars_status { __u32 reserved; __u64 err_address; __u64 length; - } __attribute__((packed)) records[0]; + } __attribute__((packed)) records[]; } __attribute__((packed)); struct nd_cmd_clear_error { _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]
