diff mbox series

[net-next] net: sunvnet: use ethtool_sprintf/puts

Message ID 20240809044502.4184-1-rosenp@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: sunvnet: use ethtool_sprintf/puts | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 7 this patch: 7
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 7 this patch: 7
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 47 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-09--15-00 (tests: 705)

Commit Message

Rosen Penev Aug. 9, 2024, 4:44 a.m. UTC
Simpler and allows avoiding manual pointer addition.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/net/ethernet/sun/sunvnet.c | 35 +++++++++---------------------
 1 file changed, 10 insertions(+), 25 deletions(-)

Comments

kernel test robot Aug. 9, 2024, 8:48 p.m. UTC | #1
Hi Rosen,

kernel test robot noticed the following build errors:

[auto build test ERROR on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Rosen-Penev/net-sunvnet-use-ethtool_sprintf-puts/20240809-145830
base:   net-next/main
patch link:    https://lore.kernel.org/r/20240809044502.4184-1-rosenp%40gmail.com
patch subject: [PATCH net-next] net: sunvnet: use ethtool_sprintf/puts
config: sparc-allmodconfig (https://download.01.org/0day-ci/archive/20240810/202408100443.OXvAtrM9-lkp@intel.com/config)
compiler: sparc64-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240810/202408100443.OXvAtrM9-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/202408100443.OXvAtrM9-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/net/ethernet/sun/sunvnet.c: In function 'vnet_get_strings':
>> drivers/net/ethernet/sun/sunvnet.c:120:36: error: passing argument 2 of 'ethtool_puts' from incompatible pointer type [-Wincompatible-pointer-types]
     120 |                 ethtool_puts(&buf, &ethtool_stats_keys);
         |                                    ^~~~~~~~~~~~~~~~~~~
         |                                    |
         |                                    const struct <anonymous> (*)[14]
   In file included from drivers/net/ethernet/sun/sunvnet.c:17:
   include/linux/ethtool.h:1273:49: note: expected 'const char *' but argument is of type 'const struct <anonymous> (*)[14]'
    1273 | extern void ethtool_puts(u8 **data, const char *str);
         |                                     ~~~~~~~~~~~~^~~


vim +/ethtool_puts +120 drivers/net/ethernet/sun/sunvnet.c

   112	
   113	static void vnet_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
   114	{
   115		struct vnet *vp = (struct vnet *)netdev_priv(dev);
   116		struct vnet_port *port;
   117	
   118		switch (stringset) {
   119		case ETH_SS_STATS:
 > 120			ethtool_puts(&buf, &ethtool_stats_keys);
   121	
   122			rcu_read_lock();
   123			list_for_each_entry_rcu(port, &vp->port_list, list) {
   124				ethtool_sprintf(&buf, "p%u.%s-%pM", port->q_index,
   125						port->switch_port ? "s" : "q",
   126						port->raddr);
   127				ethtool_sprintf(&buf, "p%u.rx_packets", port->q_index);
   128				ethtool_sprintf(&buf, "p%u.tx_packets", port->q_index);
   129				ethtool_sprintf(&buf, "p%u.rx_bytes", port->q_index);
   130				ethtool_sprintf(&buf, "p%u.tx_bytes", port->q_index);
   131				ethtool_sprintf(&buf, "p%u.event_up", port->q_index);
   132				ethtool_sprintf(&buf, "p%u.event_reset", port->q_index);
   133			}
   134			rcu_read_unlock();
   135			break;
   136		default:
   137			WARN_ON(1);
   138			break;
   139		}
   140	}
   141
diff mbox series

Patch

diff --git a/drivers/net/ethernet/sun/sunvnet.c b/drivers/net/ethernet/sun/sunvnet.c
index 2f30715e9b67..f26e76b44c60 100644
--- a/drivers/net/ethernet/sun/sunvnet.c
+++ b/drivers/net/ethernet/sun/sunvnet.c
@@ -114,37 +114,22 @@  static void vnet_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
 {
 	struct vnet *vp = (struct vnet *)netdev_priv(dev);
 	struct vnet_port *port;
-	char *p = (char *)buf;
 
 	switch (stringset) {
 	case ETH_SS_STATS:
-		memcpy(buf, &ethtool_stats_keys, sizeof(ethtool_stats_keys));
-		p += sizeof(ethtool_stats_keys);
+		ethtool_puts(&buf, &ethtool_stats_keys);
 
 		rcu_read_lock();
 		list_for_each_entry_rcu(port, &vp->port_list, list) {
-			snprintf(p, ETH_GSTRING_LEN, "p%u.%s-%pM",
-				 port->q_index, port->switch_port ? "s" : "q",
-				 port->raddr);
-			p += ETH_GSTRING_LEN;
-			snprintf(p, ETH_GSTRING_LEN, "p%u.rx_packets",
-				 port->q_index);
-			p += ETH_GSTRING_LEN;
-			snprintf(p, ETH_GSTRING_LEN, "p%u.tx_packets",
-				 port->q_index);
-			p += ETH_GSTRING_LEN;
-			snprintf(p, ETH_GSTRING_LEN, "p%u.rx_bytes",
-				 port->q_index);
-			p += ETH_GSTRING_LEN;
-			snprintf(p, ETH_GSTRING_LEN, "p%u.tx_bytes",
-				 port->q_index);
-			p += ETH_GSTRING_LEN;
-			snprintf(p, ETH_GSTRING_LEN, "p%u.event_up",
-				 port->q_index);
-			p += ETH_GSTRING_LEN;
-			snprintf(p, ETH_GSTRING_LEN, "p%u.event_reset",
-				 port->q_index);
-			p += ETH_GSTRING_LEN;
+			ethtool_sprintf(&buf, "p%u.%s-%pM", port->q_index,
+					port->switch_port ? "s" : "q",
+					port->raddr);
+			ethtool_sprintf(&buf, "p%u.rx_packets", port->q_index);
+			ethtool_sprintf(&buf, "p%u.tx_packets", port->q_index);
+			ethtool_sprintf(&buf, "p%u.rx_bytes", port->q_index);
+			ethtool_sprintf(&buf, "p%u.tx_bytes", port->q_index);
+			ethtool_sprintf(&buf, "p%u.event_up", port->q_index);
+			ethtool_sprintf(&buf, "p%u.event_reset", port->q_index);
 		}
 		rcu_read_unlock();
 		break;