diff mbox series

wifi: ath9k: fix -Wformat-truncation warning

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

Commit Message

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

drivers/net/wireless/ath/ath9k/hif_usb.c: In function ‘ath9k_hif_request_firmware’:
drivers/net/wireless/ath/ath9k/hif_usb.c:1223:42: warning: ‘.0.fw’ directive output
may be truncated writing 5 bytes into a region of size between 4 and 11 [-Wformat-truncation=]
 1223 |                          "%s/htc_%s-%d.%s.0.fw", HTC_FW_PATH,
      |                                          ^~~~~
drivers/net/wireless/ath/ath9k/hif_usb.c:1222:17: note: ‘snprintf’ output between
27 and 34 bytes into a destination of size 32
 1222 |                 snprintf(hif_dev->fw_name, sizeof(hif_dev->fw_name),
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1223 |                          "%s/htc_%s-%d.%s.0.fw", HTC_FW_PATH,
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1224 |                          chip, MAJOR_VERSION_REQ, index);

According to the comment in 'ath9k_hif_request_firmware()', 36 bytes should be enough.

Suggested-by: Kalle Valo <kvalo@kernel.org>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 drivers/net/wireless/ath/ath9k/hif_usb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kalle Valo Oct. 20, 2023, 2:45 p.m. UTC | #1
Dmitry Antipov <dmantipov@yandex.ru> wrote:

> Fix the following warning observed with GCC 13.2 and -Wformat-truncation:
> 
> drivers/net/wireless/ath/ath9k/hif_usb.c: In function ‘ath9k_hif_request_firmware’:
> drivers/net/wireless/ath/ath9k/hif_usb.c:1223:42: warning: ‘.0.fw’ directive output
> may be truncated writing 5 bytes into a region of size between 4 and 11 [-Wformat-truncation=]
>  1223 |                          "%s/htc_%s-%d.%s.0.fw", HTC_FW_PATH,
>       |                                          ^~~~~
> drivers/net/wireless/ath/ath9k/hif_usb.c:1222:17: note: ‘snprintf’ output between
> 27 and 34 bytes into a destination of size 32
>  1222 |                 snprintf(hif_dev->fw_name, sizeof(hif_dev->fw_name),
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  1223 |                          "%s/htc_%s-%d.%s.0.fw", HTC_FW_PATH,
>       |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  1224 |                          chip, MAJOR_VERSION_REQ, index);
> 
> According to the comment in 'ath9k_hif_request_firmware()', 36 bytes should be enough.
> 
> Suggested-by: Kalle Valo <kvalo@kernel.org>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>

As I didn't get any replies to my RFH I unfortunately already fixed this myself:

https://patchwork.kernel.org/project/linux-wireless/patch/20231012135854.3473332-3-kvalo@kernel.org/

I just used a bigger buffer than you.
Dmitry Antipov Oct. 20, 2023, 3:26 p.m. UTC | #2
On 10/20/23 17:45, Kalle Valo wrote:

> As I didn't get any replies to my RFH I unfortunately already fixed this myself:
> 
> https://patchwork.kernel.org/project/linux-wireless/patch/20231012135854.3473332-3-kvalo@kernel.org/
> 
> I just used a bigger buffer than you.

To be honest, I've expected a fast reply from Toke. Anyway, you're the maintainer.

Dmitry
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.h b/drivers/net/wireless/ath/ath9k/hif_usb.h
index 5985aa15ca93..752ae288de1d 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.h
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.h
@@ -126,7 +126,7 @@  struct hif_device_usb {
 	struct usb_anchor reg_in_submitted;
 	struct usb_anchor mgmt_submitted;
 	struct sk_buff *remain_skb;
-	char fw_name[32];
+	char fw_name[36];
 	int fw_minor_index;
 	int rx_remain_len;
 	int rx_pkt_len;