Skip to contentSkip to conversation

wireless-next: fix new W=1 warnings

RFH In review Kalle Valo 5 participants 11 messages Oct 9, 2023 – Oct 20, 2023

Subsystems (5)
lore
Share & tools
lore

Kalle Valo

author
#0 lore raw

Hi,

During the weekend we updated wireless-next tree from v6.5 to v6.6-rc4+. It looks like a new warning was enabled for v6.6 as I see with GCC 13.2 and W=1 several warnings (list below). In v6.5 wireless code was still W=1 warning free with GCC.

For wireless we get lots of questionable cleanup patches. But actually these kind of warnings are what we would prefer to be fixed instead of the random churn we always see. Hence I'm sending this Request For Help (RFH) in case the cleanup people would fix these. Is there a mailing list I should send this to?

The sooner these are fixed the better, it makes it difficult for us to see any new warnings from this noise.

Kalle

drivers/net/wireless/intel/ipw2x00/ipw2100.c:5905:63: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=] drivers/net/wireless/intel/ipw2x00/ipw2100.c:5905:9: note: 'snprintf' output between 4 and 140 bytes into a destination of size 32 drivers/net/wireless/intel/ipw2x00/ipw2200.c:10392:63: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=] drivers/net/wireless/intel/ipw2x00/ipw2200.c:10392:9: note: 'snprintf' output between 4 and 98 bytes into a destination of size 32 drivers/net/wireless/intel/iwlwifi/dvm/main.c:1467:19: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=] drivers/net/wireless/intel/iwlwifi/dvm/main.c:1465:9: note: 'snprintf' output between 1 and 64 bytes into a destination of size 32 drivers/net/wireless/intel/iwlwifi/mvm/ops.c:1307:19: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=] drivers/net/wireless/intel/iwlwifi/mvm/ops.c:1305:9: note: 'snprintf' output between 1 and 64 bytes into a destination of size 32 drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:262:52: warning: '%d' directive output may be truncated writing between 1 and 5 bytes into a region of size 4 [-Wformat-truncation=] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:262:46: note: directive argument in the range [0, 65535] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:262:46: note: directive argument in the range [0, 65535] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:262:9: note: 'snprintf' output between 9 and 17 bytes into a destination of size 9 drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:265:55: warning: '%d' directive output may be truncated writing between 1 and 5 bytes into a region of size 4 [-Wformat-truncation=] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:265:48: note: directive argument in the range [0, 65535] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:265:48: note: directive argument in the range [0, 65535] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:265:9: note: 'snprintf' output between 10 and 18 bytes into a destination of size 10 drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:342:50: warning: '/' directive output may be truncated writing 1 byte into a region of size between 0 and 4 [-Wformat-truncation=] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:342:42: note: directive argument in the range [0, 65535] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:342:9: note: 'snprintf' output between 10 and 18 bytes into a destination of size 10 drivers/net/wireless/intel/iwlwifi/iwl-drv.c:549:33: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size between 48 and 56 [-Wformat-truncation=] drivers/net/wireless/intel/iwlwifi/iwl-drv.c:547:9: note: 'snprintf' output 9 or more bytes (assuming 80) into a destination of size 64 drivers/net/wireless/intel/iwlwifi/iwl-drv.c:729:33: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size between 48 and 56 [-Wformat-truncation=] drivers/net/wireless/intel/iwlwifi/iwl-drv.c:727:9: note: 'snprintf' output 9 or more bytes (assuming 80) into a destination of size 64 drivers/net/wireless/intel/iwlwifi/iwl-drv.c:989:51: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size between 46 and 58 [-Wformat-truncation=] drivers/net/wireless/intel/iwlwifi/iwl-drv.c:987:33: note: 'snprintf' output between 7 and 82 bytes into a destination of size 64 drivers/net/wireless/intel/iwlwifi/iwl-drv.c:984:53: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size between 40 and 50 [-Wformat-truncation=] drivers/net/wireless/intel/iwlwifi/iwl-drv.c:982:33: note: 'snprintf' output between 15 and 88 bytes into a destination of size 64 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=] 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 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=] drivers/net/wireless/ath/ath9k/hif_usb.c:1222:17: note: 'snprintf' output between 27 and 34 bytes into a destination of size 32

