Re: [PATCH linux-next] xfrm: Remove redundant fields
From: Simon Horman <horms@kernel.org>
Date: 2021-10-20 09:07:36
Also in:
lkml
On Mon, Oct 18, 2021 at 09:17:58AM +0000, luo penghao wrote:
quoted hunk ↗ jump to hunk
From: penghao luo <redacted> 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 <redacted> Signed-off-by: penghao luo <redacted> --- 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)) {
quoted hunk ↗ jump to hunk
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