check_sub_overflow(9)
π check_sub_overflow(9)
okay bestie so you're in the Kernel API Manual and you clicked on check_sub_overflow β welcome, you're gonna do great, this one's actually iconic β¨
πΈ NAME
check_sub_overflow β does subtraction, but like... with overflow checking π
β¨ SYNOPSIS
check_sub_overflow (a , b , d );
π¦ ARGUMENTS
aβ the minuend; it's the value you're subtracting from π«Άbβ the subtrahend; the value you're taking away froma, no capdβ a pointer, and it's where the difference gets stored πΎ
π DESCRIPTION
So it literally returns true on wrap-around and false otherwise. That's the whole vibe check π₯
And here's the part that matters, bestie: *d holds the results of the attempted subtraction, regardless of whether wrap-around occurred. Like, even if things went sideways, the answer still lands in *d. She doesn't gatekeep ππ
π SEE ALSO
The kernel file ./include/linux/overflow.h β go say hi, she's the source of truth πβ¨
Then the whole friend group:
check_add_overflow(9)wrapping_add(9)wrapping_assign_add(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_add(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)
okay that's the whole page, you ate that π this one lives in ./include/linux, dated October 2026, and it's filed under check_sub_overflow(9) β mwah, go write some overflow-safe code, i'm obsessed ππ§
π¦ 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