2023-10-17 19:38:48

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH] wifi: ath11k: fix -Wformat-truncation warning

On 10/17/2023 8:53 AM, Dmitry Antipov wrote:
> 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 <[email protected]>
> Signed-off-by: Dmitry Antipov <[email protected]>
Acked-by: Jeff Johnson <[email protected]>