OpenCloudOS-Kernel/drivers/net
Simon Horman 0f6dab0b79 net: atlantic: Avoid warning about potential string truncation
[ Upstream commit 5874e0c9f25661c2faefe4809907166defae3d7f ]

W=1 builds with GCC 14.2.0 warn that:

.../aq_ethtool.c:278:59: warning: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 6 [-Wformat-truncation=]
  278 |                                 snprintf(tc_string, 8, "TC%d ", tc);
      |                                                           ^~
.../aq_ethtool.c:278:56: note: directive argument in the range [-2147483641, 254]
  278 |                                 snprintf(tc_string, 8, "TC%d ", tc);
      |                                                        ^~~~~~~
.../aq_ethtool.c:278:33: note: ‘snprintf’ output between 5 and 15 bytes into a destination of size 8
  278 |                                 snprintf(tc_string, 8, "TC%d ", tc);
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tc is always in the range 0 - cfg->tcs. And as cfg->tcs is a u8,
the range is 0 - 255. Further, on inspecting the code, it seems
that cfg->tcs will never be more than AQ_CFG_TCS_MAX (8), so
the range is actually 0 - 8.

So, it seems that the condition that GCC flags will not occur.
But, nonetheless, it would be nice if it didn't emit the warning.

It seems that this can be achieved by changing the format specifier
from %d to %u, in which case I believe GCC recognises an upper bound
on the range of tc of 0 - 255. After some experimentation I think
this is due to the combination of the use of %u and the type of
cfg->tcs (u8).

Empirically, updating the type of the tc variable to unsigned int
has the same effect.

As both of these changes seem to make sense in relation to what the code
is actually doing - iterating over unsigned values - do both.

Compile tested only.

Signed-off-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20240821-atlantic-str-v1-1-fa2cfe38ca00@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-10-10 11:57:26 +02:00
..
appletalk
arcnet
bonding bonding: Fix unnecessary warnings and logs from bond_xdp_get_xmit_slave() 2024-10-04 16:29:42 +02:00
caif
can can: esd_usb: Remove CAN_CTRLMODE_3_SAMPLES for CAN-USB/3-FD 2024-10-04 16:29:49 +02:00
dsa net: dsa: felix: ignore pending status of TAS module when it's disabled 2024-09-18 19:24:09 +02:00
ethernet net: atlantic: Avoid warning about potential string truncation 2024-10-10 11:57:26 +02:00
fddi
fjes fjes: fix memleaks in fjes_hw_setup 2024-01-31 16:19:05 -08:00
hamradio
hippi
hyperv hv_netvsc: Don't free decrypted memory 2024-05-17 12:02:17 +02:00
ieee802154 net: ieee802154: mcr20a: Use IRQF_NO_AUTOEN flag in request_irq() 2024-10-10 11:57:15 +02:00
ipa net: ipa: don't overrun IPA suspend interrupt registers 2024-03-01 13:35:08 +01:00
ipvlan ipvlan: Dont Use skb->sk in ipvlan_process_v{4,6}_outbound 2024-06-12 11:12:59 +02:00
mctp net: mctp-serial: Fix missing escapes on transmit 2024-09-12 11:11:28 +02:00
mdio
netdevsim netdevsim: avoid potential loop in nsim_dev_trap_report_work() 2024-02-16 19:10:47 +01:00
pcs net: pcs: xpcs: Return EINVAL in the internal methods 2024-04-13 13:07:31 +02:00
phy net: phy: vitesse: repair vsc73xx autonegotiation 2024-09-18 19:24:05 +02:00
plip
ppp ppp: do not assume bh is held in ppp_channel_bridge_input() 2024-10-10 11:57:18 +02:00
pse-pd
slip
team
thunderbolt
usb usbnet: fix cyclical race on disconnect with work queue 2024-10-04 16:29:50 +02:00
vmxnet3 vmxnet3: disable rx data ring on dma allocation failure 2024-06-21 14:38:15 +02:00
vxlan vxlan: Fix regression when dropping packets due to invalid src addresses 2024-06-21 14:38:17 +02:00
wan
wireguard wireguard: send: annotate intentional data race in checking empty queue 2024-07-18 13:21:23 +02:00
wireless wifi: rtw89: correct base HT rate mask for firmware 2024-10-10 11:57:26 +02:00
wwan net: wwan: qcom_bam_dmux: Fix missing pm_runtime_disable() 2024-10-10 11:57:15 +02:00
xen-netback net/xen-netback: prevent UAF in xenvif_flush_hash() 2024-10-10 11:57:22 +02:00
Kconfig
LICENSE.SRC
Makefile net: Always descend into dsa/ folder with CONFIG_NET_DSA enabled 2024-06-12 11:12:46 +02:00
Space.c
amt.c amt: do not use overwrapped cb area 2024-01-25 15:35:56 -08:00
bareudp.c bareudp: Pull inner IP header on xmit. 2024-10-04 16:28:58 +02:00
dummy.c net: add netdev_lockdep_set_classes() to virtual drivers 2024-04-13 13:07:30 +02:00
eql.c
geneve.c geneve: Fix incorrect inner network header offset when innerprotoinherit is set 2024-06-21 14:38:33 +02:00
gtp.c gtp: fix a potential NULL pointer dereference 2024-09-04 13:28:27 +02:00
ifb.c
loopback.c net: add netdev_lockdep_set_classes() to virtual drivers 2024-04-13 13:07:30 +02:00
macsec.c macsec: Detect if Rx skb is macsec-related for offloading devices that update md_dst 2024-05-02 16:32:50 +02:00
macvlan.c
macvtap.c
mdio.c
mhi_net.c
mii.c
net_failover.c
netconsole.c net: netconsole: Disable target before netpoll cleanup 2024-08-03 08:54:13 +02:00
nlmon.c
ntb_netdev.c net: ntb_netdev: Move ntb_netdev_rx_handler() to call netif_rx() from __netif_rx() 2024-07-11 12:49:13 +02:00
rionet.c
sb1000.c
sungem_phy.c
tap.c tap: add missing verification for short frame 2024-07-27 11:34:11 +02:00
tun.c tun: add missing verification for short frame 2024-07-27 11:34:10 +02:00
veth.c net: add netdev_lockdep_set_classes() to virtual drivers 2024-04-13 13:07:30 +02:00
virtio_net.c virtio_net: Fix mismatched buf address when unmapping for small packets 2024-10-04 16:29:42 +02:00
vrf.c
vsockmon.c
xen-netfront.c xen-netfront: Add missing skb_mark_for_recycle 2024-04-10 16:35:49 +02:00