kstrtouint(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ NAME ✨

kstrtouint β€” convert a string to an unsigned int. This is the kstrtouint(9) page from the Kernel API Manual, and bestie, we are literally turning a string into an unsigned int. Main character conversion energy βœ¨πŸ’…

πŸŽ€ SYNOPSIS πŸŽ€

Here’s the exact signature, no edits, no cap:

int kstrtouint (const char *s , unsigned int base , unsigned int *res );

🌸 ARGUMENTS 🌸

  • s β€” the start of the string. It must be null-terminated, and it may also include a single newline before its terminating null. The first character may also be a plus sign, but not a minus sign.
🚨 Caveat check: plus sign? allowed. Minus sign? not allowed. Periodt.
  • base β€” the number base to use. The maximum supported base is 16. If base is given as 0, then the base of the string is automatically detected with the conventional semantics: if it begins with 0x, the number will be parsed as hexadecimal (case insensitive); if it otherwise begins with 0, it will be parsed as an octal number; otherwise it will be parsed as a decimal.
  • res β€” where to write the result of the conversion on success. That’s the output spot, bestie 🎯

πŸ’… DESCRIPTION πŸ’…

Returns 0 on success, -ERANGE on overflow, and -EINVAL on parsing error. It’s preferred over simple_strtoul. The return code must be checked.

😭 Do not ghost that return code. Check it. Fr fr. The return code must be checked β€” that part is not a vibe suggestion.

πŸ”₯ SEE ALSO πŸ”₯

Kernel file ./lib/kstrtox.c, plus these iconic little references:


mwah πŸ’‹ source/version: ./lib, date: October 2026, page: kstrtouint(9). Bye bestie, go check that return code 🫢✨

πŸ“¦ where this page comes from