treewide: use ethtool_puts instead of memcpy
authorRosen Penev <rosenp@gmail.com>
Sun, 10 Dec 2023 23:12:24 +0000 (15:12 -0800)
committerChristian Marangi <ansuelsmth@gmail.com>
Fri, 5 Jan 2024 15:12:49 +0000 (16:12 +0100)
The former is a safer and more readable version.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c
target/linux/ipq40xx/patches-6.1/700-net-ipqess-introduce-the-Qualcomm-IPQESS-driver.patch
target/linux/ramips/files/drivers/net/ethernet/ralink/ethtool.c
target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c

index e5adc821d279a290cc9a39d74f45fd3450cf91b6..b022a3e9fb7a194f09e412de2a9b6a1df0571673 100644 (file)
@@ -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);
        }
 }
 
index 254e85c2844cc2e9031e5f3e9f9837f4792072aa..ccc56d115e07a2eafc74bd26739fe70c2ba880d6 100644 (file)
@@ -1953,7 +1953,7 @@ Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
 +      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;
 +      }
 +}
index 5732c28536c22a58b4e01ff15f924d65b419cc3d..a3abf30c71c74b91c9f6e3bd46ee74c91ab02e95 100644 (file)
@@ -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;
        }
 }
index d246e60cb2aca337704244f0a0939f08f9b9fd12..9f608950c06f0ec715b5e817e05b968dbcf1f5f6 100644 (file)
@@ -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,