[PATCH] bpf, devmap: Remove unnecessary if check in for loop

Thorsten Blum posted 1 patch 1 year, 6 months ago
kernel/bpf/devmap.c | 3 ---
1 file changed, 3 deletions(-)
[PATCH] bpf, devmap: Remove unnecessary if check in for loop
Posted by Thorsten Blum 1 year, 6 months ago
The iterator variable dst cannot be NULL and the if check can be
removed.

Remove it and fix the following Coccinelle/coccicheck warning reported
by itnull.cocci:

	ERROR: iterator variable bound on line 762 cannot be NULL

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
 kernel/bpf/devmap.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index 4e2cdbb5629f..7f3b34452243 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -760,9 +760,6 @@ int dev_map_redirect_multi(struct net_device *dev, struct sk_buff *skb,
 		for (i = 0; i < dtab->n_buckets; i++) {
 			head = dev_map_index_hash(dtab, i);
 			hlist_for_each_entry_safe(dst, next, head, index_hlist) {
-				if (!dst)
-					continue;
-
 				if (is_ifindex_excluded(excluded_devices, num_excluded,
 							dst->dev->ifindex))
 					continue;
-- 
2.45.1
Re: [PATCH] bpf, devmap: Remove unnecessary if check in for loop
Posted by Toke Høiland-Jørgensen 1 year, 6 months ago
Thorsten Blum <thorsten.blum@toblux.com> writes:

> The iterator variable dst cannot be NULL and the if check can be
> removed.
>
> Remove it and fix the following Coccinelle/coccicheck warning reported
> by itnull.cocci:
>
> 	ERROR: iterator variable bound on line 762 cannot be NULL
>
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>

Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
Re: [PATCH] bpf, devmap: Remove unnecessary if check in for loop
Posted by Jiri Olsa 1 year, 6 months ago
On Wed, May 29, 2024 at 12:19:01PM +0200, Thorsten Blum wrote:
> The iterator variable dst cannot be NULL and the if check can be
> removed.
> 
> Remove it and fix the following Coccinelle/coccicheck warning reported
> by itnull.cocci:
> 
> 	ERROR: iterator variable bound on line 762 cannot be NULL
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>

Acked-by: Jiri Olsa <jolsa@kernel.org>

jirka

> ---
>  kernel/bpf/devmap.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
> index 4e2cdbb5629f..7f3b34452243 100644
> --- a/kernel/bpf/devmap.c
> +++ b/kernel/bpf/devmap.c
> @@ -760,9 +760,6 @@ int dev_map_redirect_multi(struct net_device *dev, struct sk_buff *skb,
>  		for (i = 0; i < dtab->n_buckets; i++) {
>  			head = dev_map_index_hash(dtab, i);
>  			hlist_for_each_entry_safe(dst, next, head, index_hlist) {
> -				if (!dst)
> -					continue;
> -
>  				if (is_ifindex_excluded(excluded_devices, num_excluded,
>  							dst->dev->ifindex))
>  					continue;
> -- 
> 2.45.1
>