diff mbox series

wifi: ath11k: fix -Wformat-truncation warning

Message ID 20231017155342.112032-1-dmantipov@yandex.ru
State New
Headers show
Series wifi: ath11k: fix -Wformat-truncation warning | expand

Commit Message

Dmitry Antipov Oct. 17, 2023, 3:53 p.m. UTC
Fix the following warning observed with GCC 13.2 and -Wformat-truncation:

drivers/net/wireless/ath/ath11k/debugfs.c: In function ‘ath11k_debugfs_register’:
drivers/net/wireless/ath/ath11k/debugfs.c:1597:51: warning: ‘%d’ directive output
may be truncated writing between 1 and 3 bytes into a region of size 2 [-Wformat-truncation=]
 1597 |         snprintf(pdev_name, sizeof(pdev_name), "%s%d", "mac", ar->pdev_idx);
      |                                                   ^~
drivers/net/wireless/ath/ath11k/debugfs.c:1597:48: note: directive argument in the range [0, 255]
 1597 |         snprintf(pdev_name, sizeof(pdev_name), "%s%d", "mac", ar->pdev_idx);
      |                                                ^~~~~~
drivers/net/wireless/ath/ath11k/debugfs.c:1597:9: note: ‘snprintf’ output between
5 and 7 bytes into a destination of size 5
 1597 |         snprintf(pdev_name, sizeof(pdev_name), "%s%d", "mac", ar->pdev_idx);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Simplify the 'snprintf()' statement as well.

Suggested-by: Kalle Valo <kvalo@kernel.org>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 drivers/net/wireless/ath/ath11k/debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath11k/debugfs.c b/drivers/net/wireless/ath/ath11k/debugfs.c
index 5bb6fd17fdf6..e9b05e7c189b 100644
--- a/drivers/net/wireless/ath/ath11k/debugfs.c
+++ b/drivers/net/wireless/ath/ath11k/debugfs.c
@@ -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[8];
 	char buf[100] = {0};
 
-	snprintf(pdev_name, sizeof(pdev_name), "%s%d", "mac", ar->pdev_idx);
+	snprintf(pdev_name, sizeof(pdev_name), "mac%u", ar->pdev_idx);
 
 	ar->debug.debugfs_pdev = debugfs_create_dir(pdev_name, ab->debugfs_soc);
 	if (IS_ERR(ar->debug.debugfs_pdev))