size_mul(9)
β¨ size_mul(9) β¨
okay so bestie, this one is from the Kernel API Manual and it's genuinely such a little icon π β it's all about multiplying two sizes together without letting things get out of hand.
πΈ NAME πΈ
size_mul β calculates a size_t multiplication, saturating at SIZE_MAX π
π¦ SYNOPSIS π¦
size_t size_mul (size_t factor1 , size_t factor2 );
π ARGUMENTS π
factor1β the first factor, bestie πΈfactor2β the second factor, obviously π
β RETURN β
So it calculates factor1 * factor2, with both of them promoted to size_t, and likeβ¦ if any overflow happens, the return value becomes SIZE_MAX instead. No cap, it just caps out. π
Also lowkey important: the lvalue must be size_t so you don't get any implicit type conversion sneaking in. Don't do it, bestie β type conversion jumpscare π
π SEE ALSO π
Kernel file ./tools/include/linux/overflow.h, plus these iconic siblings: array_size(9), array3_size(9), struct_size(9) π«Ά
and that's the whole vibe, fr fr β¨ this page came from ./tools/include/linux, dated October 2026 β slay, go forth and multiply (safely) ππ
π¦ 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