Re: [PATCH] virtio_net: Fix duplicated return values in virtnet_get_hw_stats

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 14 May 2025 13:44:33 +0800 Tang Longjun wrote:
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index e53ba600605a..c9a86f325619 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -4897,7 +4897,7 @@ static int __virtnet_get_hw_stats(struct virtnet_info *vi,
>  					&sgs_out, &sgs_in);
>  
>  	if (!ok)
> -		return ok;
> +		return 1;

This makes sense, looks like a typo in the original code.
But we are now returning the reverse polarity of "ok", so we should
probably rename the variable in virtnet_get_hw_stats() ok -> failed
Or invert the polarity here and in virtnet_get_hw_stats()

>  	for (p = reply; p - reply < res_size; p += le16_to_cpu(hdr->size)) {
>  		hdr = p;
> @@ -4937,7 +4937,7 @@ static int virtnet_get_hw_stats(struct virtnet_info *vi,
>  	int ok;
>  
>  	if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_DEVICE_STATS))
> -		return 0;
> +		return -EOPNOTSUPP;

IDK about this part. We should not spam the logs if the device does not
support a feature. We should instead skip reporting the relevant stats.
User can tell that those stats are not supported from the fact they are
not present.
-- 
pw-bot: cr




[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux