lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Wed,  6 Oct 2021 15:21:00 +0000
From:   Wei Yang <richard.weiyang@...il.com>
To:     kuba@...nel.org, gregkh@...uxfoundation.org, neilb@...e.com,
        mojha@...eaurora.org, jkosina@...e.cz
Cc:     linux-kernel@...r.kernel.org, Wei Yang <richard.weiyang@...il.com>
Subject: [PATCH] hashtable: remove a redundant check in hash_for_each_xxx()

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@...il.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