Message ID | 161557132651.10304.9382850626606060019.stgit@localhost.localdomain (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | ethtool: Factor out common code related to writing ethtool strings | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 1 maintainers not CCed: virtualization@lists.linux-foundation.org |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | fail | Errors and warnings before: 100 this patch: 23 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 32 lines checked |
netdev/build_allmodconfig_warn | fail | Errors and warnings before: 100 this patch: 100 |
netdev/header_inline | success | Link |
On Fri, Mar 12, 2021 at 09:48:46AM -0800, Alexander Duyck wrote: > From: Alexander Duyck <alexanderduyck@fb.com> > > 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. > > Signed-off-by: Alexander Duyck <alexanderduyck@fb.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> > --- > drivers/net/virtio_net.c | 18 +++++++----------- > 1 file changed, 7 insertions(+), 11 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index e97288dd6e5a..77ba8e2fc11c 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -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; > } >
在 2021/3/13 上午1:48, Alexander Duyck 写道: > From: Alexander Duyck <alexanderduyck@fb.com> > > 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. > > Signed-off-by: Alexander Duyck <alexanderduyck@fb.com> > --- > drivers/net/virtio_net.c | 18 +++++++----------- > 1 file changed, 7 insertions(+), 11 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index e97288dd6e5a..77ba8e2fc11c 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -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; > } Acked-by: Jason Wang <jasowang@redhat.com> > >
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index e97288dd6e5a..77ba8e2fc11c 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -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; }