From 7b49953b007f99fad8a5d3c7661b120ce96fa074 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 30 Mar 2016 21:34:35 +0200 Subject: strfry: reset n to max when the do..while loop resets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/string/strfry.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/string/strfry.c b/src/string/strfry.c index 5aec420..cf6324b 100644 --- a/src/string/strfry.c +++ b/src/string/strfry.c @@ -37,11 +37,11 @@ static size_t uniform_random_zu(size_t max) { - size_t n = max, r = 0, mask = max, s = 1; + size_t n, r = 0, mask = max, s = 1; while (((mask + 1) & ~mask) != mask + 1) mask |= mask >> s++; do - for (; n; n >>= BITS) + for (n = max; n; n >>= BITS) { b = rand(); b /= (double)RAND_MAX + 1; -- cgit v1.2.3-70-g09d2