strtoul_lenient(9)
π strtoul_lenient(9) β the kernel API manual, but make it make sense
okay so bestie, welcome to strtoul_lenient, a little function from the Kernel API Manual and honestly? She's iconic for one specific reason: she parses an ASCII formatted integer from a buffer and only fails on overflow. That's it. That's her whole brand. π
β¨ NAME β¨
strtoul_lenient β parse an ASCII formatted integer from a buffer and only fail on overflow
Like, yes, that's literally it. She's lenient (it's in the name, iykyk) and she's not here to judge your weird trailing characters. π¦
πΈ SYNOPSIS πΈ
int strtoul_lenient (const char *cp , char **endp , unsigned int base ,
unsigned long *res );
Look at that signature. Chef's kiss. Four args, one int return, no cap. π
π«Ά ARGUMENTS π«Ά
cpβ the kernel buffer that's holding the string you wanna parse. She lives in the kernel, so yes, kernel buffer, keep up bestie πendpβ a pointer where the trailing characters get stored. So like, whatever's left over after the number? It goes here, and it's your problem now, not hers πbaseβ the base to use. You pick it. She trusts you. (Risky of her, but okay.)resβ the spot where the parsed integer lands. That's the whole point, honestly. β
π§ DESCRIPTION π§
So here's the vibe check: this function will fail the parse on overflow. That's the one thing she's strict about. Overflow? Absolutely not. Not on her watch. π
But if there wasn't an overflow? Then she's fully chill. She will defer the decision of what characters count as invalid to the caller β meaning she hands that judgement call straight back to you. Not her circus, not her monkeys. You decide what's invalid. She's just here to grab the number and go. π
no cap, that's the entire personality: overflow = fail, everything else = your call bestie π«Ά
π RETURN π
0on success β andreswill contain the parsed integer, andendpwill hold any trailing characters. Slay. β¨-ERANGEon overflow. That's the one and only hater in the room. π€
π₯ SEE ALSO π₯
Okay so the friend group is huge, buckle up. From Kernel file ./kernel/sysctl.c we've got enum sysctl_writes_mode(9), proc_first_pos_non_zero_ignore(9), proc_dostring(9), proc_get_long(9), proc_put_long(9), proc_uint_u2k_conv_uop(9), proc_uint_k2u_conv(9), proc_uint_conv(9), proc_int_k2u_conv_kop(9), proc_int_u2k_conv_uop(9), proc_int_conv(9), proc_douintvec_conv(9), proc_dobool(9), proc_dointvec(9), proc_douintvec(9), proc_dointvec_minmax(9), proc_douintvec_minmax(9), proc_dou8vec_minmax(9), proc_ulong_conv(9), proc_ulong_u2k_conv_uop(9), proc_ulong_k2u_conv_kop(9), proc_doulongvec_conv(9), proc_doulongvec_minmax(9), proc_dointvec_conv(9), and proc_do_large_bitmap(9).
That's the whole group chat. Go say hi. π¦π
and that's the page!! sourced from ./kernel, dated October 2026, and it's strtoul_lenient(9) β main character energy from the sysctl universe, periodt π
πβ¨
π¦ 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