All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] netfilter: nf_tables: replace unnecessary use of list_for_each_entry_continue()
@ 2022-03-19 20:25 Jakob Koschel
  2022-03-20  0:44 ` Florian Westphal
  0 siblings, 1 reply; 2+ messages in thread
From: Jakob Koschel @ 2022-03-19 20:25 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: Jakob Koschel, linux-kernel, netfilter-devel, coreteam, netdev,
	Jozsef Kadlecsik, Florian Westphal, David S. Miller,
	Jakub Kicinski, Paolo Abeni, Mike Rapoport, Brian Johannesmeyer,
	Cristiano Giuffrida, Bos, H.J.

Since there is no way for the previous list_for_each_entry() to exit
early, this call to list_for_each_entry_continue() is always guaranteed
to start with the first element of the list and can therefore be
replaced with a call to list_for_each_entry().

In preparation to limit the scope of the list iterator to the list
traversal loop, the list iterator variable 'rule' should not be used
past the loop.

Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 net/netfilter/nf_tables_api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index d71a33ae39b3..bdd80136ef1d 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -8299,7 +8299,7 @@ static int nf_tables_commit_chain_prepare(struct net *net, struct nft_chain *cha
 	data_boundary = data + data_size;
 	size = 0;
 
-	list_for_each_entry_continue(rule, &chain->rules, list) {
+	list_for_each_entry(rule, &chain->rules, list) {
 		if (!nft_is_active_next(net, rule))
 			continue;
 

base-commit: 34e047aa16c0123bbae8e2f6df33e5ecc1f56601
-- 
2.25.1


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

* Re: [PATCH] netfilter: nf_tables: replace unnecessary use of list_for_each_entry_continue()
  2022-03-19 20:25 [PATCH] netfilter: nf_tables: replace unnecessary use of list_for_each_entry_continue() Jakob Koschel
@ 2022-03-20  0:44 ` Florian Westphal
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Westphal @ 2022-03-20  0:44 UTC (permalink / raw)
  To: Jakob Koschel
  Cc: Pablo Neira Ayuso, linux-kernel, netfilter-devel, coreteam,
	netdev, Jozsef Kadlecsik, Florian Westphal, David S. Miller,
	Jakub Kicinski, Paolo Abeni, Mike Rapoport, Brian Johannesmeyer,
	Cristiano Giuffrida, Bos, H.J.

Jakob Koschel <jakobkoschel@gmail.com> wrote:
> Since there is no way for the previous list_for_each_entry() to exit
> early, this call to list_for_each_entry_continue() is always guaranteed
> to start with the first element of the list and can therefore be
> replaced with a call to list_for_each_entry().
> 
> In preparation to limit the scope of the list iterator to the list
> traversal loop, the list iterator variable 'rule' should not be used
> past the loop.
> 
> Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
>  
> -	list_for_each_entry_continue(rule, &chain->rules, list) {
> +	list_for_each_entry(rule, &chain->rules, list) {
>  		if (!nft_is_active_next(net, rule))
>  			continue;

You could also replace the first entry_continue and get rid of the
preceeding
	rule = list_entry().

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

end of thread, other threads:[~2022-03-20  0:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-19 20:25 [PATCH] netfilter: nf_tables: replace unnecessary use of list_for_each_entry_continue() Jakob Koschel
2022-03-20  0:44 ` Florian Westphal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.