linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hashtable: remove a redundant check in hash_for_each_xxx()
@ 2021-10-06 15:21 Wei Yang
  2021-10-06 15:29 ` Greg KH
  2021-10-06 21:16 ` NeilBrown
  0 siblings, 2 replies; 6+ messages in thread
From: Wei Yang @ 2021-10-06 15:21 UTC (permalink / raw)
  To: kuba, gregkh, neilb, mojha, jkosina; +Cc: linux-kernel, Wei Yang

The three hash_for_each_xxx() helper iterate the hash table with help
of hlist_for_each_entry_xxx(), which breaks the loop only when obj is
NULL.

This means the check during each iteration is redundant. This patch
removes it.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
 include/linux/hashtable.h | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/include/linux/hashtable.h b/include/linux/hashtable.h
index f6c666730b8c..a15719ed303f 100644
--- a/include/linux/hashtable.h
+++ b/include/linux/hashtable.h
@@ -124,8 +124,7 @@ static inline void hash_del_rcu(struct hlist_node *node)
  * @member: the name of the hlist_node within the struct
  */
 #define hash_for_each(name, bkt, obj, member)				\
-	for ((bkt) = 0, obj = NULL; obj == NULL && (bkt) < HASH_SIZE(name);\
-			(bkt)++)\
+	for ((bkt) = 0, obj = NULL; (bkt) < HASH_SIZE(name); (bkt)++)	\
 		hlist_for_each_entry(obj, &name[bkt], member)
 
 /**
@@ -136,8 +135,7 @@ static inline void hash_del_rcu(struct hlist_node *node)
  * @member: the name of the hlist_node within the struct
  */
 #define hash_for_each_rcu(name, bkt, obj, member)			\
-	for ((bkt) = 0, obj = NULL; obj == NULL && (bkt) < HASH_SIZE(name);\
-			(bkt)++)\
+	for ((bkt) = 0, obj = NULL; (bkt) < HASH_SIZE(name); (bkt)++)	\
 		hlist_for_each_entry_rcu(obj, &name[bkt], member)
 
 /**
@@ -150,8 +148,7 @@ static inline void hash_del_rcu(struct hlist_node *node)
  * @member: the name of the hlist_node within the struct
  */
 #define hash_for_each_safe(name, bkt, tmp, obj, member)			\
-	for ((bkt) = 0, obj = NULL; obj == NULL && (bkt) < HASH_SIZE(name);\
-			(bkt)++)\
+	for ((bkt) = 0, obj = NULL; (bkt) < HASH_SIZE(name); (bkt)++)	\
 		hlist_for_each_entry_safe(obj, tmp, &name[bkt], member)
 
 /**
-- 
2.23.0


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

end of thread, other threads:[~2021-10-07 23:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-06 15:21 [PATCH] hashtable: remove a redundant check in hash_for_each_xxx() Wei Yang
2021-10-06 15:29 ` Greg KH
2021-10-06 21:16 ` NeilBrown
2021-10-07  0:30   ` Wei Yang
2021-10-07  0:50     ` NeilBrown
2021-10-07 23:40       ` Wei Yang

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