Skip to contentSkip to conversation

wifi: drivers: fix remaining W=1 warnings

PATCH In review Kalle Valo 1 participant 6 messages Jun 13, 2023 – Jun 16, 2023

Subsystems (3)
lore
Share & tools
lore

Kalle Valo

author
#0 lore raw

cover wifi: drivers: fix remaining W=1 warnings

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

Signature · 1 line
2.30.2
author
#1 lore raw

PATCH 1/4 wifi: brcmfmac: fix gnu_printf warnings

With GCC 13.1 and W=1 brcmfmac has warnings like this:

./include/trace/perf.h:26:16: warning: function 'perf_trace_brcmf_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]

Add a workaround which disables -Wsuggest-attribute=format in tracepoint.h. I see similar workarounds in other drivers as well.

Compile tested only.

---
 .../net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h  | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h +7 -0
index 5a139d7ed47a..5d66e94c806d 100644
@@ -28,6 +28,11 @@ static inline void trace_ ## name(proto) {}
 
 #define MAX_MSG_LEN		100
 
+#pragma GCC diagnostic push
+#ifndef __clang__
+#pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
+#endif
+
 TRACE_EVENT(brcmf_err,
 	TP_PROTO(const char *func, struct va_format *vaf),
 	TP_ARGS(func, vaf),
@@ -123,6 +128,8 @@ TRACE_EVENT(brcmf_sdpcm_hdr,
 		  __entry->len, ((u8 *)__get_dynamic_array(hdr))[4])
 );
 
+#pragma GCC diagnostic pop
+
 #ifdef CONFIG_BRCM_TRACING
 
 #undef TRACE_INCLUDE_PATH
Signature · 1 line
2.30.2
author
#2 lore raw

Re: [PATCH 1/4] wifi: brcmfmac: fix gnu_printf warnings

Quoted 10 lines · Kalle Valo

With GCC 13.1 and W=1 brcmfmac has warnings like this:

./include/trace/perf.h:26:16: warning: function 'perf_trace_brcmf_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]

Add a workaround which disables -Wsuggest-attribute=format in tracepoint.h. I see similar workarounds in other drivers as well.

Compile tested only.

4 patches applied to wireless-next.git, thanks.

56714e5f1255 wifi: brcmfmac: fix gnu_printf warnings 4b6ec74ec476 wifi: brcmsmac: fix gnu_printf warnings 5ea0c3130900 wifi: hostap: fix stringop-truncations GCC warning 707a13c7e488 wifi: ray_cs: fix stringop-truncation GCC warning

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
author
#3 lore raw

PATCH 2/4 wifi: brcmsmac: fix gnu_printf warnings

In reply to Kalle Valo

With GCC 13.1 and W=1 brcmsmac has warnings like this:

./include/trace/stages/stage5_get_offsets.h:23:31: warning: function 'trace_event_get_offsets_brcms_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]

Add a workaround which disables -Wsuggest-attribute=format in brcms_trace_brcmsmac_msg.h. I see similar workarounds in other drivers as well.

Compile tested only.

---
 .../brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h         | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h +8 -0
index 488456420353..42b0a91656c4 100644
@@ -24,6 +24,11 @@
 
 #define MAX_MSG_LEN	100
 
+#pragma GCC diagnostic push
+#ifndef __clang__
+#pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
+#endif
+
 DECLARE_EVENT_CLASS(brcms_msg_event,
 	TP_PROTO(struct va_format *vaf),
 	TP_ARGS(vaf),
@@ -71,6 +76,9 @@ TRACE_EVENT(brcms_dbg,
 	),
 	TP_printk("%s: %s", __get_str(func), __get_str(msg))
 );
+
+#pragma GCC diagnostic pop
+
 #endif /* __TRACE_BRCMSMAC_MSG_H */
 
 #ifdef CONFIG_BRCM_TRACING
Signature · 1 line
2.30.2
author
#4 lore raw

PATCH 3/4 wifi: hostap: fix stringop-truncations GCC warning

In reply to Kalle Valo

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.

---
 drivers/net/wireless/intersil/hostap/hostap_ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intersil/hostap/hostap_ioctl.c +1 -1
index 26287b129d18..b4adfc190ae8 100644
@@ -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;
 
Signature · 1 line
2.30.2
author
#5 lore raw

PATCH 4/4 wifi: ray_cs: fix stringop-truncation GCC warning

In reply to Kalle Valo

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.

---
 drivers/net/wireless/legacy/ray_cs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/legacy/ray_cs.c +1 -1
index 4b53a9c70e7e..8ace797ce951 100644
@@ -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 */
 
 /*===========================================================================*/
Signature · 1 line
2.30.2