xas_next(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’« xas_next(9) πŸ’«

okay bestie, welcome to the Kernel API Manual β€” yes that manual, the one that lives in the kernel source tree, and today's main character is xas_next. she's a tiny function with one (1) job and honestly she ate πŸ’…


✨ NAME ✨

xas_next β€” move state to next index. that's it. that's the whole vibe. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

void * xas_next (struct xa_state *xas );

literally one argument, no cap. copy it exactly like that, spacing and all, she's picky πŸ™ˆ


🌸 ARGUMENTS 🌸

  • xas β€” the XArray operation state. that's the little state blob you're carrying around while you walk the array. she's the passenger princess of this whole operation ✨

πŸ‘‘ DESCRIPTION πŸ‘‘

okay so here's the tea, and it's actually important so listen up πŸ“

If the xas was already in an error state, it stays in that error state β€” like, she's not recovering, she's not bouncing back β€” and this function returns NULL. periodt. no notes.

If the xas has never been walked, then calling this has the effect of calling xas_load. so you get the load behaviour instead of a "next" behaviour. surprise! 🎁

Otherwise β€” and this is the normal case, the main character case β€” one gets added to the index, and the state gets walked to the correct location in the array ready for the next operation. she just scoots forward one slot, gracefully, like a queen πŸ‘‘

⚠️ heads up bestie: if the iterator was referencing index ULONG_MAX, this function wraps around to 0. so yeah, she loops back to the very beginning. don't be weirded out when you suddenly see index zero again, it's literally by design πŸ”₯

πŸ’– RETURN πŸ’–

The entry at the new index. this may be NULL or an internal entry. so like... don't assume it's a real pointer to a real thing, okay? internal entries exist and they're valid, she's just built different 😭


🌈 SEE ALSO 🌈

okay this list is LONG but every single one of them matters, so buckle up buttercup 🫢

Kernel file ./include/linux/xarray.h, plus:

the value helpers:

the types and macros:

init + introspection:

iteration (the for_each girlies):

storing + erasing:

compare-and-swap:

inserting:

allocating:

reserving + releasing:

more little predicates:

the state macros:

error + validity handling:

state management:

walking it forward + iteration:


πŸ’€ one more thing before you go: this page ships out of ./include/linux, dated October 2026, and it's xas_next(9) all the way down. that's the source and the date, bestie, delivered with love πŸ§šπŸ’œ

go forth and walk that array, icon 🌟 you've got this fr fr ✨

πŸ“¦ where this page comes from