]> git.ozlabs.org Git - ccan/blobdiff - ccan/tally/tally.c
tally: Adapt divls64 to Samba coding conventions
[ccan] / ccan / tally / tally.c
index a6d66b6688dc5d6940bfc75596e20d866a098ebd..5602e75017055ae5ce20f71deaf4c80f2db55784 100644 (file)
@@ -231,8 +231,9 @@ static uint64_t divlu64(uint64_t u1, uint64_t u0, uint64_t v)
        uint64_t p;               /* Product of two digits. */
        int64_t s, i, j, t, k;
 
-       if (u1 >= v)              /* If overflow, return the largest */
+       if (u1 >= v) {            /* If overflow, return the largest */
                return (uint64_t)-1; /* possible quotient. */
+       }
 
        s = 64 - fls64(v);                /* 0 <= s <= 63. */
        vn0 = v << s;             /* Normalize divisor. */
@@ -255,7 +256,9 @@ static uint64_t divlu64(uint64_t u1, uint64_t u0, uint64_t v)
                if (qhat >= b || qhat*vn[0] > b*rhat + un[j]) {
                        qhat = qhat - 1;
                        rhat = rhat + vn[1];
-                       if (rhat < b) goto again;
+                       if (rhat < b) {
+                               goto again;
+                       }
                }
 
                /* Multiply and subtract. */
@@ -289,26 +292,28 @@ static int64_t divls64(int64_t u1, uint64_t u0, int64_t v)
 {
        int64_t q, uneg, vneg, diff, borrow;
 
-       uneg = u1 >> 63;          // -1 if u < 0.
-       if (uneg) {               // Compute the absolute
-               u0 = -u0;         // value of the dividend u.
+       uneg = u1 >> 63;          /* -1 if u < 0. */
+       if (uneg) {               /* Compute the absolute */
+               u0 = -u0;         /* value of the dividend u. */
                borrow = (u0 != 0);
                u1 = -u1 - borrow;
        }
 
-       vneg = v >> 63;           // -1 if v < 0.
-       v = (v ^ vneg) - vneg;    // Absolute value of v.
+       vneg = v >> 63;           /* -1 if v < 0. */
+       v = (v ^ vneg) - vneg;    /* Absolute value of v. */
 
-       if ((uint64_t)u1 >= (uint64_t)v)
+       if ((uint64_t)u1 >= (uint64_t)v) {
                goto overflow;
+       }
 
        q = divlu64(u1, u0, v);
 
-       diff = uneg ^ vneg;       // Negate q if signs of
-       q = (q ^ diff) - diff;    // u and v differed.
+       diff = uneg ^ vneg;       /* Negate q if signs of */
+       q = (q ^ diff) - diff;    /* u and v differed. */
 
-       if ((diff ^ q) < 0 && q != 0) {    // If overflow, return the largest
-       overflow:                          // possible neg. quotient.
+       if ((diff ^ q) < 0 && q != 0) {    /* If overflow, return the
+                                             largest */
+       overflow:                          /* possible neg. quotient. */
                q = 0x8000000000000000ULL;
        }
        return q;