check_sub_overflow(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 from a, no cap
  • d β€” 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:


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