X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/4199ce23fd3df23daccbf961b2ff1a2d42f89519..f4ac4f7b033ea65635f65104dc711b9aaf3a41e0:/rand/rand.c diff --git a/rand/rand.c b/rand/rand.c index 0d0650eb..665152ac 100644 --- a/rand/rand.c +++ b/rand/rand.c @@ -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; }