list_last_entry(9)
π« 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 thelist_headitself, iykyk.memberβ the name of thelist_headwithin 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 π«Ά:
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_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(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)
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
- 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