mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Cai Huoqing <cai.huoqing@linux.dev>
To: cai.huoqing@linux.dev
Cc: Thomas Graf <tgraf@suug.ch>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] rhashtable-test: Make use of rhashtable_walk_peek
Date: Tue, 25 Apr 2023 21:56:17 +0800	[thread overview]
Message-ID: <20230425135617.77907-1-cai.huoqing@linux.dev> (raw)

Add an example usage of rhashtable_walk_peek to test_bucket_stats.

Signed-off-by: Cai Huoqing <cai.huoqing@linux.dev>
---
 lib/test_rhashtable.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/test_rhashtable.c b/lib/test_rhashtable.c
index c20f6cb4bf55..b1c3316b9bde 100644
--- a/lib/test_rhashtable.c
+++ b/lib/test_rhashtable.c
@@ -177,6 +177,7 @@ static void test_bucket_stats(struct rhashtable *ht, unsigned int entries)
 	unsigned int total = 0, chain_len = 0;
 	struct rhashtable_iter hti;
 	struct rhash_head *pos;
+	struct test_obj *obj;
 
 	rhashtable_walk_enter(ht, &hti);
 	rhashtable_walk_start(&hti);
@@ -192,6 +193,13 @@ static void test_bucket_stats(struct rhashtable *ht, unsigned int entries)
 			break;
 		}
 
+		/* Here's an example usage of rhashtable_walk_peek */
+		obj = rhashtable_walk_peek(&hti);
+		if (!obj) {
+			pr_warn("Test failed: rhashtable_walk_peek() error\n");
+			break;
+		}
+
 		total++;
 	}
 
-- 
2.34.1


             reply	other threads:[~2023-04-25 13:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-25 13:56 Cai Huoqing [this message]
2023-05-03 10:15 ` Herbert Xu

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=20230425135617.77907-1-cai.huoqing@linux.dev \
    --to=cai.huoqing@linux.dev \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tgraf@suug.ch \
    /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®