[Git][NTPsec/ntpsec][master] Use ntp_random() instead of random() to silence warnings on OpenBSD

Matt Selsky gitlab at mg.gitlab.com
Fri Dec 30 16:16:01 UTC 2016


Matt Selsky pushed to branch master at NTPsec / ntpsec


Commits:
d99c6b74 by Matt Selsky at 2016-12-30T11:13:20-05:00
Use ntp_random() instead of random() to silence warnings on OpenBSD

sht.c:(.text+0x3f6): warning: warning: random() may return deterministic values, is that what you want?

Fixes GitLab issue #217

- - - - -


1 changed file:

- attic/sht.c


Changes:

=====================================
attic/sht.c
=====================================
--- a/attic/sht.c
+++ b/attic/sht.c
@@ -14,6 +14,7 @@
 #include <assert.h>
 
 #include "ntp_stdlib.h"
+#include "ntp_random.h"
 
 char	*progname;
 
@@ -89,8 +90,6 @@ main (
 		exit (0);
 	}
 
-	srand(time(NULL));
-		
 	unit = strtoul(argv[1], &argp, 10);
 	if (argp == argv[1])
 		unit = 2;
@@ -146,7 +145,7 @@ again:
 
 	case 'w': {
 		/* To show some life action, we read the system
-		 * clock and use a bit of fuzz from 'random()' to get a
+		 * clock and use a bit of fuzz from 'ntp_random()' to get a
 		 * bit of wobbling into the values (so we can observe a
 		 * certain jitter!)
 		 */
@@ -164,11 +163,11 @@ again:
 		else
 		{
 			time(&rcv_sec);
-			rcv_frc = (uint)random() % 1000000000u;
+			rcv_frc = (uint)ntp_random() % 1000000000u;
 		}
 		/* add a wobble of ~3.5msec to the clock time */
 		clk_sec = rcv_sec;
-		clk_frc = rcv_frc + (uint)(random()%7094713 - 3547356);
+		clk_frc = rcv_frc + (uint)(ntp_random()%7094713 - 3547356);
 		/* normalise result -- the SHM driver is picky! */
 		while ((int)clk_frc < 0) {
 			clk_frc += 1000000000;



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/d99c6b74a63e144378d7205dc96046cbde381c8f
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20161230/21d308b7/attachment.html>


More information about the vc mailing list