From: Simon Horman <horms@kernel.org>
To: luo penghao <cgel.zte@gmail.com>
Cc: Steffen Klassert <steffen.klassert@secunet.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
penghao luo <luo.penghao@zte.com.cn>,
Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH linux-next] xfrm: Remove redundant fields
Date: Wed, 20 Oct 2021 11:07:29 +0200 [thread overview]
Message-ID: <20211020090729.GC3935@kernel.org> (raw)
In-Reply-To: <20211018091758.858899-1-luo.penghao@zte.com.cn>
On Mon, Oct 18, 2021 at 09:17:58AM +0000, luo penghao wrote:
> From: penghao luo <luo.penghao@zte.com.cn>
>
> the variable err is not necessary in such places. It should be revmoved
> for the simplicity of the code.
>
> The clang_analyzer complains as follows:
>
> net/xfrm/xfrm_input.c:530: warning:
>
> Although the value stored to 'err' is used in the enclosing expression,
> the value is never actually read from 'err'.
>
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: penghao luo <luo.penghao@zte.com.cn>
> ---
> net/xfrm/xfrm_input.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
> index 3df0861..ff34667 100644
> --- a/net/xfrm/xfrm_input.c
> +++ b/net/xfrm/xfrm_input.c
> @@ -530,7 +530,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
> goto drop;
> }
>
> - if ((err = xfrm_parse_spi(skb, nexthdr, &spi, &seq)) != 0) {
> + if ((xfrm_parse_spi(skb, nexthdr, &spi, &seq)) != 0) {
I agree that assigning the value to err is not needed.
But you may also wish to consider:
1. Dropping the () around the call to xfrm_parse_spi, which seem out of
place now.
2. Dropping the explicit check against zero
Which would leave you with:
if (xfrm_parse_spi(skb, nexthdr, &spi, &seq)) {
> XFRM_INC_STATS(net, LINUX_MIB_XFRMINHDRERROR);
> goto drop;
> }
> @@ -560,7 +560,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
> }
>
> seq = 0;
> - if (!spi && (err = xfrm_parse_spi(skb, nexthdr, &spi, &seq)) != 0) {
> + if (!spi && (xfrm_parse_spi(skb, nexthdr, &spi, &seq)) != 0) {
> secpath_reset(skb);
> XFRM_INC_STATS(net, LINUX_MIB_XFRMINHDRERROR);
> goto drop;
> --
> 2.15.2
>
>
next prev parent reply other threads:[~2021-10-20 9:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-18 9:17 [PATCH linux-next] xfrm: Remove redundant fields luo penghao
2021-10-20 9:07 ` Simon Horman [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-10-21 6:56 luo penghao
2021-10-18 9:12 luo penghao
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=20211020090729.GC3935@kernel.org \
--to=horms@kernel.org \
--cc=cgel.zte@gmail.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luo.penghao@zte.com.cn \
--cc=netdev@vger.kernel.org \
--cc=steffen.klassert@secunet.com \
--cc=zealci@zte.com.cn \
/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;
as well as URLs for NNTP newsgroup(s).