list_for_each_entry_safe(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 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 β€” the type * to use as a loop cursor. This is your main-character pointer that keeps track of where you are in the loop. ✨
  • n β€” another type * 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 the list_head within 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: πŸ’¬


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