netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/sched: remove redundant null check on head
@ 2017-05-03 13:50 Colin King
  2017-05-03 14:15 ` Jiri Pirko
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Colin King @ 2017-05-03 13:50 UTC (permalink / raw)
  To: Jamal Hadi Salim, Cong Wang, Jiri Pirko, netdev
  Cc: kernel-janitors, David S . Miller, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

head is previously null checked and so the 2nd null check on head
is redundant and therefore can be removed.

Detected by CoverityScan, CID#1399505 ("Logically dead code")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 net/sched/cls_matchall.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c
index 2efb36c08f2a..dee469fed967 100644
--- a/net/sched/cls_matchall.c
+++ b/net/sched/cls_matchall.c
@@ -203,8 +203,7 @@ static int mall_change(struct net *net, struct sk_buff *in_skb,
 
 	*arg = (unsigned long) head;
 	rcu_assign_pointer(tp->root, new);
-	if (head)
-		call_rcu(&head->rcu, mall_destroy_rcu);
+	call_rcu(&head->rcu, mall_destroy_rcu);
 	return 0;
 
 err_replace_hw_filter:
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] net/sched: remove redundant null check on head
  2017-05-03 13:50 [PATCH] net/sched: remove redundant null check on head Colin King
@ 2017-05-03 14:15 ` Jiri Pirko
  2017-05-03 14:21 ` walter harms
  2017-05-04 15:01 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: Jiri Pirko @ 2017-05-03 14:15 UTC (permalink / raw)
  To: Colin King
  Cc: Jamal Hadi Salim, Cong Wang, netdev, kernel-janitors,
	David S . Miller, linux-kernel

Wed, May 03, 2017 at 03:50:40PM CEST, colin.king@canonical.com wrote:
>From: Colin Ian King <colin.king@canonical.com>
>
>head is previously null checked and so the 2nd null check on head
>is redundant and therefore can be removed.
>
>Detected by CoverityScan, CID#1399505 ("Logically dead code")
>
>Signed-off-by: Colin Ian King <colin.king@canonical.com>

Acked-by: Jiri Pirko <jiri@mellanox.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net/sched: remove redundant null check on head
  2017-05-03 13:50 [PATCH] net/sched: remove redundant null check on head Colin King
  2017-05-03 14:15 ` Jiri Pirko
@ 2017-05-03 14:21 ` walter harms
  2017-05-03 15:12   ` Jiri Pirko
  2017-05-04 15:01 ` David Miller
  2 siblings, 1 reply; 5+ messages in thread
From: walter harms @ 2017-05-03 14:21 UTC (permalink / raw)
  To: Colin King
  Cc: Jamal Hadi Salim, Cong Wang, Jiri Pirko, netdev, kernel-janitors



Am 03.05.2017 15:50, schrieb Colin King:
> From: Colin Ian King <colin.king@canonical.com>
> 
> head is previously null checked and so the 2nd null check on head
> is redundant and therefore can be removed.
> 
> Detected by CoverityScan, CID#1399505 ("Logically dead code")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  net/sched/cls_matchall.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c
> index 2efb36c08f2a..dee469fed967 100644
> --- a/net/sched/cls_matchall.c
> +++ b/net/sched/cls_matchall.c
> @@ -203,8 +203,7 @@ static int mall_change(struct net *net, struct sk_buff *in_skb,
>  
>  	*arg = (unsigned long) head;
>  	rcu_assign_pointer(tp->root, new);
> -	if (head)
> -		call_rcu(&head->rcu, mall_destroy_rcu);
> +	call_rcu(&head->rcu, mall_destroy_rcu);
>  	return 0;
>  
>  err_replace_hw_filter:


if someone cares .. the err=0 in the the line above the patch is also useless
because err is never used again. Merging both if will save 1 indent level.

 err = mall_replace_hw_filter(tp, new, (unsigned long) new);
 if (err && tc_skip_sw(flags) )
	goto errout;


just my impression,
re
 wh

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net/sched: remove redundant null check on head
  2017-05-03 14:21 ` walter harms
@ 2017-05-03 15:12   ` Jiri Pirko
  0 siblings, 0 replies; 5+ messages in thread
From: Jiri Pirko @ 2017-05-03 15:12 UTC (permalink / raw)
  To: walter harms
  Cc: Colin King, Jamal Hadi Salim, Cong Wang, netdev, kernel-janitors

Wed, May 03, 2017 at 04:21:15PM CEST, wharms@bfs.de wrote:
>
>
>Am 03.05.2017 15:50, schrieb Colin King:
>> From: Colin Ian King <colin.king@canonical.com>
>> 
>> head is previously null checked and so the 2nd null check on head
>> is redundant and therefore can be removed.
>> 
>> Detected by CoverityScan, CID#1399505 ("Logically dead code")
>> 
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>  net/sched/cls_matchall.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>> 
>> diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c
>> index 2efb36c08f2a..dee469fed967 100644
>> --- a/net/sched/cls_matchall.c
>> +++ b/net/sched/cls_matchall.c
>> @@ -203,8 +203,7 @@ static int mall_change(struct net *net, struct sk_buff *in_skb,
>>  
>>  	*arg = (unsigned long) head;
>>  	rcu_assign_pointer(tp->root, new);
>> -	if (head)
>> -		call_rcu(&head->rcu, mall_destroy_rcu);
>> +	call_rcu(&head->rcu, mall_destroy_rcu);
>>  	return 0;
>>  
>>  err_replace_hw_filter:
>
>
>if someone cares .. the err=0 in the the line above the patch is also useless
>because err is never used again. Merging both if will save 1 indent level.
>
> err = mall_replace_hw_filter(tp, new, (unsigned long) new);
> if (err && tc_skip_sw(flags) )
>	goto errout;


true, however unrelated to this patch :)

Please submit as a separate patch.

Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net/sched: remove redundant null check on head
  2017-05-03 13:50 [PATCH] net/sched: remove redundant null check on head Colin King
  2017-05-03 14:15 ` Jiri Pirko
  2017-05-03 14:21 ` walter harms
@ 2017-05-04 15:01 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2017-05-04 15:01 UTC (permalink / raw)
  To: colin.king
  Cc: jhs, xiyou.wangcong, jiri, netdev, kernel-janitors, linux-kernel

From: Colin King <colin.king@canonical.com>
Date: Wed,  3 May 2017 14:50:40 +0100

> From: Colin Ian King <colin.king@canonical.com>
> 
> head is previously null checked and so the 2nd null check on head
> is redundant and therefore can be removed.
> 
> Detected by CoverityScan, CID#1399505 ("Logically dead code")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-05-04 15:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-03 13:50 [PATCH] net/sched: remove redundant null check on head Colin King
2017-05-03 14:15 ` Jiri Pirko
2017-05-03 14:21 ` walter harms
2017-05-03 15:12   ` Jiri Pirko
2017-05-04 15:01 ` David Miller

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).