#1 lore raw
Quoted 6 lines · Kalle Valo

Hi,

During the weekend we updated wireless-next tree from v6.5 to v6.6-rc4+. It looks like a new warning was enabled for v6.6 as I see with GCC 13.2 and W=1 several warnings (list below). In v6.5 wireless code was still W=1 warning free with GCC.

Can you pin-point the exact commit that introduces the warnings?

Quoted 6 lines

For wireless we get lots of questionable cleanup patches. But actually these kind of warnings are what we would prefer to be fixed instead of the random churn we always see. Hence I'm sending this Request For Help (RFH) in case the cleanup people would fix these. Is there a mailing list I should send this to?

[also Cc: maintainers and lists for files below]

Quoted 30 lines

The sooner these are fixed the better, it makes it difficult for us to see any new warnings from this noise.

Kalle

drivers/net/wireless/intel/ipw2x00/ipw2100.c:5905:63: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=] drivers/net/wireless/intel/ipw2x00/ipw2100.c:5905:9: note: 'snprintf' output between 4 and 140 bytes into a destination of size 32 drivers/net/wireless/intel/ipw2x00/ipw2200.c:10392:63: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=] drivers/net/wireless/intel/ipw2x00/ipw2200.c:10392:9: note: 'snprintf' output between 4 and 98 bytes into a destination of size 32 drivers/net/wireless/intel/iwlwifi/dvm/main.c:1467:19: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=] drivers/net/wireless/intel/iwlwifi/dvm/main.c:1465:9: note: 'snprintf' output between 1 and 64 bytes into a destination of size 32 drivers/net/wireless/intel/iwlwifi/mvm/ops.c:1307:19: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=] drivers/net/wireless/intel/iwlwifi/mvm/ops.c:1305:9: note: 'snprintf' output between 1 and 64 bytes into a destination of size 32 drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:262:52: warning: '%d' directive output may be truncated writing between 1 and 5 bytes into a region of size 4 [-Wformat-truncation=] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:262:46: note: directive argument in the range [0, 65535] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:262:46: note: directive argument in the range [0, 65535] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:262:9: note: 'snprintf' output between 9 and 17 bytes into a destination of size 9 drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:265:55: warning: '%d' directive output may be truncated writing between 1 and 5 bytes into a region of size 4 [-Wformat-truncation=] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:265:48: note: directive argument in the range [0, 65535] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:265:48: note: directive argument in the range [0, 65535] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:265:9: note: 'snprintf' output between 10 and 18 bytes into a destination of size 10 drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:342:50: warning: '/' directive output may be truncated writing 1 byte into a region of size between 0 and 4 [-Wformat-truncation=] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:342:42: note: directive argument in the range [0, 65535] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:342:9: note: 'snprintf' output between 10 and 18 bytes into a destination of size 10 drivers/net/wireless/intel/iwlwifi/iwl-drv.c:549:33: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size between 48 and 56 [-Wformat-truncation=] drivers/net/wireless/intel/iwlwifi/iwl-drv.c:547:9: note: 'snprintf' output 9 or more bytes (assuming 80) into a destination of size 64 drivers/net/wireless/intel/iwlwifi/iwl-drv.c:729:33: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size between 48 and 56 [-Wformat-truncation=] drivers/net/wireless/intel/iwlwifi/iwl-drv.c:727:9: note: 'snprintf' output 9 or more bytes (assuming 80) into a destination of size 64 drivers/net/wireless/intel/iwlwifi/iwl-drv.c:989:51: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size between 46 and 58 [-Wformat-truncation=]

Quoted 8 lines

drivers/net/wireless/intel/iwlwifi/iwl-drv.c:987:33: note: 'snprintf' output between 7 and 82 bytes into a destination of size 64 drivers/net/wireless/intel/iwlwifi/iwl-drv.c:984:53: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size between 40 and 50 [-Wformat-truncation=] drivers/net/wireless/intel/iwlwifi/iwl-drv.c:982:33: note: 'snprintf' output between 15 and 88 bytes into a destination of size 64 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=] 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 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=] drivers/net/wireless/ath/ath9k/hif_usb.c:1222:17: note: 'snprintf' output between 27 and 34 bytes into a destination of size 32

