diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2003-06-26 15:56:52 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2003-06-26 15:56:52 +0000 |
commit | 5252fdc2f1ebc9f26883d0c924775b12ea86d0c1 (patch) | |
tree | 81d214379d708bf689335581ccb9d4f73bbe0af0 /usr.sbin/timed | |
parent | 0794cefd3e1dd553dedd216c92f36e37445b05b1 (diff) |
avoid using floating point for a random in [a, b] and kill a false comment
Diffstat (limited to 'usr.sbin/timed')
-rw-r--r-- | usr.sbin/timed/timed/timed.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/usr.sbin/timed/timed/timed.c b/usr.sbin/timed/timed/timed.c index ba5d1c46c2d..b1614a6f3ea 100644 --- a/usr.sbin/timed/timed/timed.c +++ b/usr.sbin/timed/timed/timed.c @@ -1,4 +1,4 @@ -/* $OpenBSD: timed.c,v 1.20 2003/06/17 06:21:56 jmc Exp $ */ +/* $OpenBSD: timed.c,v 1.21 2003/06/26 15:56:51 mickey Exp $ */ /*- * Copyright (c) 1985, 1993 The Regents of the University of California. @@ -239,11 +239,9 @@ main(int argc, char **argv) exit(1); } - /* choose a unique seed for random number generation */ - (void)gettimeofday(&ntime, 0); - sequence = arc4random(); /* initial seq number */ + gettimeofday(&ntime, 0); /* rounds kernel variable time to multiple of 5 ms. */ ntime.tv_sec = 0; ntime.tv_usec = -((ntime.tv_usec/1000) % 5) * 1000; @@ -392,7 +390,6 @@ main(int argc, char **argv) /* election timer delay in secs. */ delay2 = casual(MINTOUT, MAXTOUT); - if (!debug) daemon(debug, 0); @@ -718,10 +715,7 @@ pickslavenet(struct netinfo *ntp) long casual(long inf, long sup) { - double value; - - value = ((double)(random() & 0x7fffffff)) / (0x7fffffff*1.0); - return(inf + (sup - inf)*value); + return (inf + random() % (sup - inf + 1)); } char * |