Skip to contentSkip to conversation

wifi: virt_wifi: Add __nonstring annotations for unterminated strings

PATCH Superseded Kees Cook 1 participant 1 message Mar 11, 2025 Networking drivers (wireless)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH v2 1/1 wifi: virt_wifi: Add __nonstring annotations for unterminated strings

When a character array without a terminating NUL character has a static initializer, GCC 15's -Wunterminated-string-initialization will only warn if the array lacks the "nonstring" attribute[1]. Mark the arrays with __nonstring to and correctly identify the char array as "not a C string" and thereby eliminate the warning.

---
v1: https://lore.kernel.org/lkml/[email protected]/
v2: correctly split and fix subject
Cc: Johannes Berg <[email protected]>
Cc: Eric Dumazet <[email protected]>
Cc: En-Wei Wu <[email protected]>
Cc: Kalle Valo <[email protected]>
Cc: [email protected]

---
 drivers/net/wireless/virtual/virt_wifi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/virtual/virt_wifi.c +1 -1
index 4ee374080466..fc122b79301a 100644
@@ -146,7 +146,7 @@ static void virt_wifi_inform_bss(struct wiphy *wiphy)
 	static const struct {
 		u8 tag;
 		u8 len;
-		u8 ssid[8];
+		u8 ssid[8] __nonstring;
 	} __packed ssid = {
 		.tag = WLAN_EID_SSID,
 		.len = VIRT_WIFI_SSID_LEN,
Signature · 1 line
2.34.1