There is only one commit touching above files in current cycle, that is b2fd72aafb1311 ("wifi: ath9k: Remove unnecessary ternary operators").

That's what I know.

Signature · 1 line
An old man doll... just what I always wanted! - Clara
#2 lore raw
In reply to Kalle Valo
Quoted 6 lines · Kalle Valo

Hi,

During the weekend we updated wireless-next tree from v6.5 to v6.6-rc4+. It looks like a new warning was enabled for v6.6 as I see with GCC 13.2 and W=1 several warnings (list below). In v6.5 wireless code was still W=1 warning free with GCC.

Can't say I am a big fan of this new warning, but I will look at the brcmfmac related warnings.

Btw. is it possible to opt out per driver.

Regards,
Arend

Quoted 44 lines

For wireless we get lots of questionable cleanup patches. But actually these kind of warnings are what we would prefer to be fixed instead of the random churn we always see. Hence I'm sending this Request For Help (RFH) in case the cleanup people would fix these. Is there a mailing list I should send this to?

The sooner these are fixed the better, it makes it difficult for us to see any new warnings from this noise.

Kalle

drivers/net/wireless/intel/ipw2x00/ipw2100.c:5905:63: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=] drivers/net/wireless/intel/ipw2x00/ipw2100.c:5905:9: note: 'snprintf' output between 4 and 140 bytes into a destination of size 32 drivers/net/wireless/intel/ipw2x00/ipw2200.c:10392:63: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=] drivers/net/wireless/intel/ipw2x00/ipw2200.c:10392:9: note: 'snprintf' output between 4 and 98 bytes into a destination of size 32 drivers/net/wireless/intel/iwlwifi/dvm/main.c:1467:19: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=] drivers/net/wireless/intel/iwlwifi/dvm/main.c:1465:9: note: 'snprintf' output between 1 and 64 bytes into a destination of size 32 drivers/net/wireless/intel/iwlwifi/mvm/ops.c:1307:19: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=] drivers/net/wireless/intel/iwlwifi/mvm/ops.c:1305:9: note: 'snprintf' output between 1 and 64 bytes into a destination of size 32 drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:262:52: warning: '%d' directive output may be truncated writing between 1 and 5 bytes into a region of size 4 [-Wformat-truncation=] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:262:46: note: directive argument in the range [0, 65535] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:262:46: note: directive argument in the range [0, 65535] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:262:9: note: 'snprintf' output between 9 and 17 bytes into a destination of size 9 drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:265:55: warning: '%d' directive output may be truncated writing between 1 and 5 bytes into a region of size 4 [-Wformat-truncation=] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:265:48: note: directive argument in the range [0, 65535] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:265:48: note: directive argument in the range [0, 65535] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:265:9: note: 'snprintf' output between 10 and 18 bytes into a destination of size 10 drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:342:50: warning: '/' directive output may be truncated writing 1 byte into a region of size between 0 and 4 [-Wformat-truncation=] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:342:42: note: directive argument in the range [0, 65535] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:342:9: note: 'snprintf' output between 10 and 18 bytes into a destination of size 10 drivers/net/wireless/intel/iwlwifi/iwl-drv.c:549:33: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size between 48 and 56 [-Wformat-truncation=] drivers/net/wireless/intel/iwlwifi/iwl-drv.c:547:9: note: 'snprintf' output 9 or more bytes (assuming 80) into a destination of size 64 drivers/net/wireless/intel/iwlwifi/iwl-drv.c:729:33: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size between 48 and 56 [-Wformat-truncation=] drivers/net/wireless/intel/iwlwifi/iwl-drv.c:727:9: note: 'snprintf' output 9 or more bytes (assuming 80) into a destination of size 64 drivers/net/wireless/intel/iwlwifi/iwl-drv.c:989:51: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size between 46 and 58 [-Wformat-truncation=] drivers/net/wireless/intel/iwlwifi/iwl-drv.c:987:33: note: 'snprintf' output between 7 and 82 bytes into a destination of size 64 drivers/net/wireless/intel/iwlwifi/iwl-drv.c:984:53: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size between 40 and 50 [-Wformat-truncation=] drivers/net/wireless/intel/iwlwifi/iwl-drv.c:982:33: note: 'snprintf' output between 15 and 88 bytes into a destination of size 64 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=] 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 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=] drivers/net/wireless/ath/ath9k/hif_usb.c:1222:17: note: 'snprintf' output between 27 and 34 bytes into a destination of size 32

