From: Rosen Penev <rosenp@gmail.com>
To: netdev@vger.kernel.org
Cc: Shay Agroskin <shayagr@amazon.com>,
Arthur Kiyanovski <akiyano@amazon.com>,
David Arinzon <darinzon@amazon.com>,
Noam Dagan <ndagan@amazon.com>, Saeed Bishara <saeedb@amazon.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Jian Shen <shenjian15@huawei.com>,
Salil Mehta <salil.mehta@huawei.com>,
Jijie Shao <shaojijie@huawei.com>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH net-next 2/2] net: ena: simplify some pointer addition
Date: Fri, 1 Nov 2024 14:48:28 -0700 [thread overview]
Message-ID: <20241101214828.289752-3-rosenp@gmail.com> (raw)
In-Reply-To: <20241101214828.289752-1-rosenp@gmail.com>
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@gmail.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
next prev parent reply other threads:[~2024-11-01 21:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-01 21:48 [PATCH net-next 0/2] net: ena: two cleanups Rosen Penev
2024-11-01 21:48 ` [PATCH net-next 1/2] net: ena: remove devm from ethtool Rosen Penev
2024-11-04 13:35 ` Shay Agroskin
2024-11-01 21:48 ` Rosen Penev [this message]
2024-11-04 13:36 ` [PATCH net-next 2/2] net: ena: simplify some pointer addition Shay Agroskin
2024-11-05 2:30 ` [PATCH net-next 0/2] net: ena: two cleanups patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241101214828.289752-3-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=akiyano@amazon.com \
--cc=andrew+netdev@lunn.ch \
--cc=darinzon@amazon.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ndagan@amazon.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedb@amazon.com \
--cc=salil.mehta@huawei.com \
--cc=shaojijie@huawei.com \
--cc=shayagr@amazon.com \
--cc=shenjian15@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).