]> git.ozlabs.org Git - ccan/blobdiff - ccan/tally/tally.c
tally: Adapt fls64 to Samba coding conventions
[ccan] / ccan / tally / tally.c
index 4c5e37e9e05d9eb256569573863e8e18714430be..4e8876cc4aa5e2874fa83c1b341783e9811d0927 100644 (file)
@@ -138,15 +138,17 @@ void tally_add(struct tally *tally, ssize_t val)
                new_max = val;
                need_renormalize = true;
        }
-       if (need_renormalize)
+       if (need_renormalize) {
                renormalize(tally, new_min, new_max);
+       }
 
        /* 128-bit arithmetic!  If we didn't want exact mean, we could just
         * pull it out of counts. */
-       if (val > 0 && tally->total[0] + val < tally->total[0])
+       if (val > 0 && tally->total[0] + val < tally->total[0]) {
                tally->total[1]++;
-       else if (val < 0 && tally->total[0] + val > tally->total[0])
+       } else if (val < 0 && tally->total[0] + val > tally->total[0]) {
                tally->total[1]--;
+       }
        tally->total[0] += val;
        tally->counts[bucket_of(tally->min, tally->step_bits, val)]++;
 }
@@ -154,8 +156,9 @@ void tally_add(struct tally *tally, ssize_t val)
 size_t tally_num(const struct tally *tally)
 {
        size_t i, num = 0;
-       for (i = 0; i < tally->buckets; i++)
+       for (i = 0; i < tally->buckets; i++) {
                num += tally->counts[i];
+       }
        return num;
 }
 
@@ -180,8 +183,9 @@ static unsigned fls64(uint64_t val)
 #endif
        uint64_t r = 64;
 
-       if (!val)
+       if (!val) {
                return 0;
+       }
        if (!(val & 0xffffffff00000000ull)) {
                val <<= 32;
                r -= 32;