rand/rand.c: Fix multiplication and division formatting.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 23 Dec 2023 14:18:57 +0000 (14:18 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 23 Dec 2023 14:33:09 +0000 (14:33 +0000)
rand/rand.c

index 0d0650e..665152a 100644 (file)
@@ -428,8 +428,8 @@ void rand_get(rand_pool *r, void *p, size_t sz)
     }
   }
 
-  if (r->obits > sz * 8)
-    r->obits -= sz * 8;
+  if (r->obits > 8*sz)
+    r->obits -= 8*sz;
   else
     r->obits = 0;
 }
@@ -467,12 +467,12 @@ void rand_getgood(rand_pool *r, void *p, size_t sz)
   while (sz) {
     size_t chunk = sz;
 
-    if (chunk * 8 > r->obits) {
-      if (chunk * 8 > r->ibits + r->obits)
+    if (8*chunk > r->obits) {
+      if (8*chunk > r->ibits + r->obits)
        do r->s->getnoise(r); while (r->ibits + r->obits < 256);
       rand_gate(r);
-      if (chunk * 8 > r->obits)
-       chunk = r->obits / 8;
+      if (8*chunk > r->obits)
+       chunk = r->obits/8;
     }
 
     if (chunk <= RAND_BUFSZ - r->o) {
@@ -484,7 +484,7 @@ void rand_getgood(rand_pool *r, void *p, size_t sz)
       rand_stretch(r);
     }
 
-    r->obits -= chunk * 8;
+    r->obits -= 8*chunk;
     o += chunk;
     sz -= chunk;
   }