list_first_entry(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… list_first_entry (Kernel API Manual energy) πŸ’…

okay so real talk β€” this little icon lives in the Kernel API Manual, and she's the one you call when you need the actual first element out of a list, not just the boring list head. main character of the list traversal world, honestly. πŸŽ€


✨ NAME ✨

list_first_entry β€” get the first element from a list. that's it, that's the whole job, and she does it flawlessly. πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

list_first_entry (ptr , type , member );

🌸 ARGUMENTS 🌸

  • ptr β€” the list head you're taking the element from. your starting point, your origin story, your where it all begins. πŸ“
  • type β€” the type of the struct this is embedded in. yes, the whole big struct, not just the tiny list bit. she needs to know what she's working with. πŸ’β€β™€οΈ
  • member β€” the name of the list_head within the struct. the lil field name that tells her exactly where to look. iykyk. πŸ”

πŸ’– DESCRIPTION πŸ’–

so basically: hand her a list head, tell her the struct type, tell her which member is the list_head, and she hands you back the first entry. slay. no cap, that's the whole vibe. ✨

⚠️ okay bestie, important caveat time: note, that list is expected to be not empty. like, that's the stated expectation, fr fr. so do your vibe check before you call her, mmkay? πŸ™ˆ

🌈 SEE ALSO 🌈

kernel file ./tools/include/linux/list.h β€” and literally the entire friend group, because she does not travel alone:

like, the whole group chat showed up. obsessed. πŸ’œ


🫢 mwah, that's a wrap! this page comes to you straight out of ./tools/include/linux, dated October 2026 β€” so she's fresh, she's iconic, and she's ready when you are. go get that first element, bestie πŸ’…βœ¨

πŸ“¦ where this page comes from