author
#3 lore raw
Quoted 11 lines · Arend van Spriel
Quoted 6 lines · Kalle Valo

Hi,

During the weekend we updated wireless-next tree from v6.5 to v6.6-rc4+. It looks like a new warning was enabled for v6.6 as I see with GCC 13.2 and W=1 several warnings (list below). In v6.5 wireless code was still W=1 warning free with GCC.

Can't say I am a big fan of this new warning, but I will look at the brcmfmac related warnings.

I already sent a patch, please take a look:

https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

Quoted 1 line

Btw. is it possible to opt out per driver.

Usually that's not preferred.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#4 lore raw

PATCH 1/1 wifi: ath9k: fix -Wformat-truncation warning

In reply to Kalle Valo

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.

---
 drivers/net/wireless/ath/ath9k/hif_usb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/hif_usb.h +1 -1
index 5985aa15ca93..752ae288de1d 100644
@@ -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;
Signature · 1 line
2.41.0
author
#5 lore raw

Re: [PATCH] wifi: ath9k: fix -Wformat-truncation warning

Quoted 15 lines · Dmitry Antipov

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);
Quoted 4 lines

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

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

https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

I just used a bigger buffer than you.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#7 lore raw

PATCH 1/1 wifi: ath11k: fix -Wformat-truncation warning

In reply to Kalle Valo

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.

---
 drivers/net/wireless/ath/ath11k/debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath11k/debugfs.c +2 -2
index 5bb6fd17fdf6..e9b05e7c189b 100644
@@ -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))
Signature · 1 line
2.41.0
Acked-by on v1 1/1
#8 lore raw

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

Quoted 12 lines · Dmitry Antipov

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

Quoted 7 lines
  1597 |         snprintf(pdev_name, sizeof(pdev_name), "%s%d", "mac", ar->pdev_idx);
       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Simplify the 'snprintf()' statement as well.

Signature · 3 lines
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k
#9 lore raw

PATCH 1/1 wifi: ipw2x00: fix -Wformat-truncation warnings

In reply to Kalle Valo

Fix the following warnings observed with GCC 13.2 and -Wformat-truncation:

drivers/net/wireless/intel/ipw2x00/ipw2100.c: In function ‘ipw_ethtool_get_drvinfo’:
drivers/net/wireless/intel/ipw2x00/ipw2100.c:5905:63: warning: ‘%s’ directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=]

 5905 |         snprintf(info->fw_version, sizeof(info->fw_version), "%s:%d:%s",
      |                                                               ^~
 5906 |                  fw_ver, priv->eeprom_version, ucode_ver);
      |                  ~~~~~~
drivers/net/wireless/intel/ipw2x00/ipw2100.c:5905:9: note: ‘snprintf’ output between
4 and 140 bytes into a destination of size 32
 5905 |         snprintf(info->fw_version, sizeof(info->fw_version), "%s:%d:%s",
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 5906 |                  fw_ver, priv->eeprom_version, ucode_ver);
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For ipw2100, 'ipw2100_get_fwversion()' says that the firmware version is no longer than 14 bytes, and 'ipw2100_get_ucodeversion()' uses "%08X" so 10 bytes should be enough.

drivers/net/wireless/intel/ipw2x00/ipw2200.c: In function ‘ipw_ethtool_get_drvinfo’:
drivers/net/wireless/intel/ipw2x00/ipw2200.c:10392:63: warning: ‘%s’ directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=]

10392 |         snprintf(info->fw_version, sizeof(info->fw_version), "%s (%s)",
      |                                                               ^~
10393 |                  vers, date);
      |                  ~~~~
