clamp_val(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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