public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn•ch>
To: Daniil Tatianin <d-tatianin@yandex-team•ru>
Cc: netdev@vger•kernel.org, Michal Kubecek <mkubecek@suse•cz>,
	yc-core@yandex-team•ru, lvc-project@linuxtesting•org
Subject: Re: [PATCH v1 1/3] net/ethtool/ioctl: return -EOPNOTSUPP if we have no phy stats
Date: Fri, 25 Nov 2022 20:02:50 +0100	[thread overview]
Message-ID: <Y4ERWsV1vo1o7F2d@lunn.ch> (raw)
In-Reply-To: <20221125164913.360082-2-d-tatianin@yandex-team.ru>

On Fri, Nov 25, 2022 at 07:49:11PM +0300, Daniil Tatianin wrote:
> It's not very useful to copy back an empty ethtool_stats struct and
> return 0 if we didn't actually have any stats. This also allows for
> further simplification of this function in the future commits.
> 
> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team•ru>
> ---
>  net/ethtool/ioctl.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
> index 57e7238a4136..071e9bf16007 100644
> --- a/net/ethtool/ioctl.c
> +++ b/net/ethtool/ioctl.c
> @@ -2089,11 +2089,15 @@ static int ethtool_get_phy_stats(struct net_device *dev, void __user *useraddr)
>  		n_stats = phy_ops->get_sset_count(phydev);
>  	else
>  		n_stats = ops->get_sset_count(dev, ETH_SS_PHY_STATS);
> +
>  	if (n_stats < 0)

Please don't make unneeded white space changes. It just distracts from
the real change being made here.

>  		return n_stats;
>  	if (n_stats > S32_MAX / sizeof(u64))
>  		return -ENOMEM;
> -	WARN_ON_ONCE(!n_stats);
> +	if (!n_stats) {
> +		WARN_ON_ONCE(1);
> +		return -EOPNOTSUPP;
> +	}

WARN_ON_ONCE() returns the result of the comparison being made. so you can do:

	if (WARN_ON_ONCE(!n_stats))
		return -EOPNOTSUPP;

	Andrew		


       reply	other threads:[~2022-11-25 19:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20221125164913.360082-1-d-tatianin@yandex-team.ru>
     [not found] ` <20221125164913.360082-2-d-tatianin@yandex-team.ru>
2022-11-25 19:02   ` Andrew Lunn [this message]
     [not found] ` <20221125164913.360082-4-d-tatianin@yandex-team.ru>
2022-11-25 19:11   ` [PATCH v1 3/3] net/ethtool/ioctl: correct & simplify ethtool_get_phy_stats if checks Andrew Lunn
     [not found]     ` <55705e49-4b35-59be-5e41-7454dd12a0a4@yandex-team.ru>
2022-11-25 23:25       ` Andrew Lunn
     [not found]         ` <11169dbe-2a26-6f31-3be6-f0439bb861f1@yandex-team.ru>
2022-11-28 13:35           ` Andrew Lunn

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=Y4ERWsV1vo1o7F2d@lunn.ch \
    --to=andrew@lunn$(echo .)ch \
    --cc=d-tatianin@yandex-team$(echo .)ru \
    --cc=lvc-project@linuxtesting$(echo .)org \
    --cc=mkubecek@suse$(echo .)cz \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=yc-core@yandex-team$(echo .)ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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