diff --git a/arc4random.c b/arc4random.c index 8729f6b9..9a00ea2c 100644 --- a/arc4random.c +++ b/arc4random.c @@ -176,25 +176,14 @@ static int arc4_seed_getrandom(void) { unsigned char buf[ADD_ENTROPY]; - size_t len, n; - unsigned i; - int any_set; - - memset(buf, 0, sizeof(buf)); + size_t len; + ssize_t n = 0; for (len = 0; len < sizeof(buf); len += n) { - n = sizeof(buf) - len; - - if (0 == getrandom(&buf[len], n, 0)) + n = getrandom(&buf[len], sizeof(buf) - len, 0); + if (n < 0) return -1; } - /* make sure that the buffer actually got set. */ - for (i=0,any_set=0; i