kstrtoint(9)
π kstrtoint π
okay so bestie, welcome to the kstrtoint(9) glow-up β this is a Kernel API Manual page and it's literally about turning a string into an int. that's it. that's the whole vibe. let's get into it π«Ά
β¨ SYNOPSIS β¨
int kstrtoint (const char *s , unsigned int base , int *res );
like, that's the whole signature. three args. no cap. π
π ARGUMENTS π
sβ the start of the string, bestie. and it must be null-terminated, okay? it may also have a single newline before that terminating null (one newline. not two. don't be messy π). and the first character is also allowed to be a plus sign or a minus sign, so+and-are both valid openers here.baseβ the number base to use, and the maximum supported base is 16. ifbaseis0, then the base gets auto-detected with the conventional semantics: if the string begins with0xthe number is parsed as hexadecimal (case insensitive, so0xand0Xare both fine π ), and if it otherwise begins with0it's parsed as an octal number. otherwise? plain old decimal. slay.resβ where the result of the conversion gets written on success. like, that's the destination, that's where it lives now π
πΈ DESCRIPTION πΈ
okay so the return value story: it returns 0 on success, -ERANGE on overflow, and -EINVAL on a parsing error. three outcomes, three moods π
it's preferred over simple_strtol β highkey the upgrade. and hear me loud and clear: the return code must be checked. not optional. not a suggestion. check it. fr fr.
bestie if you skip the return check i will personally find you π
π¦ SEE ALSO π¦
- Kernel file
./lib/kstrtox.c _parse_integer_limit(9)kstrtoull(9)kstrtoll(9)kstrtouint(9)kstrtobool(9)kstrtoudec64(9)kstrtodec64(9)
go read the siblings. they're all iconic in their own way β¨
mwah π this page came from ./lib, dated October 2026, and it's filed under kstrtoint(9) β take care of it, check your return codes, and stan kernel documentation responsibly πβ¨
π¦ 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