[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241101214828.289752-3-rosenp@gmail.com>
Date: Fri, 1 Nov 2024 14:48:28 -0700
From: Rosen Penev <rosenp@...il.com>
To: netdev@...r.kernel.org
Cc: Shay Agroskin <shayagr@...zon.com>,
Arthur Kiyanovski <akiyano@...zon.com>,
David Arinzon <darinzon@...zon.com>,
Noam Dagan <ndagan@...zon.com>,
Saeed Bishara <saeedb@...zon.com>,
Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Jian Shen <shenjian15@...wei.com>,
Salil Mehta <salil.mehta@...wei.com>,
Jijie Shao <shaojijie@...wei.com>,
linux-kernel@...r.kernel.org (open list)
Subject: [PATCH net-next 2/2] net: ena: simplify some pointer addition
Use ethtool_sprintf to simplify the code.
Because strings_buf is separate from buf, it needs to be incremented
separately.
Signed-off-by: Rosen Penev <rosenp@...il.com>
---
drivers/net/ethernet/amazon/ena/ena_ethtool.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/amazon/ena/ena_ethtool.c b/drivers/net/ethernet/amazon/ena/ena_ethtool.c
index fa9d7b8ec00d..96fa55a88faf 100644
--- a/drivers/net/ethernet/amazon/ena/ena_ethtool.c
+++ b/drivers/net/ethernet/amazon/ena/ena_ethtool.c
@@ -1120,7 +1120,7 @@ static void ena_dump_stats_ex(struct ena_adapter *adapter, u8 *buf)
u8 *strings_buf;
u64 *data_buf;
int strings_num;
- int i, rc;
+ int i;
strings_num = ena_get_sw_stats_count(adapter);
if (strings_num <= 0) {
@@ -1149,17 +1149,16 @@ static void ena_dump_stats_ex(struct ena_adapter *adapter, u8 *buf)
/* If there is a buffer, dump stats, otherwise print them to dmesg */
if (buf)
for (i = 0; i < strings_num; i++) {
- rc = snprintf(buf, ETH_GSTRING_LEN + sizeof(u64),
- "%s %llu\n",
- strings_buf + i * ETH_GSTRING_LEN,
- data_buf[i]);
- buf += rc;
+ ethtool_sprintf(&buf, "%s %llu\n", strings_buf,
+ data_buf[i]);
+ strings_buf += ETH_GSTRING_LEN;
}
else
- for (i = 0; i < strings_num; i++)
+ for (i = 0; i < strings_num; i++) {
netif_err(adapter, drv, netdev, "%s: %llu\n",
- strings_buf + i * ETH_GSTRING_LEN,
- data_buf[i]);
+ strings_buf, data_buf[i]);
+ strings_buf += ETH_GSTRING_LEN;
+ }
kfree(strings_buf);
kfree(data_buf);
--
2.47.0
Powered by blists - more mailing lists