CID 716906: Division or modulo by zero (DIVIDE_BY_ZERO)
At (214): In expression "(float)weight[i] / (float)total_weight", division by expression "total_weight" which may be zero has undefined behavior.
Signed-off-by: Sage Weil <sage@inktank.com>
// get the total weight of the system
int total_weight = 0;
-
for (unsigned i = 0; i < per.size(); i++)
total_weight += weight[i];
+ if (total_weight == 0)
+ continue;
+
// compute the expected number of objects stored per device in the absence of weighting
float expected_objects = min(nr, get_maximum_affected_by_rule(r)) * num_objects;