ssize_t min, max;
min = bucket_min(tally->min, tally->step_bits, b);
- if (b == tally->buckets - 1)
+ if (b == tally->buckets - 1) {
max = tally->max;
- else
+ } else {
max = bucket_min(tally->min, tally->step_bits, b+1) - 1;
+ }
/* FIXME: Think harder about cumulative error; is this enough?. */
*err = (max - min + 1) / 2;
for (i = 0; i < tally->buckets; i++) {
total += tally->counts[i];
- if (total * 2 >= count)
+ if (total * 2 >= count) {
break;
+ }
}
return bucket_range(tally, i, err);
}
{
unsigned int i;
- for (i = tally->buckets; i > 0; i--)
- if (tally->counts[i-1])
+ for (i = tally->buckets; i > 0; i--) {
+ if (tally->counts[i-1]) {
break;
+ }
+ }
return i;
}