list_for_each_entry_safe(9)
πΈ NAME πΈ
okay bestie, welcome to the list_for_each_entry_safe(9) page from the Kernel API Manual β yes, the safe list-walker, and she is iconic for a reason. π
list_for_each_entry_safeβ iterate over list of given type safe against removal of list entry.
This is the loop you reach for when you're walking a list of a given type and you need to stay safe against removal of a list entry while you do it. It's giving "I can keep going even when a list entry gets removed," and that's the whole point, no cap. π¦
β¨ SYNOPSIS β¨
list_for_each_entry_safe (pos , n , head , member );
π ARGUMENTS π
posβ thetype *to use as a loop cursor. This is your main-character pointer that keeps track of where you are in the loop. β¨nβ anothertype *to use as temporary storage. bestie, that's literally the whole job β temporary storage. π«Άheadβ the head for your list. The starting point, the queen of the list, periodt. πmemberβ the name of thelist_headwithin the struct. You're telling the macro which field inside your struct is the list glue. π
π¦ SEE ALSO π¦
Kernel file: ./tools/include/linux/list.h β and these are the linked pages, all in the group chat: π¬
list_add(9)list_add_tail(9)list_replace(9)list_del_init(9)list_move(9)list_move_tail(9)list_is_first(9)list_is_last(9)list_empty(9)list_empty_careful(9)list_rotate_left(9)list_is_singular(9)list_cut_position(9)list_splice(9)list_splice_tail(9)list_splice_init(9)list_splice_tail_init(9)list_entry(9)list_first_entry(9)list_last_entry(9)list_first_entry_or_null(9)list_last_entry_or_null(9)list_next_entry(9)list_prev_entry(9)list_for_each(9)list_for_each_prev(9)list_for_each_safe(9)list_for_each_prev_safe(9)list_for_each_entry(9)list_for_each_entry_reverse(9)list_prepare_entry(9)list_for_each_entry_continue(9)list_for_each_entry_continue_reverse(9)list_for_each_entry_from(9)list_for_each_entry_safe_continue(9)list_for_each_entry_safe_from(9)list_for_each_entry_safe_reverse(9)list_safe_reset_next(9)hlist_for_each_entry(9)hlist_for_each_entry_continue(9)hlist_for_each_entry_from(9)hlist_for_each_entry_safe(9)list_del_range(9)list_for_each_from(9)
and that's the whole page, babe. the footer says ./tools/include/linux, October 2026, and list_for_each_entry_safe(9) β catch u in the kernel, mwah πβ¨π«Ά
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms