This avoids the theoretical possibility of integer overflow in
adding a constant before dividing in order to get the effect of
rounding up. Instead we divide and add 1 if the original value modulo
the divisor is non-zero.
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
}
else if (!strncmp(end,"cps",3)) end += 3;
else if (!strncmp(end,"bps",3)) {
- rate = (rate+(up ? 8*ATM_CELL_PAYLOAD-1 : 0))/8/
- ATM_CELL_PAYLOAD;
+ if (up && rate % (8 * ATM_CELL_PAYLOAD) == 0)
+ up = 0;
+ rate = rate / (8 * ATM_CELL_PAYLOAD) + !!up;
end += 3;
}
else if (multiplier) return RATE_ERROR;