From b42923dc5d7f2c6d6aca5ca997c35fb86f088aa4 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Thu, 13 Apr 2023 21:36:14 -0500 Subject: [PATCH] treewide: Prefer flexible arrays to zero-length arrays https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html --- src/eap-mschapv2.c | 2 +- src/mpdu.h | 18 +++++++++--------- src/netdev.c | 2 +- src/rrm.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/eap-mschapv2.c b/src/eap-mschapv2.c index 7eac260b..ef0ce620 100644 --- a/src/eap-mschapv2.c +++ b/src/eap-mschapv2.c @@ -73,7 +73,7 @@ struct mschapv2_response { /* This will always be sizeof(value) */ uint8_t val_length; struct mschapv2_value value; - char name[0]; + char name[]; } __attribute__((packed)); /** diff --git a/src/mpdu.h b/src/mpdu.h index 9a825f2a..f6f19744 100644 --- a/src/mpdu.h +++ b/src/mpdu.h @@ -334,7 +334,7 @@ struct mmpdu_field_capability { struct mmpdu_association_request { struct mmpdu_field_capability capability; __le16 listen_interval; - uint8_t ies[0]; + uint8_t ies[]; } __attribute__ ((packed)); /* 802.11, Section 8.3.3.6 */ @@ -342,7 +342,7 @@ struct mmpdu_association_response { struct mmpdu_field_capability capability; __le16 status_code; __le16 aid; - uint8_t ies[0]; + uint8_t ies[]; } __attribute__ ((packed)); /* 802.11, Section 8.3.3.7 */ @@ -350,7 +350,7 @@ struct mmpdu_reassociation_request { struct mmpdu_field_capability capability; __le16 listen_interval; unsigned char current_ap_address[6]; - uint8_t ies[0]; + uint8_t ies[]; } __attribute__ ((packed)); /* 802.11, Section 8.3.3.8 */ @@ -358,13 +358,13 @@ struct mmpdu_reassociation_response { struct mmpdu_field_capability capability; __le16 status_code; __le16 aid; - uint8_t ies[0]; + uint8_t ies[]; } __attribute__ ((packed)); /* 802.11, Section 8.3.3.4 */ struct mmpdu_disassociation { __le16 reason_code; - uint8_t ies[0]; + uint8_t ies[]; } __attribute__ ((packed)); /* 802.11, Section 8.3.3.9 */ @@ -377,14 +377,14 @@ struct mmpdu_probe_response { __le64 timestamp; __le16 beacon_interval; struct mmpdu_field_capability capability; - uint8_t ies[0]; + uint8_t ies[]; } __attribute__ ((packed)); /* 802.11, Section 8.3.3.15 */ struct mmpdu_timing_advertisement { __le64 timestamp; struct mmpdu_field_capability capability; - uint8_t ies[0]; + uint8_t ies[]; } __attribute__ ((packed)); /* 802.11, Section 8.3.3.2 */ @@ -392,7 +392,7 @@ struct mmpdu_beacon { __le64 timestamp; __le16 beacon_interval; struct mmpdu_field_capability capability; - uint8_t ies[0]; + uint8_t ies[]; } __attribute__ ((packed)); /* 802.11, Section 8.3.3.11 */ @@ -406,7 +406,7 @@ struct mmpdu_authentication { /* 802.11, Section 8.3.3.12 */ struct mmpdu_deauthentication { __le16 reason_code; - uint8_t ies[0]; + uint8_t ies[]; } __attribute__ ((packed)); const struct mmpdu_header *mpdu_validate(const uint8_t *frame, int len); diff --git a/src/netdev.c b/src/netdev.c index 438ec4f8..4ee17f3b 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -99,7 +99,7 @@ struct netdev_handshake_state { struct netdev_ext_key_info { uint16_t proto; bool noencrypt; - struct eapol_frame frame[0]; + struct eapol_frame frame[]; }; struct netdev { diff --git a/src/rrm.c b/src/rrm.c index ed44cee6..7054db36 100644 --- a/src/rrm.c +++ b/src/rrm.c @@ -138,7 +138,7 @@ struct rrm_beacon_report { uint8_t bssid[6]; uint8_t antenna_id; __le32 parent_tsf; - uint8_t subelements[0]; + uint8_t subelements[]; } __attribute__ ((packed)); static struct l_queue *states;