match_hex(9)
β¨ match_hex(9) β¨ β from the Kernel API Manual, bestie π
okay so picture this: it's giving "little helper that reads hex out of a string," and honestly? iconic. the function is match_hex, and it lives in section 9 of the Kernel API Manual, which is where all the kernel-functions hang out. π
πΈ NAME πΈ
match_hex β scan a hex representation of an integer from a substring_t
like, it looks at a chunk of string and goes "hmm yes, that's a hex number, let me get that for you" π§
β SYNOPSIS β
int match_hex (substring_t *s , int *result );
two args, one int coming back at you. no cap. π
π¦ ARGUMENTS π¦
sβ thesubstring_tto be scanned, aka the little string-slice main character we're inspecting πresultβ the resulting integer on success, aka where the parsed number gets dropped off π«Ά
π DESCRIPTION π
Attempts to parse the substring_t s as a hexadecimal integer.
that's it, that's the whole vibe. it takes your substring and tries to read it as hex. slay. β¨
π₯ RETURN π₯
On success, it sets result to the integer represented by the string and returns 0. zero means we ate, we devoured, no crumbs. π
on failure it returns -EINVAL or -ERANGE. so like, if it's not valid hex you get -EINVAL, and if the number is out of range you get -ERANGE. both of those are the "nope, not today" answers π
π SEE ALSO π
Kernel file ./lib/parser.c β and honestly the whole parser function fam, they all show up together:
match_one(9), match_token(9), match_number(9), match_u64int(9), match_int(9), match_uint(9), match_u64(9), match_octal(9), match_wildcard(9), match_strlcpy(9), match_strdup(9)
one big happy parser family reunion π
okay that's the whole page, ily, go read some hex ππ
β signed off with love from ./lib, October 2026 edition π
β¨
π¦ 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