wifi: ath11k: ath11k_debugfs_register(): fix format-truncation warning
authorKalle Valo <quic_kvalo@quicinc.com>
Tue, 10 Oct 2023 06:22:50 +0000 (09:22 +0300)
committerKalle Valo <quic_kvalo@quicinc.com>
Thu, 12 Oct 2023 16:04:24 +0000 (19:04 +0300)
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.

Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231010062250.2580951-1-kvalo@kernel.org
drivers/net/wireless/ath/ath11k/debugfs.c

index 5bb6fd17fdf6f59ee1423bf47892e750ea6abff2..6f89e24cb6125d35442521dd62124e97b41f3d65 100644 (file)
@@ -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))