kstrtobool(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– kstrtobool(9) β€” the kernel API manual, bestie edition πŸ’–

okay so real talk, this one is a kstrtobool(9) situation and it's literally the most useful little gremlin in ./lib β€” it takes whatever chaos a user typed and turns it into a clean lil bool. no cap, it's giving "translator for the group chat". πŸ¦‹


✨ SYNOPSIS ✨

int kstrtobool (const char *s , bool *res );

like, that's it. that's the whole vibe. πŸŽ€


🌸 ARGUMENTS 🌸

  • s β€” the input string, aka whatever unhinged text the user handed you. the star of the show, main character energy fr.
  • res β€” the result. this is where the answer lands, so bestie better be pointing somewhere real. 🫢

πŸ”₯ DESCRIPTION πŸ”₯

okay so here's the tea β˜• β€” this routine returns 0 if and only if the first character is one of:

'EeYyTt1DdNnFf0'

...or it's [oO][NnFf] for "on" and "off". so yes, it's out here accepting y, Y, e, E, t, T, 1, d, D, n, N, f, F, 0, and the whole on/off duo β€” iconic, honestly. πŸ’…

Otherwise it will return -EINVAL. no match, no mercy. πŸ’€

and the value pointed to by res gets updated upon finding a match β€” so like, the moment it vibes with your input, it writes the result through the pointer. slay. ✨

ngl, notice it says first character β€” so it's checking the start of the string, not doing a deep read of the whole thing. don't come for me, that's just what the page says. πŸ™ˆ

πŸ‘‘ SEE ALSO πŸ‘‘

the whole kstrto* friend group is there, go say hi. 🌈


and that's the whole page, bestie β€” brought to you straight outta ./lib, dated October 2026, in the Kernel API Manual. mwah, go forth and convert those booleans πŸ’‹β­πŸ“

πŸ“¦ where this page comes from