Skip to content

Commit

Permalink
virtio_net: Update driver to use ethtool_sprintf
Browse files Browse the repository at this point in the history
Update the code to replace instances of snprintf and a pointer update with
just calling ethtool_sprintf.

Also replace the char pointer with a u8 pointer to avoid having to recast
the pointer type.

Acked-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Alexander Duyck <alexanderduyck@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Alexander Duyck authored and David S. Miller committed Mar 17, 2021
1 parent 3ae0ed3 commit d7a9a01
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions drivers/net/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -2138,25 +2138,21 @@ static int virtnet_set_channels(struct net_device *dev,
static void virtnet_get_strings(struct net_device *dev, u32 stringset, u8 *data)
{
struct virtnet_info *vi = netdev_priv(dev);
char *p = (char *)data;
unsigned int i, j;
u8 *p = data;

switch (stringset) {
case ETH_SS_STATS:
for (i = 0; i < vi->curr_queue_pairs; i++) {
for (j = 0; j < VIRTNET_RQ_STATS_LEN; j++) {
snprintf(p, ETH_GSTRING_LEN, "rx_queue_%u_%s",
i, virtnet_rq_stats_desc[j].desc);
p += ETH_GSTRING_LEN;
}
for (j = 0; j < VIRTNET_RQ_STATS_LEN; j++)
ethtool_sprintf(&p, "rx_queue_%u_%s", i,
virtnet_rq_stats_desc[j].desc);
}

for (i = 0; i < vi->curr_queue_pairs; i++) {
for (j = 0; j < VIRTNET_SQ_STATS_LEN; j++) {
snprintf(p, ETH_GSTRING_LEN, "tx_queue_%u_%s",
i, virtnet_sq_stats_desc[j].desc);
p += ETH_GSTRING_LEN;
}
for (j = 0; j < VIRTNET_SQ_STATS_LEN; j++)
ethtool_sprintf(&p, "tx_queue_%u_%s", i,
virtnet_sq_stats_desc[j].desc);
}
break;
}
Expand Down

0 comments on commit d7a9a01

Please sign in to comment.