mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexander Lobakin <alexandr.lobakin@intel.com>
To: Guo Zhengkui <guozhengkui@vivo.com>
Cc: Alexander Lobakin <alexandr.lobakin@intel.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel@vivo.com
Subject: Re: [PATCH] net: gro: use IS_ERR before PTR_ERR
Date: Tue,  7 Dec 2021 15:41:37 +0100	[thread overview]
Message-ID: <20211207144137.22454-1-alexandr.lobakin@intel.com> (raw)
In-Reply-To: <20211207073116.3856-1-guozhengkui@vivo.com>

From: Guo Zhengkui <guozhengkui@vivo.com>
Date: Tue,  7 Dec 2021 15:31:09 +0800

Hi, thanks for your patch.

> fix following cocci warning:
> ./net/core/gro.c:493:5-12: ERROR: PTR_ERR applied after initialization to constant on line 441
> 
> Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
> ---
>  net/core/gro.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/net/core/gro.c b/net/core/gro.c
> index 8ec8b44596da..ee08f7b23793 100644
> --- a/net/core/gro.c
> +++ b/net/core/gro.c
> @@ -490,9 +490,11 @@ static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff
>  	if (&ptype->list == head)
>  		goto normal;
>  
> -	if (PTR_ERR(pp) == -EINPROGRESS) {
> -		ret = GRO_CONSUMED;
> -		goto ok;
> +	if (IS_ERR(pp)) {
> +		if (PTR_ERR(pp) == -EINPROGRESS) {
> +			ret = GRO_CONSUMED;
> +			goto ok;
> +		}
>  	}

`if (PTR_ERR(ptr) == -ERRNO)` itself is correct without a check for
IS_ERR(). The former basically is a more precise test comparing to
the latter.
Not sure if compilers can get it well, but in ideal case the first
will be omitted from the object code at all, and so do we.

In case I'm wrong and this is a correct fix, it at least shouldn't
increase the indentation by one, these two conditions can be placed
into one `if` statement.

NAK.

>  
>  	same_flow = NAPI_GRO_CB(skb)->same_flow;
> -- 
> 2.20.1

Al

  reply	other threads:[~2021-12-07 14:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-07  7:31 Guo Zhengkui
2021-12-07 14:41 ` Alexander Lobakin [this message]
     [not found] ` <AG2AqAARE0*4ic4l2539l4rv.9.1638888118554.Hmail.guozhengkui@vivo.com.@PDIwMjExMjA3MTQ0MTM3LjIyNDU0LTEtYWxleGFuZHIubG9iYWtpbkBpbnRlbC5jb20+>
2021-12-08  7:09   ` Guo Zhengkui

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=20211207144137.22454-1-alexandr.lobakin@intel.com \
    --to=alexandr.lobakin@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=guozhengkui@vivo.com \
    --cc=kernel@vivo.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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

all inboxes | Powered by JetHome®