Re: [PATCH net-next] net: bnxt: use ethtool string helpers
From: Rosen Penev
Date: Mon Oct 21 2024 - 17:05:43 EST
On Mon, Oct 21, 2024 at 1:26 PM Michael Chan <michael.chan@xxxxxxxxxxxx> wrote:
>
> On Sun, Oct 20, 2024 at 7:29 PM Rosen Penev <rosenp@xxxxxxxxx> wrote:
> >
> > Avoids having to use manual pointer manipulation.
> >
> > Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
> > ---
> > .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 110 ++++++++----------
> > 1 file changed, 50 insertions(+), 60 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
> > index f71cc8188b4e..84d468ad3c8e 100644
> > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
> > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
> > @@ -713,18 +713,17 @@ static void bnxt_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
> > for (i = 0; i < bp->cp_nr_rings; i++) {
> > if (is_rx_ring(bp, i)) {
> > num_str = NUM_RING_RX_HW_STATS;
> > - for (j = 0; j < num_str; j++) {
> > - sprintf(buf, "[%d]: %s", i,
> > + for (j = 0; j < num_str; j++)
> > + ethtool_sprintf(
> > + &buf, "[%d]: %s", i,
>
> If you combine this line with the line above, I think it will look better:
>
> ethtool_sprintf(&buf, "[%d]: %s", i,
>
> checkpatch.pl may warn because the next line won't line up, but I
> think it will look better and it reduces the number of lines. The
> same comment applies to other similar spots in the patch. Thanks.
I use git-clang-format for this stuff.
The only real way to satisfy everything is to use a temporary variable like
for (i = 0; i < BNXT_NUM_PORT_STATS; i++) {
const char *str = bnxt_port_stats_arr[i].string;
ethtool_puts(&buf, str);
}
to make everything small.
>
> > bnxt_ring_rx_stats_str[j]);
> > - buf += ETH_GSTRING_LEN;
> > - }