drivers/net/wireless/intel/ipw2x00/ipw2200.c:10392:9: note: ‘snprintf’ output between
4 and 98 bytes into a destination of size 32
10392 |         snprintf(info->fw_version, sizeof(info->fw_version), "%s (%s)",
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10393 |                  vers, date);
      |                  ~~~~~~~~~~~

For ipw2200, I assume that the firmware version is no longer than 14 bytes as well, and, according to ipw2100.h, firmware date is in 'mmm dd yyyy' format so 12 bytes should be enough.

---
 drivers/net/wireless/intel/ipw2x00/ipw2100.c | 2 +-
 drivers/net/wireless/intel/ipw2x00/ipw2200.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/intel/ipw2x00/ipw2100.c +1 -1
index 0812db8936f1..11b698255fe8 100644
@@ -5894,7 +5894,7 @@ static void ipw_ethtool_get_drvinfo(struct net_device *dev,
 				    struct ethtool_drvinfo *info)
 {
 	struct ipw2100_priv *priv = libipw_priv(dev);
-	char fw_ver[64], ucode_ver[64];
+	char fw_ver[16], ucode_ver[10];
 
 	strscpy(info->driver, DRV_NAME, sizeof(info->driver));
 	strscpy(info->version, DRV_VERSION, sizeof(info->version));
drivers/net/wireless/intel/ipw2x00/ipw2200.c +2 -2
index 820100cac491..f9a539d2e93b 100644
@@ -10377,8 +10377,8 @@ static void ipw_ethtool_get_drvinfo(struct net_device *dev,
 				    struct ethtool_drvinfo *info)
 {
 	struct ipw_priv *p = libipw_priv(dev);
-	char vers[64];
-	char date[32];
+	char vers[16];
+	char date[12];
 	u32 len;
 
 	strscpy(info->driver, DRV_NAME, sizeof(info->driver));
Signature · 1 line
2.41.0
author
#10 lore raw

Re: [PATCH] wifi: ipw2x00: fix -Wformat-truncation warnings

Quoted 34 lines · Dmitry Antipov

Fix the following warnings observed with GCC 13.2 and -Wformat-truncation:

drivers/net/wireless/intel/ipw2x00/ipw2100.c: In function ‘ipw_ethtool_get_drvinfo’:
drivers/net/wireless/intel/ipw2x00/ipw2100.c:5905:63: warning: ‘%s’ directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=]

 5905 |         snprintf(info->fw_version, sizeof(info->fw_version), "%s:%d:%s",
      |                                                               ^~
 5906 |                  fw_ver, priv->eeprom_version, ucode_ver);
      |                  ~~~~~~
drivers/net/wireless/intel/ipw2x00/ipw2100.c:5905:9: note: ‘snprintf’ output between
4 and 140 bytes into a destination of size 32
 5905 |         snprintf(info->fw_version, sizeof(info->fw_version), "%s:%d:%s",
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 5906 |                  fw_ver, priv->eeprom_version, ucode_ver);
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For ipw2100, 'ipw2100_get_fwversion()' says that the firmware version is no longer than 14 bytes, and 'ipw2100_get_ucodeversion()' uses "%08X" so 10 bytes should be enough.

drivers/net/wireless/intel/ipw2x00/ipw2200.c: In function ‘ipw_ethtool_get_drvinfo’:
drivers/net/wireless/intel/ipw2x00/ipw2200.c:10392:63: warning: ‘%s’ directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=]

10392 |         snprintf(info->fw_version, sizeof(info->fw_version), "%s (%s)",
      |                                                               ^~
10393 |                  vers, date);
      |                  ~~~~
drivers/net/wireless/intel/ipw2x00/ipw2200.c:10392:9: note: ‘snprintf’ output between
4 and 98 bytes into a destination of size 32
10392 |         snprintf(info->fw_version, sizeof(info->fw_version), "%s (%s)",
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10393 |                  vers, date);
      |                  ~~~~~~~~~~~
Quoted 6 lines

For ipw2200, I assume that the firmware version is no longer than 14 bytes as well, and, according to ipw2100.h, firmware date is in 'mmm dd yyyy' format so 12 bytes should be enough.

I tried to fix this a bit differently:

https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches