[hackers] [sbase][PATCH] libutil/random: no need to call time() when we have timespec

From: Elie Le Vaillant <eolien55_AT_disroot.org>
Date: Tue, 5 Mar 2024 18:16:19 +0100

Thanks Steve Ward
---
 libutil/random.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libutil/random.c b/libutil/random.c
index 6b795a9..d5214ae 100644
--- a/libutil/random.c
+++ b/libutil/random.c
_AT_@ -67,7 +67,7 @@ rng32_seed_r(uint64_t *state)
 {
 	struct timespec ts;
 	clock_gettime(CLOCK_REALTIME, &ts);
-	*state = (intptr_t)&printf ^ time(NULL) ^ (ts.tv_nsec * 0xAC5533CD);
+	*state = (intptr_t)&printf ^ ts.tv_sec ^ (ts.tv_nsec * 0xAC5533CD);
 }
 
 void
-- 
2.44.0
Received on Tue Mar 05 2024 - 18:16:19 CET

This archive was generated by hypermail 2.3.0 : Tue Mar 05 2024 - 18:24:37 CET