size_add(9)
π NAME π
okay so welcome to size_add(9) from the Kernel API Manual β the saturation queen of size_t addition π
β¨. This page is literally about calculating size_t addition with saturation at SIZE_MAX. bestie, itβs giving βmath but make it kernel-safe.β π«Ά
πΈ SYNOPSIS πΈ
the whole flex is:
size_t size_add (size_t addend1 , size_t addend2 );
π ARGUMENTS π
addend1β the first addend. literally the first number going in. πaddend2β the second addend. the other one. π
β¨ RETURN β¨
It calculates addend1 + addend2, with both promoted to size_t, and any overflow causes the return value to be SIZE_MAX. slay, no cap. π₯
β οΈ Important caveat: the lvalue must be size_t to avoid implicit type conversion. do not get cute with a smaller type, okay? thatβs the rule, periodt. π
π¦ SEE ALSO π¦
bestie, the whole overflow.h friend group is right here in the kernel file ./include/linux/overflow.h β go say hi:
check_add_overflow(9)wrapping_add(9)wrapping_assign_add(9)check_sub_overflow(9)wrapping_sub(9)wrapping_assign_sub(9)check_mul_overflow(9)wrapping_mul(9)check_shl_overflow(9)overflows_type(9)range_overflows(9)range_overflows_t(9)range_end_overflows(9)range_end_overflows_t(9)castable_to_type(9)size_mul(9)size_sub(9)array_size(9)array3_size(9)flex_array_size(9)struct_size(9)struct_size_t(9)struct_offset(9)__DEFINE_FLEX(9)_DEFINE_FLEX(9)DEFINE_RAW_FLEX(9)DEFINE_FLEX(9)STACK_FLEX_ARRAY_SIZE(9)typeof_flex_counter(9)overflows_flex_counter_type(9)__set_flex_counter(9)
sign-off realness: this page is chillinβ in source ./include/linux, version Kernel API Manual, dated October 2026, and itβs serving size_add(9). bye bestie π
β¨π¦
π¦ 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