From: Arnd Bergmann Date: Thu, 4 Feb 2021 16:29:17 +0000 (+0100) Subject: carl9170: fix struct alignment conflict X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=cb3e585dce0152374a3db742d232d148f32d0299;p=carl9170fw.git carl9170: fix struct alignment conflict Multiple structures in the carl9170 driver have alignment impossible alignment constraints that gcc warns about when building with 'make W=1': include/shared/fwcmd.h:243:2: warning: alignment 1 of 'union ' is less than 4 [-Wpacked-not-aligned] include/shared/wlan.h:373:1: warning: alignment 1 of 'struct ar9170_rx_frame_single' is less than 2 [-Wpacked-not-aligned] In the carl9170_cmd structure, multiple members that have an explicit alignment requirement of four bytes are added into a union with explicit byte alignment, but this in turn is part of a structure that also has four-byte alignment. In the wlan.h header, multiple structures contain a ieee80211_hdr member that is required to be two-byte aligned to avoid alignmnet faults when processing network headers, but all members are forced to be byte-aligned using the __packed tag at the end of the struct definition. In both cases, leaving out the packing does not change the internal layout of the structure but changes the alignment constraint of the structure itself. Change all affected structures to only apply packing where it does not violate the alignment requirement of the contained structure. Signed-off-by: Arnd Bergmann Signed-off-by: Christian Lamparter --- diff --git a/include/shared/wlan.h b/include/shared/wlan.h index 117f005..61c3112 100644 --- a/include/shared/wlan.h +++ b/include/shared/wlan.h @@ -270,7 +270,7 @@ struct ar9170_tx_frame { struct ar9170_tx_hwdesc hdr; union { - struct ieee80211_hdr i3e; + struct ieee80211_hdr i3e __packed __aligned(2); u8 payload[0]; } data; } __packed __aligned(4); @@ -367,24 +367,24 @@ struct ar9170_rx_macstatus { struct ar9170_rx_frame_single { struct ar9170_rx_head phy_head; - struct ieee80211_hdr i3e; + struct ieee80211_hdr i3e __packed __aligned(2); struct ar9170_rx_phystatus phy_tail; struct ar9170_rx_macstatus macstatus; -} __packed __aligned(4); +}; struct ar9170_rx_frame_head { struct ar9170_rx_head phy_head; - struct ieee80211_hdr i3e; + struct ieee80211_hdr i3e __packed __aligned(2); struct ar9170_rx_macstatus macstatus; -} __packed __aligned(4); +}; struct ar9170_rx_frame_middle { - struct ieee80211_hdr i3e; + struct ieee80211_hdr i3e __packed __aligned(2); struct ar9170_rx_macstatus macstatus; -} __packed __aligned(4); +}; struct ar9170_rx_frame_tail { - struct ieee80211_hdr i3e; + struct ieee80211_hdr i3e __packed __aligned(2); struct ar9170_rx_phystatus phy_tail; struct ar9170_rx_macstatus macstatus; } __packed __aligned(4); @@ -395,8 +395,8 @@ struct ar9170_rx_frame { struct ar9170_rx_frame_head head; struct ar9170_rx_frame_middle middle; struct ar9170_rx_frame_tail tail; - } __packed __aligned(4); -} __packed __aligned(4); + }; +}; static inline u8 ar9170_get_decrypt_type(struct ar9170_rx_macstatus *t) {