__set_flex_counter(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… __set_flex_counter(9) β€” like, the kernel's set function for your flexible-array counters

Hey bestie, welcome to the kernel API manual ✨ (9 = kernel API section, iykyk). Today's main character is __set_flex_counter, and honestly? She's the quiet one who just does her job and dips. 🫢


✨ NAME ✨

__set_flex_counter β€” sets the counter that goes with a given flexible array member, the one that's been annotated by __counted_by(). That's it, that's the whole vibe. πŸŽ€


🌸 SYNOPSIS 🌸

__set_flex_counter (FAM , COUNT );

Yes, the spacing looks like that. No she's not going to fix it. It's iconic. πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • FAM β€” an instance of a flexible array member, living inside some struct. You know, that member at the end of the struct. πŸ‘‘
  • COUNT β€” the value you want to store into the counter of the __counted_by-annotated FAM's pointer. So like, the number goes here. πŸ“

πŸ’– DESCRIPTION πŸ’–

Okay so here's the tea β˜•: this whole thing is a no-op if there's no annotation. Nothing happens. She ghosts you. Incredibly valid of her.

⚠️ Real talk though: you must check COUNT with overflows_flex_counter_type before you use this function. Not optional, bestie. Check first, set second, that's the order. overflows_flex_counter_type is literally right there in SEE ALSO. Use her. 😭

πŸ”₯ SEE ALSO πŸ”₯

Everything lives in the Kernel file ./include/linux/overflow.h β€” that's the overflow.h girlies' whole universe, and __set_flex_counter is just one star in that constellation. 🌈

The add squad βž•

The sub squad βž–

The rest of the arithmetic besties ✨

Type + range checkers (vibe check, but for numbers) 🧚

Sizing it up πŸ“

Flex array family reunion πŸ’€


πŸŽ€ the sign-off πŸŽ€

That's the whole page, bestie β€” no notes, no cap. This little legend ships out of ./include/linux, dated October 2026, and she's titled __set_flex_counter(9) because of course she is. Go forth, set your counters, check your overflows, slay. πŸ’œπŸ¦‹βœ¨

πŸ“¦ where this page comes from