Skip to contentSkip to conversation

wifi: ath11k: ath11k_debugfs_register(): fix format-truncation warning

PATCH In review Kalle Valo 2 participants 3 messages Oct 10, 2023 – Oct 12, 2023 Qualcomm Atheros ATH11K wireless driver

lore
Share & tools
lore

Kalle Valo

author
#0 lore raw

PATCH 1/1 wifi: ath11k: ath11k_debugfs_register(): fix format-truncation warning

From: Kalle Valo <[email protected]>

In v6.6-rc4 with GCC 13.2 I see a new warning:

drivers/net/wireless/ath/ath11k/debugfs.c: In function 'ath11k_debugfs_register':
drivers/net/wireless/ath/ath11k/debugfs.c:1597:51: error: '%d' directive output may be truncated writing between 1 and 3 bytes into a region of size 2 [-Werror=format-truncation=] drivers/net/wireless/ath/ath11k/debugfs.c:1597:48: note: directive argument in the range [0, 255]
drivers/net/wireless/ath/ath11k/debugfs.c:1597:9: note: 'snprintf' output between 5 and 7 bytes into a destination of size 5

Increase the size of pdev_name to 10 bytes to make sure there's enough room for the string. Also change the format to '%u' as ar->pdev_idx is u8.

Compile tested only.

---
 drivers/net/wireless/ath/ath11k/debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath11k/debugfs.c +2 -2
index 5bb6fd17fdf6..6f89e24cb612 100644
@@ -1591,10 +1591,10 @@ static const struct file_operations fops_ps_state_enable = {
 int ath11k_debugfs_register(struct ath11k *ar)
 {
 	struct ath11k_base *ab = ar->ab;
-	char pdev_name[5];
+	char pdev_name[10];
 	char buf[100] = {0};
 
-	snprintf(pdev_name, sizeof(pdev_name), "%s%d", "mac", ar->pdev_idx);
+	snprintf(pdev_name, sizeof(pdev_name), "%s%u", "mac", ar->pdev_idx);
 
 	ar->debug.debugfs_pdev = debugfs_create_dir(pdev_name, ab->debugfs_soc);
 	if (IS_ERR(ar->debug.debugfs_pdev))

base-commit: 54ca82af78699713bae8b086f46ae13179772085

Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Kalle Valo

From: Kalle Valo <[email protected]>

In v6.6-rc4 with GCC 13.2 I see a new warning:

drivers/net/wireless/ath/ath11k/debugfs.c: In function 'ath11k_debugfs_register':
drivers/net/wireless/ath/ath11k/debugfs.c:1597:51: error: '%d' directive output may be truncated writing between 1 and 3 bytes into a region of size 2 [-Werror=format-truncation=] drivers/net/wireless/ath/ath11k/debugfs.c:1597:48: note: directive argument in the range [0, 255]
drivers/net/wireless/ath/ath11k/debugfs.c:1597:9: note: 'snprintf' output between 5 and 7 bytes into a destination of size 5

Quoted 6 lines

Increase the size of pdev_name to 10 bytes to make sure there's enough room for the string. Also change the format to '%u' as ar->pdev_idx is u8.

Compile tested only.

Signature · 3 lines
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k
author
#2 lore raw
In reply to Kalle Valo
Quoted 7 lines · Kalle Valo

In v6.6-rc4 with GCC 13.2 I see a new warning:

drivers/net/wireless/ath/ath11k/debugfs.c: In function 'ath11k_debugfs_register':
drivers/net/wireless/ath/ath11k/debugfs.c:1597:51: error: '%d' directive output may be truncated writing between 1 and 3 bytes into a region of size 2 [-Werror=format-truncation=] drivers/net/wireless/ath/ath11k/debugfs.c:1597:48: note: directive argument in the range [0, 255]
drivers/net/wireless/ath/ath11k/debugfs.c:1597:9: note: 'snprintf' output between 5 and 7 bytes into a destination of size 5

Quoted 6 lines

Increase the size of pdev_name to 10 bytes to make sure there's enough room for the string. Also change the format to '%u' as ar->pdev_idx is u8.

Compile tested only.

Patch applied to ath-next branch of ath.git, thanks.

a47111663491 wifi: ath11k: ath11k_debugfs_register(): fix format-truncation warning

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

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches