* [PATCH 1/4] wifi: brcmfmac: fix gnu_printf warnings
2023-06-13 14:09 [PATCH 0/4] wifi: drivers: fix remaining W=1 warnings Kalle Valo
@ 2023-06-13 14:09 ` Kalle Valo
2023-06-16 9:26 ` Kalle Valo
2023-06-13 14:09 ` [PATCH 2/4] wifi: brcmsmac: " Kalle Valo
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Kalle Valo @ 2023-06-13 14:09 UTC (permalink / raw)
To: linux-wireless
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.
Signed-off-by: Kalle Valo <kvalo@kernel.org>
---
.../net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h
index 5a139d7ed47a..5d66e94c806d 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h
@@ -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
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/4] wifi: brcmsmac: fix gnu_printf warnings
2023-06-13 14:09 [PATCH 0/4] wifi: drivers: fix remaining W=1 warnings Kalle Valo
2023-06-13 14:09 ` [PATCH 1/4] wifi: brcmfmac: fix gnu_printf warnings Kalle Valo
@ 2023-06-13 14:09 ` Kalle Valo
2023-06-13 14:09 ` [PATCH 3/4] wifi: hostap: fix stringop-truncations GCC warning Kalle Valo
2023-06-13 14:09 ` [PATCH 4/4] wifi: ray_cs: fix stringop-truncation " Kalle Valo
3 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2023-06-13 14:09 UTC (permalink / raw)
To: linux-wireless
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.
Signed-off-by: Kalle Valo <kvalo@kernel.org>
---
.../brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h
index 488456420353..42b0a91656c4 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h
@@ -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
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 3/4] wifi: hostap: fix stringop-truncations GCC warning
2023-06-13 14:09 [PATCH 0/4] wifi: drivers: fix remaining W=1 warnings Kalle Valo
2023-06-13 14:09 ` [PATCH 1/4] wifi: brcmfmac: fix gnu_printf warnings Kalle Valo
2023-06-13 14:09 ` [PATCH 2/4] wifi: brcmsmac: " Kalle Valo
@ 2023-06-13 14:09 ` Kalle Valo
2023-06-13 14:09 ` [PATCH 4/4] wifi: ray_cs: fix stringop-truncation " Kalle Valo
3 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2023-06-13 14:09 UTC (permalink / raw)
To: linux-wireless
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 <kvalo@kernel.org>
---
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
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 4/4] wifi: ray_cs: fix stringop-truncation GCC warning
2023-06-13 14:09 [PATCH 0/4] wifi: drivers: fix remaining W=1 warnings Kalle Valo
` (2 preceding siblings ...)
2023-06-13 14:09 ` [PATCH 3/4] wifi: hostap: fix stringop-truncations GCC warning Kalle Valo
@ 2023-06-13 14:09 ` Kalle Valo
3 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2023-06-13 14:09 UTC (permalink / raw)
To: linux-wireless
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 <kvalo@kernel.org>
---
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
^ permalink raw reply related [flat|nested] 6+ messages in thread