]> granicus.if.org Git - fcron/commitdiff
better use of rand().
authorthib <thib>
Sat, 2 Feb 2002 14:52:29 +0000 (14:52 +0000)
committerthib <thib>
Sat, 2 Feb 2002 14:52:29 +0000 (14:52 +0000)
database.c

index 22f3a0478cea09455012954e274142e5273c36e0..9ab46fc111fdcc62b00b9a0beb791d56eb331829 100644 (file)
@@ -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);