list_last_entry(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’« list_last_entry(9) πŸ’«

okay bestie, welcome to the list_last_entry page from the Kernel API Manual (that's the manual name, no cap, we're in the kernel docs now πŸŽ€). this one's short and sweet and honestly kind of iconic.


✨ NAME ✨

list_last_entry β€” get the last element from a list πŸ₯°

like, the last one. the final girl. the one at the end of the conga line. periodt.


🌸 SYNOPSIS 🌸

list_last_entry (ptr , type , member );

that's it. that's the whole vibe. three little args and you're slaying πŸ’… (and yes, the spaces are exactly like that, don't @ me, that's how it's written).


πŸ¦‹ ARGUMENTS πŸ¦‹

  • ptr β€” the list head you're taking the element from. it's giving "start here but actually end there" energy ngl.
  • type β€” the type of the struct this whole thing is embedded in. so like, the actual struct type, not the list_head itself, iykyk.
  • member β€” the name of the list_head within the struct. the little list handle hiding inside your big struct 🫢.

πŸ’– DESCRIPTION πŸ’–

so the whole point: it gives you the last element of the list, converted back into your struct type. super handy, main character macro behavior honestly.

⚠️ okay this is the important part, listen up bestie: note, that list is expected to be not empty. 🚨

like, the docs literally say it. if you call this on an empty list, that's on you and it's not gonna be cute. do a vibe check (list_empty(9), it's right there in SEE ALSO) before you commit, fr fr. 😭


πŸ”₯ SEE ALSO πŸ”₯

kernel file ./tools/include/linux/list.h β€” and literally the entire list family, they're all here, the whole friend group 🫢:

that's 44 entries bestie, I counted, they all had to be here, no skipping the "boring" ones in this house πŸ’€βœ¨


and that's the whole page!! mwah πŸ’‹ this one came from ./tools/include/linux and it's dated October 2026 β€” so like, future vibes only 🌈⭐ go forth and grab your last element, but check it's not empty first, I'm begging πŸ™ˆπŸ’œ

πŸ“¦ where this page comes from