From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FB00C4332F for ; Fri, 25 Nov 2022 19:03:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229685AbiKYTC6 (ORCPT ); Fri, 25 Nov 2022 14:02:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbiKYTC5 (ORCPT ); Fri, 25 Nov 2022 14:02:57 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83CCD2F009 for ; Fri, 25 Nov 2022 11:02:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=6T/Q4WFoXHQ6RmYERX27lAjeGjyEHdN7GJcOWISil5U=; b=AtG1+5QYrSlZKVqdCeh26qrfLr Le4UmmfSJjnxeYbpQFNThB++faM8fGUD7vOS/YqdS5kmBmkXpGQ0Cu1E+T4NG+/SLKuQqxjoQQII9 fucRVWTVWayiLLIHYDVZnMDljl8qlFwx9AOWvGe2DE7q3GgBQ9l7DOWbcuHnL0C//t9s=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1oydyM-003SSg-9H; Fri, 25 Nov 2022 20:02:50 +0100 Date: Fri, 25 Nov 2022 20:02:50 +0100 From: Andrew Lunn To: Daniil Tatianin Cc: netdev@vger.kernel.org, Michal Kubecek , 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 Message-ID: References: <20221125164913.360082-1-d-tatianin@yandex-team.ru> <20221125164913.360082-2-d-tatianin@yandex-team.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221125164913.360082-2-d-tatianin@yandex-team.ru> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 > --- > 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