From 89ff407d68ca152a28811f94c0a8e9ebb11f44d7 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sun, 10 Dec 2023 15:12:24 -0800 Subject: [PATCH] treewide: use ethtool_puts instead of memcpy The former is a safer and more readable version. Signed-off-by: Rosen Penev --- .../files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c | 3 +-- .../700-net-ipqess-introduce-the-Qualcomm-IPQESS-driver.patch | 2 +- .../linux/ramips/files/drivers/net/ethernet/ralink/ethtool.c | 2 +- target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c | 3 +-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c index e5adc821d2..b022a3e9fb 100644 --- a/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c +++ b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c @@ -169,8 +169,7 @@ static void ag71xx_ethtool_get_strings(struct net_device *netdev, u32 sset, int i; for (i = 0; i < ARRAY_SIZE(ag71xx_statistics); i++) - memcpy(data + i * ETH_GSTRING_LEN, - ag71xx_statistics[i].name, ETH_GSTRING_LEN); + ethtool_puts(&data, ag71xx_statistics[i].name); } } diff --git a/target/linux/ipq40xx/patches-6.1/700-net-ipqess-introduce-the-Qualcomm-IPQESS-driver.patch b/target/linux/ipq40xx/patches-6.1/700-net-ipqess-introduce-the-Qualcomm-IPQESS-driver.patch index 254e85c284..ccc56d115e 100644 --- a/target/linux/ipq40xx/patches-6.1/700-net-ipqess-introduce-the-Qualcomm-IPQESS-driver.patch +++ b/target/linux/ipq40xx/patches-6.1/700-net-ipqess-introduce-the-Qualcomm-IPQESS-driver.patch @@ -1953,7 +1953,7 @@ Signed-off-by: Maxime Chevallier + switch (stringset) { + case ETH_SS_STATS: + for (i = 0; i < ARRAY_SIZE(ipqess_stats); i++) -+ ethtool_sprintf(&p, ipqess_stats[i].string); ++ ethtool_puts(&p, ipqess_stats[i].string); + break; + } +} diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/ethtool.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/ethtool.c index 5732c28536..a3abf30c71 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/ethtool.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/ethtool.c @@ -161,7 +161,7 @@ static void fe_get_strings(struct net_device *dev, u32 stringset, u8 *data) { switch (stringset) { case ETH_SS_STATS: - memcpy(data, *fe_gdma_str, sizeof(fe_gdma_str)); + ethtool_puts(&data, *fe_gdma_str); break; } } diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c index d246e60cb2..9f608950c0 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c @@ -944,8 +944,7 @@ static void rtl83xx_get_strings(struct dsa_switch *ds, return; for (int i = 0; i < ARRAY_SIZE(rtl83xx_mib); i++) - strncpy(data + i * ETH_GSTRING_LEN, rtl83xx_mib[i].name, - ETH_GSTRING_LEN); + ethtool_puts(&data, rtl83xx_mib[i].name); } static void rtl83xx_get_ethtool_stats(struct dsa_switch *ds, int port, -- 2.30.2