You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Manvendra Bhangui edited this page Feb 25, 2024
·
4 revisions
NAME
add_of - add two integers, check for arithmetic overflow
SYNTAX
#include <rangecheck.h>
int add_of(dest,a,b);
DESCRIPTION
If calculating a+b is possible without causing undefined behavior or an
arithmetic overflow in C, and the sum fits into the destination integer
type, do dest=a+b and return 0.
Otherwise, return 1.
Note: This is a macro, so dest does not have to be a pointer.
BUGS
In the multiplication functions, a return value of 1 signals success and
0 failure. In add_of, sub_of and assign it's the other way around.