clamp_val(9)
π NAME π
okay so bestie, meet clamp_val(9) from the Kernel API Manual β it's the macro that will return a value clamped to a given range using val's type. periodt π
β¨ SYNOPSIS β¨
clamp_val (val , lo , hi );
π ARGUMENTS π
valβ current value, the main character here.loβ minimum allowable value.hiβ maximum allowable value.
π¦ DESCRIPTION π¦
Okay so real talk: this macro does no typechecking β not a single vibe check, bestie π. It uses temporary variables of whatever type the input argument val is. That's the lowkey slay: it's useful when val is an unsigned type and lo and hi are literals that will otherwise be assigned a signed integer type. fr fr, that's the whole tea π«Ά.
π SEE ALSO π
Kernel file ./include/linux/minmax.h, plus the whole squad: min(9), max(9), umin(9), umax(9), min3(9), max3(9), min_t(9), max_t(9), min_not_zero(9), clamp(9), clamp_t(9), min_array(9), max_array(9), in_range(9), swap(9). iykyk β¨
And that's the page, bestie π β this one's hanging out under ./include/linux, dated October 2026, and it signs off as clamp_val(9). iconic ππ
π¦ 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