net/ipv6: remove redundant err variable
Subsystems (3)
PATCH 1/1 net/ipv6: remove redundant err variable
From: Minghao Chi <[email protected]>
Return value from ip6_tnl_err() directly instead of taking this in another redundant variable.
--- net/ipv6/ip6_tunnel.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/ipv6/ip6_tunnel.c +2 -3
@@ -698,13 +698,12 @@ mplsip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, u8 type, u8 code, int offset, __be32 info) { __u32 rel_info = ntohl(info); -int err, rel_msg =0 ; +int rel_msg =0 ;u8 rel_type = type;u8 rel_code = code; - err =ip6_tnl_err (skb,IPPROTO_MPLS , opt, &rel_type, &rel_code, +return ip6_tnl_err (skb,IPPROTO_MPLS , opt, &rel_type, &rel_code, &rel_msg, &rel_info, offset); -return err; } static int ip4ip6_dscp_ecn_decapsulate(const struct ip6_tnl *t,
Signature · 1 line
2.25.1
net/ipv6/ip6_tunnel.c mplsip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, · line 701
Quoted 10 lines · On 1/12/22 1:26 AM, [email protected] wrote:
net/ipv6/ip6_tunnel.c +1
-1@@ -698,13 +698,12 @@ mplsip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, u8 type, u8 code, int offset, __be32 info) { __u32 rel_info = ntohl(info); -int err, rel_msg =0 ; +int rel_msg =0 ;
this line needs to be moved down to maintain reverse xmas tree ordering.
You need to make the subject
'[PATCH net-next] net/ipv6: remove redundant err variable'
and since net-next is closed you will need to resubmit when it is open.
Quoted 10 lines
net/ipv6/ip6_tunnel.c +1
-2u8 rel_type = type;u8 rel_code = code; - err =ip6_tnl_err (skb,IPPROTO_MPLS , opt, &rel_type, &rel_code, +return ip6_tnl_err (skb,IPPROTO_MPLS , opt, &rel_type, &rel_code, &rel_msg, &rel_info, offset); -return err; } static int ip4ip6_dscp_ecn_decapsulate(const struct ip6_tnl *t,
Jakub Kicinski
maintainerQuoted 14 lines · On Wed, 12 Jan 2022 08:54:41 -0700 David Ahern wrote:
net/ipv6/ip6_tunnel.c mplsip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, · line 701
Quoted 10 lines · On 1/12/22 1:26 AM, [email protected] wrote:
net/ipv6/ip6_tunnel.c +1
-1@@ -698,13 +698,12 @@ mplsip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, u8 type, u8 code, int offset, __be32 info) { __u32 rel_info = ntohl(info); -int err, rel_msg =0 ; +int rel_msg =0 ;this line needs to be moved down to maintain reverse xmas tree ordering.
Quoted 4 lines
You need to make the subject
'[PATCH net-next] net/ipv6: remove redundant err variable'and since net-next is closed you will need to resubmit when it is open.
Frankly I'm not sure these type of patches make sense.
Minghao how many instances of this pattern are there in the tree today?
What tools can we use to ensure the pattern does not get added back in new patches?
Quoted 6 lines
net/ipv6/ip6_tunnel.c mplsip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, · line 706
Quoted 6 lines
net/ipv6/ip6_tunnel.c +1
-1u8 rel_type = type;u8 rel_code = code; - err =ip6_tnl_err (skb,IPPROTO_MPLS , opt, &rel_type, &rel_code, +return ip6_tnl_err (skb,IPPROTO_MPLS , opt, &rel_type, &rel_code, &rel_msg, &rel_info, offset);
You should re-align continuation lines when you move the opening bracket.
Quoted 2 lines
Quoted 2 lines
net/ipv6/ip6_tunnel.c +0
-1-return err; }
In the bot, I wrote a coccinelle rule myself to search for such problems, maybe use the rules to scan before submitting the patch.
Jakub Kicinski
maintainerQuoted 2 lines · On Wed, 19 Jan 2022 03:00:03 +0000 [email protected] wrote:
In the bot, I wrote a coccinelle rule myself to search for such problems, maybe use the rules to scan before submitting the patch.
Is it
scripts/coccinelle/misc/returnvar.cocci
?
How many of such patches do you have pending?
There are more than 3,000 numbers retrieved by the rules I wrote. Of course, many of these 3,000 are false positives, and maybe there are 300 patches.I wrote this rule similar to returnvar.cocci.
Jakub Kicinski
maintainerQuoted 3 lines · On Wed, 19 Jan 2022 05:55:57 +0000 [email protected] wrote:
There are more than 3,000 numbers retrieved by the rules I wrote. Of course, many of these 3,000 are false positives, and maybe there are 300 patches.I wrote this rule similar to
returnvar.cocci.
Can you start by improving returnvar.cocci so it catches all the cases? Then make sure your patches build and don't introduce formatting problems. Then post them.