Here are the final fixes and workarounds I see with W=1. After this patchset my
plan is to compile wireless driver patches with W=1 before applying them.
Please review.
Kalle Valo (4):
wifi: brcmfmac: fix gnu_printf warnings
wifi: brcmsmac: fix gnu_printf warnings
wifi: hostap: fix stringop-truncations GCC warning
wifi: ray_cs: fix stringop-truncation GCC warning
.../net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h | 7 +++++++
.../brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h | 8 ++++++++
drivers/net/wireless/intersil/hostap/hostap_ioctl.c | 2 +-
drivers/net/wireless/legacy/ray_cs.c | 2 +-
4 files changed, 17 insertions(+), 2 deletions(-)
base-commit: cabb8b48e542e1401f6881c4f7d3bb82f723ee40
--
2.30.2
With GCC 13.1 and W=1 hostap has a warning:
drivers/net/wireless/intersil/hostap/hostap_ioctl.c:3633:17: warning: 'strncpy' specified bound 16 equals destination size [-Wstringop-truncation]
fortify-string.h recommends not to use strncpy() so use strscpy() which fixes
the warning. Also now it's guarenteed that the string is NUL-terminated.
Compile tested only.
Signed-off-by: Kalle Valo <[email protected]>
---
drivers/net/wireless/intersil/hostap/hostap_ioctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
index 26287b129d18..b4adfc190ae8 100644
--- a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
@@ -3630,7 +3630,7 @@ static int prism2_ioctl_get_encryption(local_info_t *local,
param->u.crypt.key_len = 0;
param->u.crypt.idx = 0xff;
} else {
- strncpy(param->u.crypt.alg, (*crypt)->ops->name,
+ strscpy(param->u.crypt.alg, (*crypt)->ops->name,
HOSTAP_CRYPT_ALG_NAME_LEN);
param->u.crypt.key_len = 0;
--
2.30.2
GCC 12.2 with W=1 warns:
drivers/net/wireless/legacy/ray_cs.c:630:17: warning: 'strncpy' specified bound 32 equals destination size [-Wstringop-truncation]
The driver uses SSID as a string which is just wrong, it should be treated as a
byte array instead. But as the driver is ancient and most likely there are no
users so convert it to use strscpy(). This makes sure that the string is
NUL-terminated and also the warning is fixed.
Signed-off-by: Kalle Valo <[email protected]>
---
drivers/net/wireless/legacy/ray_cs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wireless/legacy/ray_cs.c b/drivers/net/wireless/legacy/ray_cs.c
index 4b53a9c70e7e..8ace797ce951 100644
--- a/drivers/net/wireless/legacy/ray_cs.c
+++ b/drivers/net/wireless/legacy/ray_cs.c
@@ -627,7 +627,7 @@ static void init_startup_params(ray_dev_t *local)
local->sparm.b4.a_acting_as_ap_status = TYPE_STA;
if (essid != NULL)
- strncpy(local->sparm.b4.a_current_ess_id, essid, ESSID_SIZE);
+ strscpy(local->sparm.b4.a_current_ess_id, essid, ESSID_SIZE);
} /* init_startup_params */
/*===========================================================================*/
--
2.30.2