check_add_overflow(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– check_add_overflow(9) β€” the kernel API manual, but make it make sense

okay so bestie, welcome to the check_add_overflow page of the Kernel API Manual ✨ this one is short, sweet, and honestly kind of iconic. it does exactly one thing and it does it well. let's get into it 🫢


🌸 NAME

check_add_overflow β€” calculate addition with overflow checking πŸ’…

like, it adds two things and it also tells you if the addition went sideways. multitasking queen behavior.


✨ SYNOPSIS

check_add_overflow (a , b , d );

that's it. three little args. no cap. πŸŽ€


πŸ¦‹ ARGUMENTS

  • a β€” first addend 🌸 (the first number going into the addition, bestie)
  • b β€” second addend πŸ’– (the other number, obviously)
  • d β€” pointer to store sum ✨ (not the sum itself! a pointer to where the sum lives. do not come for me about it)

πŸ”₯ DESCRIPTION

Returns true on wrap-around, false otherwise. literally that's the whole personality πŸ’€

and here's the part you cannot skip, so pay attention:

*d holds the results of the attempted addition, regardless of whether wrap-around occurred.

like. even if the addition wrapped around and everything went to chaos, *d still gets written. so don't go thinking "oh it returned true so *d is garbage" β€” nope, *d is populated either way, and it's on you to check the return value. main character responsibility 🧚


πŸ‘‘ SEE ALSO

okay this is the part where the whole friend group shows up. all of these live in the kernel file ./include/linux/overflow.h and honestly the roster is giving family reunion 🌈

every single one of them, no skips, no cuts, we support the whole squad πŸ’œ


quick vibe check reminder: this is the checking variant. it tells you about the wrap-around. if you just want the wrap-around with no questions asked, that's what the wrapping_* crew is for. iykyk 😌

and that's the page, bestie πŸŽ€ this came from the ./include/linux corner of the source tree, dated October 2026, and it's filed under check_add_overflow(9) β€” go forth and check your overflows, you gorgeous little integer wrangler πŸ¦‹πŸ’…

πŸ“¦ where this page comes from