mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 1/3] test: self: idr: add test for idr_remove in idr_for_each_entry
Date: Mon, 23 Jun 2025 08:26:39 +0200	[thread overview]
Message-ID: <20250623062641.3529615-2-a.fatoum@barebox.org> (raw)
In-Reply-To: <20250623062641.3529615-1-a.fatoum@barebox.org>

If we have had this test earlier, it would have caught that
idr_for_each_entry didn't guarantee safe iteration while freeing.

Add a test, so we may catach future issues of this sort.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 test/self/idr.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/test/self/idr.c b/test/self/idr.c
index cc3217bb06e4..bc68a84be4ce 100644
--- a/test/self/idr.c
+++ b/test/self/idr.c
@@ -73,9 +73,17 @@ static void test_idr(void)
 	id = idr_alloc_one(&idr, &cmp[2], cmp[2]);
 	expect(id == cmp[2]);
 
+	id = idr_alloc_one(&idr, NULL, 4);
+	expect(id == 4);
+
 	count = 0;
 
 	idr_for_each_entry(&idr, ptr, id) {
+		if (id == 4) {
+			idr_remove(&idr, 4);
+			continue;
+		}
+
 		expect(id  ==  sorted_cmp[count]);
 		expect(*(int *)ptr == sorted_cmp[count]);
 
-- 
2.39.5




  reply	other threads:[~2025-06-23  6:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-23  6:26 [PATCH 0/3] test: test recent regressions/features Ahmad Fatoum
2025-06-23  6:26 ` Ahmad Fatoum [this message]
2025-06-23  6:26 ` [PATCH 2/3] test: py: test mount/unmount of pstore file system Ahmad Fatoum
2025-06-23  8:37   ` Ahmad Fatoum
2025-06-23  9:26     ` Sascha Hauer
2025-06-23  6:26 ` [PATCH 3/3] test: py: add bootchooser attempt decrement and locking test Ahmad Fatoum
2025-06-23  8:35 ` [PATCH 0/3] test: test recent regressions/features Sascha Hauer

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=20250623062641.3529615-2-a.fatoum@barebox.org \
    --to=a.fatoum@barebox.org \
    --cc=barebox@lists.infradead.org \
    /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