Skip to content

Commit

Permalink
treewide: use ethtool_puts instead of memcpy
Browse files Browse the repository at this point in the history
The former is a safer and more readable version.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
  • Loading branch information
neheb authored and pull[bot] committed Jan 22, 2024
1 parent f5c8587 commit af048a3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
+ }
+}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit af048a3

Please sign in to comment.