kstrtoint(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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. if base is 0, then the base gets auto-detected with the conventional semantics: if the string begins with 0x the number is parsed as hexadecimal (case insensitive, so 0x and 0X are both fine πŸ’…), and if it otherwise begins with 0 it'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 πŸ¦‹

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