[Intel-gfx] [PATCH 08/11] atmel: avoid gcc -Wstringop-overflow warning
Arnd Bergmann
arnd at kernel.org
Mon Mar 22 16:02:46 UTC 2021
From: Arnd Bergmann <arnd at arndb.de>
gcc-11 notices that the fields as defined in the ass_req_format
structure do not match the actual use of that structure:
cc1: error: writing 4 bytes into a region of size between 18446744073709551613 and 2 [-Werror=stringop-overflow=]
drivers/net/wireless/atmel/atmel.c:2884:20: note: at offset [4, 6] into destination object ‘ap’ of size 6
2884 | u8 ap[ETH_ALEN]; /* nothing after here directly accessible */
| ^~
drivers/net/wireless/atmel/atmel.c:2885:20: note: at offset [4, 6] into destination object ‘ssid_el_id’ of size 1
2885 | u8 ssid_el_id;
| ^~~~~~~~~~
This is expected here because the actual structure layout is variable.
As the code does not actually access the individual fields, replace
them with a comment and fixed-length array so prevent gcc from
complaining about it.
Signed-off-by: Arnd Bergmann <arnd at arndb.de>
---
drivers/net/wireless/atmel/atmel.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/drivers/net/wireless/atmel/atmel.c b/drivers/net/wireless/atmel/atmel.c
index 707fe66727f8..ff9152d600e1 100644
--- a/drivers/net/wireless/atmel/atmel.c
+++ b/drivers/net/wireless/atmel/atmel.c
@@ -2881,13 +2881,18 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
struct ass_req_format {
__le16 capability;
__le16 listen_interval;
- u8 ap[ETH_ALEN]; /* nothing after here directly accessible */
- u8 ssid_el_id;
- u8 ssid_len;
- u8 ssid[MAX_SSID_LENGTH];
- u8 sup_rates_el_id;
- u8 sup_rates_len;
- u8 rates[4];
+ u8 ssid_el[ETH_ALEN + 2 + MAX_SSID_LENGTH + 2 + 4];
+ /*
+ * nothing after here directly accessible:
+ *
+ * u8 ap[ETH_ALEN];
+ * u8 ssid_el_id;
+ * u8 ssid_len;
+ * u8 ssid[MAX_SSID_LENGTH];
+ * u8 sup_rates_el_id;
+ * u8 sup_rates_len;
+ * u8 rates[4];
+ */
} body;
header.frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
@@ -2907,13 +2912,13 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
body.listen_interval = cpu_to_le16(priv->listen_interval * priv->beacon_period);
+ ssid_el_p = body.ssid_el;
/* current AP address - only in reassoc frame */
if (is_reassoc) {
- memcpy(body.ap, priv->CurrentBSSID, ETH_ALEN);
- ssid_el_p = &body.ssid_el_id;
+ memcpy(ssid_el_p, priv->CurrentBSSID, ETH_ALEN);
+ ssid_el_p += ETH_ALEN;
bodysize = 18 + priv->SSID_size;
} else {
- ssid_el_p = &body.ap[0];
bodysize = 12 + priv->SSID_size;
}
--
2.29.2
More information about the Intel-gfx
mailing list