ipv6: Remove some pointless conditionals before kfree_skb()
Subsystems (4)
PATCH 1/1 ipv6: Remove some pointless conditionals before kfree_skb()
Remove some pointless conditionals before kfree_skb().
The semantic match that finds the problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@@
expression E;
@@
- if (E)
- kfree_skb(E);
+ kfree_skb(E);
// </smpl>
--- net/ipv6/ipv6_sockglue.c | 3 +-- net/ipv6/tcp_ipv6.c | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-)
net/ipv6/ipv6_sockglue.c +1 -2
@@ -218,8 +218,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,if (opt)sock_kfree_s (sk, opt, opt->tot_len); pktopt =xchg (&np->pktoptions,NULL ); -if (pktopt) -kfree_skb (pktopt); +kfree_skb (pktopt); sk->sk_destruct = inet_sock_destruct;/*
net/ipv6/tcp_ipv6.c +2 -4
@@ -533,8 +533,7 @@ static inline void syn_flood_warning(struct sk_buff *skb)static void tcp_v6_reqsk_destructor (struct request_sock *req) { -if (inet6_rsk (req)->pktopts) -kfree_skb (inet6_rsk (req)->pktopts); +kfree_skb (inet6_rsk (req)->pktopts); }#ifdef CONFIG_TCP_MD5SIG
@@ -1611,8 +1610,7 @@ ipv6_pktoptions: } } -if (opt_skb) -kfree_skb (opt_skb); +kfree_skb (opt_skb);return 0 ; }
Signature · 1 line
1.5.3.8
Quoted 12 lines · Wei Yongjun
Remove some pointless conditionals before
kfree_skb().The semantic match that finds the problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)// <smpl>
@@
expression E;
@@
- if (E)(quoted diff) +1
-1- kfree_skb(E); + kfree_skb(E);
Quoted 1 line
// </smpl>
I think kfree_skb() suppose that you have handled NULL pointer because it uses unlikely to check the pointer.
So I don't think these conditions are pointless...
437 void kfree_skb(struct sk_buff *skb)
438 {
439 if (unlikely(!skb))
440 return;
Quoted 45 lines
Signed-off-by Wei Yongjun <[email protected]>--- net/ipv6/ipv6_sockglue.c | 3 +-- net/ipv6/tcp_ipv6.c | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-)net/ipv6/ipv6_sockglue.c +1
-2@@ -218,8 +218,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,if (opt)sock_kfree_s (sk, opt, opt->tot_len); pktopt =xchg (&np->pktoptions,NULL ); -if (pktopt) -kfree_skb (pktopt); +kfree_skb (pktopt); sk->sk_destruct = inet_sock_destruct;/* net/ipv6/tcp_ipv6.c +2
-4@@ -533,8 +533,7 @@ static inline void syn_flood_warning(struct sk_buff *skb)static void tcp_v6_reqsk_destructor (struct request_sock *req) { -if (inet6_rsk (req)->pktopts) -kfree_skb (inet6_rsk (req)->pktopts); +kfree_skb (inet6_rsk (req)->pktopts); }#ifdef CONFIG_TCP_MD5SIG @@ -1611,8 +1610,7 @@ ipv6_pktoptions: } } -if (opt_skb) -kfree_skb (opt_skb); +kfree_skb (opt_skb);return 0 ; }
Signature · 2 lines
Regards Yang Hongyang
Quoted 8 lines · Yang Hongyang
I think
kfree_skb()suppose that you have handled NULL pointer because it usesunlikelyto check the pointer.
So I don't think these conditions are pointless... 437 voidkfree_skb(struct sk_buff *skb)
438 {
439 if (unlikely(!skb))
440 return;
These checks were specifically added so that callers didn't have to check for NULL.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 11 lines · Herbert Xu
Quoted 7 lines · Yang Hongyang
I think
kfree_skb()suppose that you have handled NULL pointer because it usesunlikelyto check the pointer.
So I don't think these conditions are pointless... 437 voidkfree_skb(struct sk_buff *skb)
438 {
439 if (unlikely(!skb))
440 return;These checks were specifically added so that callers didn't have to check for NULL.
Yes,but if the the callers checked for NULL,it's OK right?
Quoted 2 lines
Cheers,
Signature · 2 lines
Regards Yang Hongyang
Quoted 5 lines · Yang Hongyang
Quoted 3 lines
These checks were specifically added so that callers didn't have to check for NULL.
Yes,but if the the callers checked for NULL,it's OK right?
Well people will continue to send patches to remove them until they're all gone :)
Really this isn't even worth discussing.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtFrom: Wei Yongjun <[email protected]>
Date: Tue, 24 Feb 2009 15:45:33 +0800
Quoted 4 lines
Remove some pointless conditionals before
kfree_skb().The semantic match that finds the problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)
...
Quoted 1 line
Signed-off-by Wei Yongjun <[email protected]>
Applied.