All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kaitao Cheng <kaitao.cheng@linux.dev>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Kaitao Cheng <chengkaitao@kylinos.cn>
Subject: [PATCH v3 6/7] initramfs: Use mutable list iterator
Date: Mon, 22 Jun 2026 12:39:13 +0800	[thread overview]
Message-ID: <20260622043913.32612-1-kaitao.cheng@linux.dev> (raw)
In-Reply-To: <20260622040533.29824-1-kaitao.cheng@linux.dev>

From: Kaitao Cheng <chengkaitao@kylinos.cn>

The safe list iterator in dir_utime() requires a temporary cursor even
though the loop body only deletes and frees the current entry.  The
mutable iterator keeps the same removal-safe traversal semantics while
hiding the internal cursor from the call site.

Switch dir_utime() to list_for_each_entry_mutable() and drop the unused
temporary cursor variable.  No functional change is intended.

Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn>
---
 init/initramfs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/init/initramfs.c b/init/initramfs.c
index 20a18fcda48e..e226d7eb1257 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -167,8 +167,9 @@ static void __init dir_add(const char *name, size_t nlen, time64_t mtime)
 
 static void __init dir_utime(void)
 {
-	struct dir_entry *de, *tmp;
-	list_for_each_entry_safe(de, tmp, &dir_list, list) {
+	struct dir_entry *de;
+
+	list_for_each_entry_mutable(de, &dir_list, list) {
 		list_del(&de->list);
 		do_utime(de->name, de->mtime);
 		kfree(de);
-- 
2.43.0


  parent reply	other threads:[~2026-06-22  4:40 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-22  4:05 [PATCH v3 0/7] Prepare mutable list iterators to cache cursor state Kaitao Cheng
2026-06-22  4:05 ` [PATCH v3 1/7] list: Add mutable iterator variants Kaitao Cheng
2026-06-22  8:42   ` David Laight
2026-06-22  8:51   ` Christian König
2026-06-22  4:05 ` [PATCH v3 2/7] llist: " Kaitao Cheng
2026-06-22  4:15 ` [PATCH v3 3/7] mm: Use mutable list iterators Kaitao Cheng
2026-06-22  4:57   ` sashiko-bot
2026-06-22  4:28 ` [PATCH v3 5/7] kernel: " Kaitao Cheng
2026-06-22  5:22   ` bot+bpf-ci
2026-06-22  5:22     ` bot+bpf-ci
2026-06-22  4:39 ` Kaitao Cheng [this message]
2026-06-22  4:41 ` [PATCH v3 7/7] io_uring: " Kaitao Cheng
2026-06-22  4:42 ` [PATCH v3 4/7] block: " Kaitao Cheng
2026-06-22  5:28 ` [PATCH v3 0/7] Prepare mutable list iterators to cache cursor state Alexei Starovoitov
2026-06-22  6:15   ` Kaitao Cheng
2026-06-22 10:46     ` Andy Shevchenko
2026-06-22 11:27   ` David Hildenbrand (Arm)
2026-06-22  8:37 ` Jani Nikula
  -- strict thread matches above, loose matches on Subject: below --
2026-06-22  4:32 [PATCH v3 6/7] initramfs: Use mutable list iterator Kaitao Cheng

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=20260622043913.32612-1-kaitao.cheng@linux.dev \
    --to=kaitao.cheng@linux.dev \
    --cc=brauner@kernel.org \
    --cc=chengkaitao@kylinos.cn \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.