Message ID | 20241015200222.12452-3-rosenp@gmail.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: memcpy to ethtool_puts | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
On Tue, Oct 15, 2024 at 1:02 PM Rosen Penev <rosenp@gmail.com> wrote: > > The latter is the prefered way to copy ethtool strings. > > Transformed with the following coccinelle script: > > virtual org > virtual report > virtual context > virtual patch > > @depends on patch@ > expression E1, E2; > identifier I; > position p; > @@ > > - memcpy@p(E1 + I * ETH_GSTRING_LEN, E2, ETH_GSTRING_LEN); > + ethtool_puts(&E1, E2); > > Signed-off-by: Rosen Penev <rosenp@gmail.com> ugh accidentally sent this. It needs more work. > --- > drivers/net/dsa/b53/b53_common.c | 3 +- > drivers/net/dsa/bcm_sf2.c | 5 +- > drivers/net/dsa/bcm_sf2_cfp.c | 17 ++-- > drivers/net/dsa/hirschmann/hellcreek.c | 8 +- > drivers/net/dsa/microchip/ksz_common.c | 3 +- > drivers/net/dsa/mv88e6xxx/chip.c | 5 +- > drivers/net/dsa/rzn1_a5psw.c | 3 +- > drivers/net/dsa/sja1105/sja1105_ethtool.c | 7 +- > drivers/net/dsa/xrs700x/xrs700x.c | 6 +- > drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c | 22 +++--- > drivers/net/ethernet/apm/xgene-v2/ethtool.c | 13 +--- > .../ethernet/apm/xgene/xgene_enet_ethtool.c | 13 +--- > drivers/net/ethernet/atheros/atlx/atl1.c | 8 +- > .../ethernet/broadcom/asp2/bcmasp_ethtool.c | 5 +- > drivers/net/ethernet/broadcom/bcm63xx_enet.c | 10 +-- > drivers/net/ethernet/broadcom/bcmsysport.c | 16 ++-- > drivers/net/ethernet/broadcom/bgmac.c | 3 +- > .../net/ethernet/broadcom/genet/bcmgenet.c | 5 +- > drivers/net/ethernet/cadence/macb_main.c | 19 ++--- > drivers/net/ethernet/calxeda/xgmac.c | 9 +-- > .../ethernet/cavium/liquidio/lio_ethtool.c | 50 +++++------- > .../ethernet/cavium/thunder/nicvf_ethtool.c | 48 ++++-------- > .../net/ethernet/cisco/enic/enic_ethtool.c | 40 ++++------ > .../net/ethernet/emulex/benet/be_ethtool.c | 39 ++++------ > drivers/net/ethernet/engleder/tsnep_ethtool.c | 32 ++++---- > .../ethernet/freescale/dpaa/dpaa_ethtool.c | 38 +++------ > .../ethernet/freescale/dpaa2/dpaa2-ethtool.c | 15 ++-- > .../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 7 +- > .../freescale/dpaa2/dpaa2-switch-ethtool.c | 12 ++- > .../ethernet/freescale/enetc/enetc_ethtool.c | 33 +++----- > .../net/ethernet/freescale/gianfar_ethtool.c | 8 +- > .../net/ethernet/freescale/ucc_geth_ethtool.c | 23 +++--- > .../ethernet/hisilicon/hns/hns_dsaf_main.c | 66 ++++++---------- > .../hns3/hns3_common/hclge_comm_tqp_stats.c | 6 +- > .../ethernet/hisilicon/hns3/hns3_ethtool.c | 9 +-- > .../hisilicon/hns3/hns3pf/hclge_main.c | 49 +++++------- > drivers/net/ethernet/ibm/ibmveth.c | 4 +- > drivers/net/ethernet/ibm/ibmvnic.c | 30 +++---- > .../net/ethernet/intel/e1000/e1000_ethtool.c | 13 ++-- > drivers/net/ethernet/intel/e1000e/ethtool.c | 13 ++-- > drivers/net/ethernet/intel/igbvf/ethtool.c | 9 +-- > drivers/net/ethernet/intel/ixgbevf/ethtool.c | 35 ++++----- > .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 38 +++------ > .../marvell/octeon_ep/octep_ethtool.c | 34 +++----- > .../marvell/octeon_ep_vf/octep_vf_ethtool.c | 37 ++++----- > .../marvell/octeontx2/nic/otx2_ethtool.c | 78 +++++++------------ > drivers/net/ethernet/marvell/skge.c | 3 +- > drivers/net/ethernet/marvell/sky2.c | 3 +- > .../mellanox/mlxsw/spectrum_ethtool.c | 77 +++++++----------- > .../ethernet/mellanox/mlxsw/spectrum_ptp.c | 7 +- > drivers/net/ethernet/micrel/ksz884x.c | 5 +- > .../microchip/lan966x/lan966x_ethtool.c | 3 +- > .../ethernet/microsoft/mana/mana_ethtool.c | 55 +++++-------- > drivers/net/ethernet/mscc/ocelot_stats.c | 3 +- > .../ethernet/netronome/nfp/nfp_net_ethtool.c | 3 +- > .../oki-semi/pch_gbe/pch_gbe_ethtool.c | 8 +- > .../qlogic/netxen/netxen_nic_ethtool.c | 10 +-- > .../net/ethernet/qlogic/qede/qede_ethtool.c | 34 ++++---- > .../ethernet/qlogic/qlcnic/qlcnic_ethtool.c | 49 +++++------- > .../net/ethernet/qualcomm/emac/emac-ethtool.c | 7 +- > drivers/net/ethernet/rocker/rocker_main.c | 7 +- > .../ethernet/samsung/sxgbe/sxgbe_ethtool.c | 9 +-- > drivers/net/ethernet/sfc/ethtool_common.c | 21 +++-- > drivers/net/ethernet/sfc/falcon/ethtool.c | 14 ++-- > drivers/net/ethernet/sfc/falcon/nic.c | 7 +- > drivers/net/ethernet/sfc/nic.c | 7 +- > .../net/ethernet/sfc/siena/ethtool_common.c | 25 +++--- > drivers/net/ethernet/sfc/siena/nic.c | 7 +- > .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 60 ++++++-------- > .../stmicro/stmmac/stmmac_selftests.c | 7 +- > drivers/net/ethernet/sun/cassini.c | 6 +- > .../ethernet/synopsys/dwc-xlgmac-ethtool.c | 8 +- > drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 20 ++--- > drivers/net/ethernet/ti/cpsw_ethtool.c | 15 ++-- > drivers/net/ethernet/ti/netcp_ethss.c | 7 +- > drivers/net/fjes/fjes_ethtool.c | 52 +++++-------- > drivers/net/phy/aquantia/aquantia_main.c | 3 +- > drivers/net/phy/bcm-phy-lib.c | 3 +- > drivers/net/usb/cdc_ncm.c | 8 +- > drivers/net/xen-netback/interface.c | 3 +- > drivers/net/xen-netfront.c | 3 +- > net/dsa/user.c | 11 ++- > 82 files changed, 550 insertions(+), 966 deletions(-) > > diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c > index c39cb119e760..285785c942b0 100644 > --- a/drivers/net/dsa/b53/b53_common.c > +++ b/drivers/net/dsa/b53/b53_common.c > @@ -989,8 +989,7 @@ void b53_get_strings(struct dsa_switch *ds, int port, u32 stringset, > > if (stringset == ETH_SS_STATS) { > for (i = 0; i < mib_size; i++) > - strscpy(data + i * ETH_GSTRING_LEN, > - mibs[i].name, ETH_GSTRING_LEN); > + ethtool_puts(&data, mibs[i].name); > } else if (stringset == ETH_SS_PHY_STATS) { > phydev = b53_get_phy_device(ds, port); > if (!phydev) > diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c > index 9201f07839ad..2bb1832d21bc 100644 > --- a/drivers/net/dsa/bcm_sf2.c > +++ b/drivers/net/dsa/bcm_sf2.c > @@ -1180,11 +1180,8 @@ static const struct b53_io_ops bcm_sf2_io_ops = { > static void bcm_sf2_sw_get_strings(struct dsa_switch *ds, int port, > u32 stringset, uint8_t *data) > { > - int cnt = b53_get_sset_count(ds, port, stringset); > - > b53_get_strings(ds, port, stringset, data); > - bcm_sf2_cfp_get_strings(ds, port, stringset, > - data + cnt * ETH_GSTRING_LEN); > + bcm_sf2_cfp_get_strings(ds, port, stringset, data); > } > > static void bcm_sf2_sw_get_ethtool_stats(struct dsa_switch *ds, int port, > diff --git a/drivers/net/dsa/bcm_sf2_cfp.c b/drivers/net/dsa/bcm_sf2_cfp.c > index c88ee3dd4299..8ba23e643a42 100644 > --- a/drivers/net/dsa/bcm_sf2_cfp.c > +++ b/drivers/net/dsa/bcm_sf2_cfp.c > @@ -1284,22 +1284,15 @@ void bcm_sf2_cfp_get_strings(struct dsa_switch *ds, int port, > { > struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds); > unsigned int s = ARRAY_SIZE(bcm_sf2_cfp_stats); > - char buf[ETH_GSTRING_LEN]; > - unsigned int i, j, iter; > + unsigned int i, j; > > if (stringset != ETH_SS_STATS) > return; > > - for (i = 1; i < priv->num_cfp_rules; i++) { > - for (j = 0; j < s; j++) { > - snprintf(buf, sizeof(buf), > - "CFP%03d_%sCntr", > - i, bcm_sf2_cfp_stats[j].name); > - iter = (i - 1) * s + j; > - strscpy(data + iter * ETH_GSTRING_LEN, > - buf, ETH_GSTRING_LEN); > - } > - } > + for (i = 1; i < priv->num_cfp_rules; i++) > + for (j = 0; j < s; j++) > + ethtool_sprintf(&data, "CFP%03d_%sCntr", i, > + bcm_sf2_cfp_stats[j].name); > } > > void bcm_sf2_cfp_get_ethtool_stats(struct dsa_switch *ds, int port, > diff --git a/drivers/net/dsa/hirschmann/hellcreek.c b/drivers/net/dsa/hirschmann/hellcreek.c > index d798f17cf7ea..283ec5a6e23c 100644 > --- a/drivers/net/dsa/hirschmann/hellcreek.c > +++ b/drivers/net/dsa/hirschmann/hellcreek.c > @@ -294,12 +294,8 @@ static void hellcreek_get_strings(struct dsa_switch *ds, int port, > { > int i; > > - for (i = 0; i < ARRAY_SIZE(hellcreek_counter); ++i) { > - const struct hellcreek_counter *counter = &hellcreek_counter[i]; > - > - strscpy(data + i * ETH_GSTRING_LEN, > - counter->name, ETH_GSTRING_LEN); > - } > + for (i = 0; i < ARRAY_SIZE(hellcreek_counter); ++i) > + ethtool_puts(&data, hellcreek_counter[i].name); > } > > static int hellcreek_get_sset_count(struct dsa_switch *ds, int port, int sset) > diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c > index 4e8710c7cb7b..408ccb1f012e 100644 > --- a/drivers/net/dsa/microchip/ksz_common.c > +++ b/drivers/net/dsa/microchip/ksz_common.c > @@ -2113,8 +2113,7 @@ static void ksz_get_strings(struct dsa_switch *ds, int port, > return; > > for (i = 0; i < dev->info->mib_cnt; i++) { > - memcpy(buf + i * ETH_GSTRING_LEN, > - dev->info->mib_names[i].string, ETH_GSTRING_LEN); > + ethtool_puts(&buf, dev->info->mib_names[i].string); > } > } > > diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c > index 69cf19d3dd5e..bc813d97afa7 100644 > --- a/drivers/net/dsa/mv88e6xxx/chip.c > +++ b/drivers/net/dsa/mv88e6xxx/chip.c > @@ -1220,12 +1220,9 @@ static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port, > if (chip->info->ops->stats_get_strings) > count = chip->info->ops->stats_get_strings(chip, data); > > - if (chip->info->ops->serdes_get_strings) { > - data += count * ETH_GSTRING_LEN; > + if (chip->info->ops->serdes_get_strings) > count = chip->info->ops->serdes_get_strings(chip, port, data); > - } > > - data += count * ETH_GSTRING_LEN; > mv88e6xxx_atu_vtu_get_strings(data); > > mv88e6xxx_reg_unlock(chip); > diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c > index 1135a32e4b7e..b3e127f64b08 100644 > --- a/drivers/net/dsa/rzn1_a5psw.c > +++ b/drivers/net/dsa/rzn1_a5psw.c > @@ -803,8 +803,7 @@ static void a5psw_get_strings(struct dsa_switch *ds, int port, u32 stringset, > return; > > for (u = 0; u < ARRAY_SIZE(a5psw_stats); u++) { > - memcpy(data + u * ETH_GSTRING_LEN, a5psw_stats[u].name, > - ETH_GSTRING_LEN); > + ethtool_puts(&data, a5psw_stats[u].name); > } > } > > diff --git a/drivers/net/dsa/sja1105/sja1105_ethtool.c b/drivers/net/dsa/sja1105/sja1105_ethtool.c > index decc6c931dc1..2ea64b1d026d 100644 > --- a/drivers/net/dsa/sja1105/sja1105_ethtool.c > +++ b/drivers/net/dsa/sja1105/sja1105_ethtool.c > @@ -586,7 +586,6 @@ void sja1105_get_strings(struct dsa_switch *ds, int port, > { > struct sja1105_private *priv = ds->priv; > enum sja1105_counter_index max_ctr, i; > - char *p = data; > > if (stringset != ETH_SS_STATS) > return; > @@ -597,10 +596,8 @@ void sja1105_get_strings(struct dsa_switch *ds, int port, > else > max_ctr = __MAX_SJA1105PQRS_PORT_COUNTER; > > - for (i = 0; i < max_ctr; i++) { > - strscpy(p, sja1105_port_counters[i].name, ETH_GSTRING_LEN); > - p += ETH_GSTRING_LEN; > - } > + for (i = 0; i < max_ctr; i++) > + ethtool_puts(&data, sja1105_port_counters[i].name); > } > > int sja1105_get_sset_count(struct dsa_switch *ds, int port, int sset) > diff --git a/drivers/net/dsa/xrs700x/xrs700x.c b/drivers/net/dsa/xrs700x/xrs700x.c > index de3b768f2ff9..4dbcc49a9e52 100644 > --- a/drivers/net/dsa/xrs700x/xrs700x.c > +++ b/drivers/net/dsa/xrs700x/xrs700x.c > @@ -91,10 +91,8 @@ static void xrs700x_get_strings(struct dsa_switch *ds, int port, > if (stringset != ETH_SS_STATS) > return; > > - for (i = 0; i < ARRAY_SIZE(xrs700x_mibs); i++) { > - strscpy(data, xrs700x_mibs[i].name, ETH_GSTRING_LEN); > - data += ETH_GSTRING_LEN; > - } > + for (i = 0; i < ARRAY_SIZE(xrs700x_mibs); i++) > + ethtool_puts(&data, xrs700x_mibs[i].name); > } > > static int xrs700x_get_sset_count(struct dsa_switch *ds, int port, int sset)
Hi Rosen,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net/main]
[also build test WARNING on net-next/main linus/master horms-ipvs/master v6.12-rc3 next-20241016]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Rosen-Penev/net-memcpy-to-ethtool_puts/20241016-040502
base: net/main
patch link: https://lore.kernel.org/r/20241015200222.12452-3-rosenp%40gmail.com
patch subject: [PATCH] net: memcpy to ethtool_puts
config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20241016/202410162106.9WmH0oPN-lkp@intel.com/config)
compiler: arceb-elf-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241016/202410162106.9WmH0oPN-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410162106.9WmH0oPN-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/net/dsa/mv88e6xxx/chip.c: In function 'mv88e6xxx_get_strings':
>> drivers/net/dsa/mv88e6xxx/chip.c:1215:13: warning: variable 'count' set but not used [-Wunused-but-set-variable]
1215 | int count = 0;
| ^~~~~
during RTL pass: mach
drivers/net/dsa/mv88e6xxx/chip.c: In function 'mv88e6xxx_read':
drivers/net/dsa/mv88e6xxx/chip.c:68:1: internal compiler error: in arc_ifcvt, at config/arc/arc.cc:9703
68 | }
| ^
0x5b78c1 arc_ifcvt
/tmp/build-crosstools-gcc-13.2.0-binutils-2.41/gcc/gcc-13.2.0/gcc/config/arc/arc.cc:9703
0xe431b4 arc_reorg
/tmp/build-crosstools-gcc-13.2.0-binutils-2.41/gcc/gcc-13.2.0/gcc/config/arc/arc.cc:8552
0xaed299 execute
/tmp/build-crosstools-gcc-13.2.0-binutils-2.41/gcc/gcc-13.2.0/gcc/reorg.cc:3927
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [y]:
- RESOURCE_KUNIT_TEST [=y] && RUNTIME_TESTING_MENU [=y] && KUNIT [=y]
vim +/count +1215 drivers/net/dsa/mv88e6xxx/chip.c
65f60e4582bd32 drivers/net/dsa/mv88e6xxx/chip.c Andrew Lunn 2018-03-28 1210
dfafe449bbc91d drivers/net/dsa/mv88e6xxx/chip.c Andrew Lunn 2016-11-21 1211 static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
89f09048348936 drivers/net/dsa/mv88e6xxx/chip.c Florian Fainelli 2018-04-25 1212 u32 stringset, uint8_t *data)
f5e2ed022dff60 drivers/net/dsa/mv88e6xxx.c Andrew Lunn 2015-12-23 1213 {
04bed1434df256 drivers/net/dsa/mv88e6xxx/chip.c Vivien Didelot 2016-08-31 1214 struct mv88e6xxx_chip *chip = ds->priv;
436fe17d273bed drivers/net/dsa/mv88e6xxx/chip.c Andrew Lunn 2018-03-01 @1215 int count = 0;
dfafe449bbc91d drivers/net/dsa/mv88e6xxx/chip.c Andrew Lunn 2016-11-21 1216
89f09048348936 drivers/net/dsa/mv88e6xxx/chip.c Florian Fainelli 2018-04-25 1217 if (stringset != ETH_SS_STATS)
89f09048348936 drivers/net/dsa/mv88e6xxx/chip.c Florian Fainelli 2018-04-25 1218 return;
89f09048348936 drivers/net/dsa/mv88e6xxx/chip.c Florian Fainelli 2018-04-25 1219
c9acece064e3f0 drivers/net/dsa/mv88e6xxx/chip.c Rasmus Villemoes 2019-06-20 1220 mv88e6xxx_reg_lock(chip);
c6c8cd5e3ce494 drivers/net/dsa/mv88e6xxx/chip.c Andrew Lunn 2018-03-01 1221
dfafe449bbc91d drivers/net/dsa/mv88e6xxx/chip.c Andrew Lunn 2016-11-21 1222 if (chip->info->ops->stats_get_strings)
436fe17d273bed drivers/net/dsa/mv88e6xxx/chip.c Andrew Lunn 2018-03-01 1223 count = chip->info->ops->stats_get_strings(chip, data);
436fe17d273bed drivers/net/dsa/mv88e6xxx/chip.c Andrew Lunn 2018-03-01 1224
577149384b2aab drivers/net/dsa/mv88e6xxx/chip.c Rosen Penev 2024-10-15 1225 if (chip->info->ops->serdes_get_strings)
65f60e4582bd32 drivers/net/dsa/mv88e6xxx/chip.c Andrew Lunn 2018-03-28 1226 count = chip->info->ops->serdes_get_strings(chip, port, data);
c6c8cd5e3ce494 drivers/net/dsa/mv88e6xxx/chip.c Andrew Lunn 2018-03-01 1227
65f60e4582bd32 drivers/net/dsa/mv88e6xxx/chip.c Andrew Lunn 2018-03-28 1228 mv88e6xxx_atu_vtu_get_strings(data);
65f60e4582bd32 drivers/net/dsa/mv88e6xxx/chip.c Andrew Lunn 2018-03-28 1229
c9acece064e3f0 drivers/net/dsa/mv88e6xxx/chip.c Rasmus Villemoes 2019-06-20 1230 mv88e6xxx_reg_unlock(chip);
dfafe449bbc91d drivers/net/dsa/mv88e6xxx/chip.c Andrew Lunn 2016-11-21 1231 }
dfafe449bbc91d drivers/net/dsa/mv88e6xxx/chip.c Andrew Lunn 2016-11-21 1232
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index c39cb119e760..285785c942b0 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -989,8 +989,7 @@ void b53_get_strings(struct dsa_switch *ds, int port, u32 stringset, if (stringset == ETH_SS_STATS) { for (i = 0; i < mib_size; i++) - strscpy(data + i * ETH_GSTRING_LEN, - mibs[i].name, ETH_GSTRING_LEN); + ethtool_puts(&data, mibs[i].name); } else if (stringset == ETH_SS_PHY_STATS) { phydev = b53_get_phy_device(ds, port); if (!phydev) diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c index 9201f07839ad..2bb1832d21bc 100644 --- a/drivers/net/dsa/bcm_sf2.c +++ b/drivers/net/dsa/bcm_sf2.c @@ -1180,11 +1180,8 @@ static const struct b53_io_ops bcm_sf2_io_ops = { static void bcm_sf2_sw_get_strings(struct dsa_switch *ds, int port, u32 stringset, uint8_t *data) { - int cnt = b53_get_sset_count(ds, port, stringset); - b53_get_strings(ds, port, stringset, data); - bcm_sf2_cfp_get_strings(ds, port, stringset, - data + cnt * ETH_GSTRING_LEN); + bcm_sf2_cfp_get_strings(ds, port, stringset, data); } static void bcm_sf2_sw_get_ethtool_stats(struct dsa_switch *ds, int port, diff --git a/drivers/net/dsa/bcm_sf2_cfp.c b/drivers/net/dsa/bcm_sf2_cfp.c index c88ee3dd4299..8ba23e643a42 100644 --- a/drivers/net/dsa/bcm_sf2_cfp.c +++ b/drivers/net/dsa/bcm_sf2_cfp.c @@ -1284,22 +1284,15 @@ void bcm_sf2_cfp_get_strings(struct dsa_switch *ds, int port, { struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds); unsigned int s = ARRAY_SIZE(bcm_sf2_cfp_stats); - char buf[ETH_GSTRING_LEN]; - unsigned int i, j, iter; + unsigned int i, j; if (stringset != ETH_SS_STATS) return; - for (i = 1; i < priv->num_cfp_rules; i++) { - for (j = 0; j < s; j++) { - snprintf(buf, sizeof(buf), - "CFP%03d_%sCntr", - i, bcm_sf2_cfp_stats[j].name); - iter = (i - 1) * s + j; - strscpy(data + iter * ETH_GSTRING_LEN, - buf, ETH_GSTRING_LEN); - } - } + for (i = 1; i < priv->num_cfp_rules; i++) + for (j = 0; j < s; j++) + ethtool_sprintf(&data, "CFP%03d_%sCntr", i, + bcm_sf2_cfp_stats[j].name); } void bcm_sf2_cfp_get_ethtool_stats(struct dsa_switch *ds, int port, diff --git a/drivers/net/dsa/hirschmann/hellcreek.c b/drivers/net/dsa/hirschmann/hellcreek.c index d798f17cf7ea..283ec5a6e23c 100644 --- a/drivers/net/dsa/hirschmann/hellcreek.c +++ b/drivers/net/dsa/hirschmann/hellcreek.c @@ -294,12 +294,8 @@ static void hellcreek_get_strings(struct dsa_switch *ds, int port, { int i; - for (i = 0; i < ARRAY_SIZE(hellcreek_counter); ++i) { - const struct hellcreek_counter *counter = &hellcreek_counter[i]; - - strscpy(data + i * ETH_GSTRING_LEN, - counter->name, ETH_GSTRING_LEN); - } + for (i = 0; i < ARRAY_SIZE(hellcreek_counter); ++i) + ethtool_puts(&data, hellcreek_counter[i].name); } static int hellcreek_get_sset_count(struct dsa_switch *ds, int port, int sset) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 4e8710c7cb7b..408ccb1f012e 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -2113,8 +2113,7 @@ static void ksz_get_strings(struct dsa_switch *ds, int port, return; for (i = 0; i < dev->info->mib_cnt; i++) { - memcpy(buf + i * ETH_GSTRING_LEN, - dev->info->mib_names[i].string, ETH_GSTRING_LEN); + ethtool_puts(&buf, dev->info->mib_names[i].string); } } diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 69cf19d3dd5e..bc813d97afa7 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -1220,12 +1220,9 @@ static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port, if (chip->info->ops->stats_get_strings) count = chip->info->ops->stats_get_strings(chip, data); - if (chip->info->ops->serdes_get_strings) { - data += count * ETH_GSTRING_LEN; + if (chip->info->ops->serdes_get_strings) count = chip->info->ops->serdes_get_strings(chip, port, data); - } - data += count * ETH_GSTRING_LEN; mv88e6xxx_atu_vtu_get_strings(data); mv88e6xxx_reg_unlock(chip); diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c index 1135a32e4b7e..b3e127f64b08 100644 --- a/drivers/net/dsa/rzn1_a5psw.c +++ b/drivers/net/dsa/rzn1_a5psw.c @@ -803,8 +803,7 @@ static void a5psw_get_strings(struct dsa_switch *ds, int port, u32 stringset, return; for (u = 0; u < ARRAY_SIZE(a5psw_stats); u++) { - memcpy(data + u * ETH_GSTRING_LEN, a5psw_stats[u].name, - ETH_GSTRING_LEN); + ethtool_puts(&data, a5psw_stats[u].name); } } diff --git a/drivers/net/dsa/sja1105/sja1105_ethtool.c b/drivers/net/dsa/sja1105/sja1105_ethtool.c index decc6c931dc1..2ea64b1d026d 100644 --- a/drivers/net/dsa/sja1105/sja1105_ethtool.c +++ b/drivers/net/dsa/sja1105/sja1105_ethtool.c @@ -586,7 +586,6 @@ void sja1105_get_strings(struct dsa_switch *ds, int port, { struct sja1105_private *priv = ds->priv; enum sja1105_counter_index max_ctr, i; - char *p = data; if (stringset != ETH_SS_STATS) return; @@ -597,10 +596,8 @@ void sja1105_get_strings(struct dsa_switch *ds, int port, else max_ctr = __MAX_SJA1105PQRS_PORT_COUNTER; - for (i = 0; i < max_ctr; i++) { - strscpy(p, sja1105_port_counters[i].name, ETH_GSTRING_LEN); - p += ETH_GSTRING_LEN; - } + for (i = 0; i < max_ctr; i++) + ethtool_puts(&data, sja1105_port_counters[i].name); } int sja1105_get_sset_count(struct dsa_switch *ds, int port, int sset) diff --git a/drivers/net/dsa/xrs700x/xrs700x.c b/drivers/net/dsa/xrs700x/xrs700x.c index de3b768f2ff9..4dbcc49a9e52 100644 --- a/drivers/net/dsa/xrs700x/xrs700x.c +++ b/drivers/net/dsa/xrs700x/xrs700x.c @@ -91,10 +91,8 @@ static void xrs700x_get_strings(struct dsa_switch *ds, int port, if (stringset != ETH_SS_STATS) return; - for (i = 0; i < ARRAY_SIZE(xrs700x_mibs); i++) { - strscpy(data, xrs700x_mibs[i].name, ETH_GSTRING_LEN); - data += ETH_GSTRING_LEN; - } + for (i = 0; i < ARRAY_SIZE(xrs700x_mibs); i++) + ethtool_puts(&data, xrs700x_mibs[i].name); } static int xrs700x_get_sset_count(struct dsa_switch *ds, int port, int sset)
The latter is the prefered way to copy ethtool strings. Transformed with the following coccinelle script: virtual org virtual report virtual context virtual patch @depends on patch@ expression E1, E2; identifier I; position p; @@ - memcpy@p(E1 + I * ETH_GSTRING_LEN, E2, ETH_GSTRING_LEN); + ethtool_puts(&E1, E2); Signed-off-by: Rosen Penev <rosenp@gmail.com> --- drivers/net/dsa/b53/b53_common.c | 3 +- drivers/net/dsa/bcm_sf2.c | 5 +- drivers/net/dsa/bcm_sf2_cfp.c | 17 ++-- drivers/net/dsa/hirschmann/hellcreek.c | 8 +- drivers/net/dsa/microchip/ksz_common.c | 3 +- drivers/net/dsa/mv88e6xxx/chip.c | 5 +- drivers/net/dsa/rzn1_a5psw.c | 3 +- drivers/net/dsa/sja1105/sja1105_ethtool.c | 7 +- drivers/net/dsa/xrs700x/xrs700x.c | 6 +- drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c | 22 +++--- drivers/net/ethernet/apm/xgene-v2/ethtool.c | 13 +--- .../ethernet/apm/xgene/xgene_enet_ethtool.c | 13 +--- drivers/net/ethernet/atheros/atlx/atl1.c | 8 +- .../ethernet/broadcom/asp2/bcmasp_ethtool.c | 5 +- drivers/net/ethernet/broadcom/bcm63xx_enet.c | 10 +-- drivers/net/ethernet/broadcom/bcmsysport.c | 16 ++-- drivers/net/ethernet/broadcom/bgmac.c | 3 +- .../net/ethernet/broadcom/genet/bcmgenet.c | 5 +- drivers/net/ethernet/cadence/macb_main.c | 19 ++--- drivers/net/ethernet/calxeda/xgmac.c | 9 +-- .../ethernet/cavium/liquidio/lio_ethtool.c | 50 +++++------- .../ethernet/cavium/thunder/nicvf_ethtool.c | 48 ++++-------- .../net/ethernet/cisco/enic/enic_ethtool.c | 40 ++++------ .../net/ethernet/emulex/benet/be_ethtool.c | 39 ++++------ drivers/net/ethernet/engleder/tsnep_ethtool.c | 32 ++++---- .../ethernet/freescale/dpaa/dpaa_ethtool.c | 38 +++------ .../ethernet/freescale/dpaa2/dpaa2-ethtool.c | 15 ++-- .../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 7 +- .../freescale/dpaa2/dpaa2-switch-ethtool.c | 12 ++- .../ethernet/freescale/enetc/enetc_ethtool.c | 33 +++----- .../net/ethernet/freescale/gianfar_ethtool.c | 8 +- .../net/ethernet/freescale/ucc_geth_ethtool.c | 23 +++--- .../ethernet/hisilicon/hns/hns_dsaf_main.c | 66 ++++++---------- .../hns3/hns3_common/hclge_comm_tqp_stats.c | 6 +- .../ethernet/hisilicon/hns3/hns3_ethtool.c | 9 +-- .../hisilicon/hns3/hns3pf/hclge_main.c | 49 +++++------- drivers/net/ethernet/ibm/ibmveth.c | 4 +- drivers/net/ethernet/ibm/ibmvnic.c | 30 +++---- .../net/ethernet/intel/e1000/e1000_ethtool.c | 13 ++-- drivers/net/ethernet/intel/e1000e/ethtool.c | 13 ++-- drivers/net/ethernet/intel/igbvf/ethtool.c | 9 +-- drivers/net/ethernet/intel/ixgbevf/ethtool.c | 35 ++++----- .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 38 +++------ .../marvell/octeon_ep/octep_ethtool.c | 34 +++----- .../marvell/octeon_ep_vf/octep_vf_ethtool.c | 37 ++++----- .../marvell/octeontx2/nic/otx2_ethtool.c | 78 +++++++------------ drivers/net/ethernet/marvell/skge.c | 3 +- drivers/net/ethernet/marvell/sky2.c | 3 +- .../mellanox/mlxsw/spectrum_ethtool.c | 77 +++++++----------- .../ethernet/mellanox/mlxsw/spectrum_ptp.c | 7 +- drivers/net/ethernet/micrel/ksz884x.c | 5 +- .../microchip/lan966x/lan966x_ethtool.c | 3 +- .../ethernet/microsoft/mana/mana_ethtool.c | 55 +++++-------- drivers/net/ethernet/mscc/ocelot_stats.c | 3 +- .../ethernet/netronome/nfp/nfp_net_ethtool.c | 3 +- .../oki-semi/pch_gbe/pch_gbe_ethtool.c | 8 +- .../qlogic/netxen/netxen_nic_ethtool.c | 10 +-- .../net/ethernet/qlogic/qede/qede_ethtool.c | 34 ++++---- .../ethernet/qlogic/qlcnic/qlcnic_ethtool.c | 49 +++++------- .../net/ethernet/qualcomm/emac/emac-ethtool.c | 7 +- drivers/net/ethernet/rocker/rocker_main.c | 7 +- .../ethernet/samsung/sxgbe/sxgbe_ethtool.c | 9 +-- drivers/net/ethernet/sfc/ethtool_common.c | 21 +++-- drivers/net/ethernet/sfc/falcon/ethtool.c | 14 ++-- drivers/net/ethernet/sfc/falcon/nic.c | 7 +- drivers/net/ethernet/sfc/nic.c | 7 +- .../net/ethernet/sfc/siena/ethtool_common.c | 25 +++--- drivers/net/ethernet/sfc/siena/nic.c | 7 +- .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 60 ++++++-------- .../stmicro/stmmac/stmmac_selftests.c | 7 +- drivers/net/ethernet/sun/cassini.c | 6 +- .../ethernet/synopsys/dwc-xlgmac-ethtool.c | 8 +- drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 20 ++--- drivers/net/ethernet/ti/cpsw_ethtool.c | 15 ++-- drivers/net/ethernet/ti/netcp_ethss.c | 7 +- drivers/net/fjes/fjes_ethtool.c | 52 +++++-------- drivers/net/phy/aquantia/aquantia_main.c | 3 +- drivers/net/phy/bcm-phy-lib.c | 3 +- drivers/net/usb/cdc_ncm.c | 8 +- drivers/net/xen-netback/interface.c | 3 +- drivers/net/xen-netfront.c | 3 +- net/dsa/user.c | 11 ++- 82 files changed, 550 insertions(+), 966 deletions(-)