mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: kuba@kernel.org, gregkh@linuxfoundation.org, neilb@suse.com,
	mojha@codeaurora.org, jkosina@suse.cz
Cc: linux-kernel@vger.kernel.org, Wei Yang <richard.weiyang@gmail.com>
Subject: [PATCH] hashtable: remove a redundant check in hash_for_each_xxx()
Date: Wed,  6 Oct 2021 15:21:00 +0000	[thread overview]
Message-ID: <20211006152100.17795-1-richard.weiyang@gmail.com> (raw)

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


             reply	other threads:[~2021-10-06 15:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-06 15:21 Wei Yang [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211006152100.17795-1-richard.weiyang@gmail.com \
    --to=richard.weiyang@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jkosina@suse.cz \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mojha@codeaurora.org \
    --cc=neilb@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®