* [PATCH v3 6/7] initramfs: Use mutable list iterator
@ 2026-06-22 4:32 Kaitao Cheng
0 siblings, 0 replies; 2+ messages in thread
From: Kaitao Cheng @ 2026-06-22 4:32 UTC (permalink / raw)
To: Alexander Viro, Christian Brauner, Jan Kara
Cc: linux-fsdevel, linux-kernel, Kaitao Cheng
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH v3 6/7] initramfs: Use mutable list iterator
2026-06-22 4:05 [PATCH v3 0/7] Prepare mutable list iterators to cache cursor state Kaitao Cheng
@ 2026-06-22 4:39 ` Kaitao Cheng
0 siblings, 0 replies; 2+ messages in thread
From: Kaitao Cheng @ 2026-06-22 4:39 UTC (permalink / raw)
To: Alexander Viro, Christian Brauner, Jan Kara
Cc: linux-fsdevel, linux-kernel, Kaitao Cheng
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-22 4:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-22 4:32 [PATCH v3 6/7] initramfs: Use mutable list iterator Kaitao Cheng
-- 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
powered by JetHome