summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Chang <seanwascoding@gmail.com>2026-03-02 17:29:31 +0300
committerJakub Kicinski <kuba@kernel.org>2026-03-04 04:18:00 +0300
commitacd338ba2f3a33d68aa05f406407fbdf6adccfee (patch)
treebc9ebe6897b9dc2f3a31c73f251de3615a8fa46b
parent39feb171f361f887dad8504dc5822b852871ac21 (diff)
downloadlinux-acd338ba2f3a33d68aa05f406407fbdf6adccfee.tar.xz
net: macb: use ethtool_sprintf to fill ethtool stats strings
The RISC-V toolchain triggers a stringop-truncation warning when using snprintf() with a fixed ETH_GSTRING_LEN (32 bytes) buffer. Convert the driver to use the modern ethtool_sprintf() API from linux/ethtool.h. This removes the need for manual snprintf() and memcpy() calls, handles the 32-byte padding automatically, and simplifies the logic by removing manual pointer arithmetic. Suggested-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Sean Chang <seanwascoding@gmail.com> Link: https://patch.msgid.link/20260302142931.49108-1-seanwascoding@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r--drivers/net/ethernet/cadence/macb_main.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 02eab26fd98b..17f0ad3d7a09 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3161,7 +3161,6 @@ static int gem_get_sset_count(struct net_device *dev, int sset)
static void gem_get_ethtool_strings(struct net_device *dev, u32 sset, u8 *p)
{
- char stat_string[ETH_GSTRING_LEN];
struct macb *bp = netdev_priv(dev);
struct macb_queue *queue;
unsigned int i;
@@ -3174,11 +3173,8 @@ static void gem_get_ethtool_strings(struct net_device *dev, u32 sset, u8 *p)
ETH_GSTRING_LEN);
for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
- for (i = 0; i < QUEUE_STATS_LEN; i++, p += ETH_GSTRING_LEN) {
- snprintf(stat_string, ETH_GSTRING_LEN, "q%d_%s",
- q, queue_statistics[i].stat_string);
- memcpy(p, stat_string, ETH_GSTRING_LEN);
- }
+ for (i = 0; i < QUEUE_STATS_LEN; i++)
+ ethtool_sprintf(&p, "q%u_%s", q, queue_statistics[i].stat_string);
}
break;
}