list_first_entry(9)
π 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 thelist_headwithin 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:
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_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(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)
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
- 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