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:32:10 +0800 [thread overview]
Message-ID: <20260622043210.32069-1-kaitao.cheng@linux.dev> (raw)
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
next reply other threads:[~2026-06-22 4:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-22 4:32 Kaitao Cheng [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-06-22 4:05 [PATCH v3 0/7] Prepare mutable list iterators to cache cursor state Kaitao Cheng
2026-06-22 4:39 ` [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=20260622043210.32069-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox