[PATCH] wifi: ath11k: fix -Wformat-truncation warning

Jeff Johnson quic_jjohnson at quicinc.com
Tue Oct 17 12:38:31 PDT 2023


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 <kvalo at kernel.org>
> Signed-off-by: Dmitry Antipov <dmantipov at yandex.ru>
Acked-by: Jeff Johnson <quic_jjohnson at quicinc.com>




More information about the ath11k mailing list