ipip: do not use 'err' variable for setting return value
Subsystems (3)
PATCH 1/1 ipip: do not use 'err' variable for setting return value
It's a bit confusing to set 'err' variable inside and outside of the block for the return value of ipip_err(). We don't even need this variable, so clean it all up to spare declaration as well as bunch of unnecessary initializations and jumps.
--- net/ipv4/ipip.c | 20 +++++++------------- 1 files changed, 7 insertions(+), 13 deletions(-)
net/ipv4/ipip.c +7 -13
@@ -343,7 +343,6 @@ static int ipip_err(struct sk_buff *skb, u32 info)const int type =icmp_hdr (skb)->type;const int code =icmp_hdr (skb)->code;struct ip_tunnel *t; -int err;switch (type) {default :
@@ -372,40 +371,35 @@ static int ipip_err(struct sk_buff *skb, u32 info)break ; } - err = -ENOENT ; t =ipip_tunnel_lookup (dev_net (skb->dev), iph->daddr, iph->saddr);if (t ==NULL ) - goto out; +return -ENOENT ;if (type ==ICMP_DEST_UNREACH && code ==ICMP_FRAG_NEEDED ) {ipv4_update_pmtu (skb,dev_net (skb->dev), info, t->dev->ifindex,0 ,IPPROTO_IPIP ,0 ); - err =0 ; - goto out; +return 0 ; }if (type ==ICMP_REDIRECT ) {ipv4_redirect (skb,dev_net (skb->dev), t->dev->ifindex,0 ,IPPROTO_IPIP ,0 ); - err =0 ; - goto out; +return 0 ; }if (t->parms.iph.daddr ==0 ) - goto out; +return -ENOENT ; - err =0 ;if (t->parms.iph.ttl ==0 && type ==ICMP_TIME_EXCEEDED ) - goto out; +return 0 ;if (time_before (jiffies, t->err_time +IPTUNNEL_ERR_TIMEO )) t->err_count++;else t->err_count =1 ; - t->err_time = jiffies; -out: -return err; + t->err_time = jiffies; +return 0 ; }static int ipip_rcv (struct sk_buff *skb)
David Miller
maintainerFrom: Jean Sacren <[email protected]>
Date: Tue, 15 Jan 2013 01:14:10 -0700
Quoted 6 lines
It's a bit confusing to set 'err' variable inside and outside of the block for the return value of
ipip_err(). We don't even need this variable, so clean it all up to spare declaration as well as bunch of unnecessary initializations and jumps.Signed-off-by Jean Sacren <[email protected]>
It makes the non-error path straight line code.
The code as-is is fine, and I'm not applying this patch, sorry.
From: David Miller <[email protected]>
Date: Tue, 15 Jan 2013 03:20:08 -0500
Quoted 4 lines
From: Jean Sacren <[email protected]>
Date: Tue, 15 Jan 2013 01:14:10 -0700
Quoted 8 lines
Quoted 6 lines
It's a bit confusing to set 'err' variable inside and outside of the block for the return value of
ipip_err(). We don't even need this variable, so clean it all up to spare declaration as well as bunch of unnecessary initializations and jumps.Signed-off-by Jean Sacren <[email protected]>It makes the non-error path straight line code.
I thought about the error path, but I realized the error handling code couldn't be simpler. There is only one error, namely ENOENT, which warrants no error path. As 'err' variable was used, you were forced to reset it to zero seven months ago. Again you were forced to reset it to zero six months ago. As you were doubly forced, finally I came up with this idea of getting rid of the unnecessary variable.
Also the error handling in the patch is consistent with the way earlier portion of the function definition does.
Quoted 1 line
The code as-is is fine, and I'm not applying this patch, sorry.
Thank you for reviewing. This is a rather trivial patch. If patches like this one are not compelling enough for acceptance, that's fair enough.
Signature · 1 line
Jean Sacren