homed: drop unnecessary cast to double

Coverity was complaining that we we're doing a integer division and then
casting that to double. This was OK, but it was also a bit pointless.
An operation on a double and unsigned promoted the unsigned to a double,
so it's enough if we have a double somewhere as an argument early enough.
Drop noop casts and parens to make the formulas easier to read.

CID#1466459
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-04-11 14:58:34 +02:00
parent efbd8a26d6
commit 3fac59557c
+3 -3
View File
@@ -1889,10 +1889,10 @@ static int manager_rebalance_calculate(Manager *m) {
assert(h->rebalance_usage <= usage_sum);
assert(h->rebalance_weight <= weight_sum);
d = ((double) (free_sum / 4096.0) * (double) h->rebalance_weight) / (double) weight_sum; /* Calculate new space for this home in units of 4K */
d = free_sum / 4096.0 * h->rebalance_weight / weight_sum; /* Calculate new space for this home in units of 4K */
/* Convert from units of 4K back to bytes */
if (d >= (double) (UINT64_MAX/4096))
if (d >= UINT64_MAX / 4096)
new_free = UINT64_MAX;
else
new_free = (uint64_t) d * 4096;
@@ -1928,7 +1928,7 @@ static int manager_rebalance_calculate(Manager *m) {
h->rebalance_pending = true;
}
if ((fabs((double) h->rebalance_size - (double) h->rebalance_goal) * 100 / (double) h->rebalance_size) >= 5.0)
if (ABS_DIFF(h->rebalance_size, h->rebalance_goal) * 100.0 / h->rebalance_size >= 5.0)
relevant = true;
}