Fix for:
CID
1247720 (#1 of 1): Unintentional integer overflow
(OVERFLOW_BEFORE_WIDEN)
overflow_before_widen: Potentially overflowing expression
stripe_count * stripe_unit with type unsigned int (32 bits,
unsigned) is evaluated using 32-bit arithmetic before being
used in a context which expects an expression of type
uint64_t (64 bits, unsigned).
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
uint64_t num_periods = (size + period - 1) / period;
uint64_t remainder_bytes = size % period;
uint64_t remainder_objs = 0;
- if ((remainder_bytes > 0) && (remainder_bytes < stripe_count * stripe_unit))
+ if ((remainder_bytes > 0) && (remainder_bytes < (uint64_t)stripe_count * stripe_unit))
remainder_objs = stripe_count - ((remainder_bytes + stripe_unit - 1) / stripe_unit);
return num_periods * stripe_count - remainder_objs;
}