]> git.ozlabs.org Git - ccan/blobdiff - ccan/tally/tally.c
tally: Adapt get_max_bucket to Samba coding conventions
[ccan] / ccan / tally / tally.c
index e166dd03c532252df2b0e31ed7d41198f390f88b..b1bc70b8dbeb7350dcfca63767fea4abbee6ef71 100644 (file)
@@ -367,10 +367,11 @@ static ssize_t bucket_range(const struct tally *tally, unsigned b, size_t *err)
        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;
@@ -385,8 +386,9 @@ ssize_t tally_approx_median(const struct tally *tally, size_t *err)
 
        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);
 }
@@ -420,9 +422,11 @@ static unsigned get_max_bucket(const struct tally *tally)
 {
        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;
 }