From: thib <thib>
Date: Sat, 2 Feb 2002 14:52:29 +0000 (+0000)
Subject: better use of rand().
X-Git-Tag: ver1564~131
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=18b46dde5ae4fa5e5301191412f6049279cfb0b5;p=fcron

better use of rand().
---

diff --git a/database.c b/database.c
index 22f3a04..9ab46fc 100644
--- a/database.c
+++ b/database.c
@@ -22,7 +22,7 @@
  *  `LICENSE' that comes with the fcron source distribution.
  */
 
- /* $Id: database.c,v 1.60 2002-01-27 16:33:20 thib Exp $ */
+ /* $Id: database.c,v 1.61 2002-02-02 14:52:29 thib Exp $ */
 
 #include "fcron.h"
 
@@ -964,8 +964,8 @@ set_next_exe(CL *line, char option)
 	    intend_int = mktime(&intend);
 
 	    /* set a random time to add to the first allowed time of execution */
-	    nextexe += ( (i= intend_int - nextexe) > 0) ? (time_t)( rand() % i) : 0 ;
-
+	    nextexe += ( (i= intend_int - nextexe) > 0) ? 
+		(time_t)(((float)i * (float)rand())/(float)RAND_MAX) : 0;
 	}
 
 	line->cl_nextexe = nextexe + (line->cl_file->cf_tzdiff * 3600);