...
Code Block |
---|
|
#include <limits.h>
void func(signed long s_a, signed long s_b) {
signed long result;
if ((s_a == LONG_MIN) && (s_b == -1)) {
/* Handle error */
} else {
signed long result = s_a / s_b;
}
/* ... */
} |
...
Code Block |
---|
|
#include <limits.h>
void func(signed long s_a, signed long s_b) {
signed long result;
if ((s_b == 0) || ((s_a == LONG_MIN) && (s_b == -1))) {
/* Handle error */
} else {
result = s_a / s_b;
}
/* ... */
} |
Remainder
The remainder operator provides the remainder when two operands of integer type are divided.
...
Code Block |
---|
|
#include <limits.h>
void func(signed long s_a, signed long s_b) {
signed long result;
if ((s_a == LONG_MIN) && (s_b == -1)) {
/* Handle error */
} else {
signed long result = s_a % s_b;
}
/* ... */
} |
...
Code Block |
---|
|
#include <limits.h>
void func(signed long s_a, signed long s_b) {
signed long result;
if ((s_b == 0 ) || ((s_a == LONG_MIN) && (s_b == -1))) {
/* Handle error */
} else {
result = s_a % s_b;
}
/* ... */
} |
Risk Assessment
...