Skip to contentSkip to conversation

wifi: carl9170: Add __nonstring annotations for unterminated strings

PATCH Applied Kees Cook 3 participants 3 messages Mar 10, 2025 – Mar 17, 2025 CARL9170 Linux community wireless driver

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 wifi: carl9170: 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.

---
 drivers/net/wireless/ath/carl9170/fw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/carl9170/fw.c +1 -1
index 4c1aecd1163c..419f5530f885 100644
@@ -15,7 +15,7 @@
 #include "fwcmd.h"
 #include "version.h"
 
-static const u8 otus_magic[4] = { OTUS_MAGIC };
+static const u8 otus_magic[4] __nonstring = { OTUS_MAGIC };
 
 static const void *carl9170_fw_find_desc(struct ar9170 *ar, const u8 descid[4],
 	const unsigned int len, const u8 compatible_revision)
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Kees Cook

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.

Sure. Thank you!

Quoted 5 lines
Quoted 17 lines
---
  drivers/net/wireless/ath/carl9170/fw.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/carl9170/fw.c +1 -1
index 4c1aecd1163c..419f5530f885 100644
@@ -15,7 +15,7 @@
  #include "fwcmd.h"
  #include "version.h"
 
-static const u8 otus_magic[4] = { OTUS_MAGIC };
+static const u8 otus_magic[4] __nonstring = { OTUS_MAGIC };
 
  static const void *carl9170_fw_find_desc(struct ar9170 *ar, const u8 descid[4],
  	const unsigned int len, const u8 compatible_revision)
Applied
#2 lore raw
In reply to Kees Cook
Quoted 8 lines · Kees Cook

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.

[...]

Applied, thanks!

[1/1] wifi: carl9170: Add __nonstring annotations for unterminated strings

      commit: 9a1cf85c9c7cca15bfc452f207818977621dedf8

Best regards,

Signature · 1 line
Jeff Johnson <[email protected]>