From ecb4043db21718f5d19b80701bd1e693e566775a Mon Sep 17 00:00:00 2001 From: Dieter Baron Date: Mon, 24 Jul 2023 15:11:39 +0200 Subject: [PATCH] Simplify fallback to srand/rand. --- lib/zip_random_unix.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/zip_random_unix.c b/lib/zip_random_unix.c index e8ed5bf70..867df7900 100644 --- a/lib/zip_random_unix.c +++ b/lib/zip_random_unix.c @@ -83,6 +83,11 @@ zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) { #ifndef HAVE_RANDOM_UINT32 #include +#ifndef HAVE_RANDOM +#define srandom srand +#define random rand +#endif + zip_uint32_t zip_random_uint32(void) { static bool seeded = false; @@ -93,21 +98,12 @@ zip_random_uint32(void) { return value; } -#ifdef HAVE_RANDOM if (!seeded) { srandom((unsigned int)time(NULL)); seeded = true; } return (zip_uint32_t)random(); -#else - if (!seeded) { - srand((unsigned int)time(NULL)); - seeded = true; - } - - return (zip_uint32_t)rand(); -#endif } #endif