__set_flex_counter(9)
π
__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 checkCOUNTwithoverflows_flex_counter_typebefore you use this function. Not optional, bestie. Check first, set second, that's the order.overflows_flex_counter_typeis 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) π§
overflows_type(9)range_overflows(9)range_overflows_t(9)range_end_overflows(9)range_end_overflows_t(9)castable_to_type(9)
Sizing it up π
size_mul(9)size_add(9)size_sub(9)array_size(9)array3_size(9)flex_array_size(9)struct_size(9)struct_size_t(9)struct_offset(9)
Flex array family reunion π
__DEFINE_FLEX(9)_DEFINE_FLEX(9)DEFINE_RAW_FLEX(9)DEFINE_FLEX(9)STACK_FLEX_ARRAY_SIZE(9)typeof_flex_counter(9)overflows_flex_counter_type(9)
π 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
- 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