initramfs: Use mutable list iterator
PATCH v3 6/7 initramfs: Use mutable list iterator
From: Kaitao Cheng <[email protected]>
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 <[email protected]>
--- init/initramfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
init/initramfs.c +3 -2
@@ -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);
Signature · 1 line
2.43.0