match_hex(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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 β€” the substring_t to 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