]> git.puffer.fish Git - matthieu/frr.git/commitdiff
Quagga: Fix code to use srandom/random
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 19 Jun 2015 23:26:19 +0000 (19:26 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 30 May 2016 00:24:55 +0000 (20:24 -0400)
Quagga was using a mix of srand/rand and srandom/random.
Consolidate to use srandom/random which are the POSIX
versions of random number generators

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_main.c
bgpd/bgp_routemap.c
isisd/isis_main.c
isisd/isis_misc.c
lib/command.c
ospf6d/ospf6_main.c
ripd/ripd.c
ripngd/ripngd.c

index 7fa80cc9c99f981cd6aa44b477b94f957080cb24..f873aba493364836744931acde881b11d596c3f1 100644 (file)
@@ -490,7 +490,7 @@ main (int argc, char **argv)
 
 
   /* Initializations. */
-  srand (time (NULL));
+  srandom (time (NULL));
   signal_init (bm->master, array_size(bgp_signals), bgp_signals);
   zprivs_init (&bgpd_privs);
   cmd_init (1);
index ab22a455d2f23cc5b45ae5d2fd8154f1bbb1f2a5..a7d62a6b37e0e31252cefa9173b33b05683a57b6 100644 (file)
@@ -892,12 +892,7 @@ static route_map_result_t
 route_match_probability (void *rule, struct prefix *prefix,
                    route_map_object_t type, void *object)
 {
-  unsigned long r;
-#if _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE >= 500
-  r = random();
-#else
-  r = (unsigned long) rand();
-#endif
+  long r = random();
 
   switch (*(long *) rule)
   {
@@ -919,12 +914,6 @@ route_match_probability_compile (const char *arg)
   long *lobule;
   unsigned  perc;
 
-#if _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE >= 500
-  srandom (time (NULL));
-#else
-  srand (time (NULL));
-#endif
-
   perc    = atoi (arg);
   lobule  = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (long));
 
index f2fe4ef71f38ec726f17081eec2756ee982ac75e..343c683f4840744a649f2e831b69e69a0547674e 100644 (file)
@@ -327,7 +327,7 @@ main (int argc, char **argv, char **envp)
   master = thread_master_create ();
 
   /* random seed from time */
-  srand (time (NULL));
+  srandom (time (NULL));
 
   /*
    *  initializations
index 230fe24387825a6d25d60eb290d15493c86a57f2..f19b44155ad46e67e5d3f6cd93bb2e085e53fd1e 100644 (file)
@@ -510,7 +510,7 @@ isis_jitter (unsigned long timer, unsigned long jitter)
    * most IS-IS timers are no longer than 16 bit
    */
 
-  j = 1 + (int) ((RANDOM_SPREAD * rand ()) / (RAND_MAX + 1.0));
+  j = 1 + (int) ((RANDOM_SPREAD * random ()) / (RAND_MAX + 1.0));
 
   k = timer - (timer * (100 - jitter)) / 100;
 
index 85506adefef6c72ea901c75cd58ef8d8054b7625..d080d6cc0b2aa458ff5327254c251835db2ed199 100644 (file)
@@ -4209,7 +4209,7 @@ cmd_init (int terminal)
 
       vrf_install_commands ();
     }
-  srand(time(NULL));
+  srandom(time(NULL));
 }
 
 static void
index 52dc6677f0f9c638774108f45ff35389a48f42f2..84c98b885f5b57cbbbe891c052ee7e46f2cad3d3 100644 (file)
@@ -243,7 +243,7 @@ main (int argc, char *argv[], char *envp[])
   progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
 
   /* Seed random number for LSA ID */
-  srand (time(NULL));
+  srandom (time(NULL));
 
   /* Command line argument treatment. */
   while (1) 
index fc3ad3adb30e567f19f36e44e3d25cba3b1f143c..42f1015453cceab00426a1b98c2f46825826e683 100644 (file)
@@ -2867,7 +2867,7 @@ rip_update_jitter (unsigned long time)
   if (jitter_input < JITTER_BOUND)
     jitter_input = JITTER_BOUND;
   
-  jitter = (((rand () % ((jitter_input * 2) + 1)) - jitter_input));  
+  jitter = (((random () % ((jitter_input * 2) + 1)) - jitter_input));
 
   return jitter/JITTER_BOUND;
 }
@@ -4140,7 +4140,7 @@ void
 rip_init (void)
 {
   /* Randomize for triggered update random(). */
-  srand (time (NULL));
+  srandom (time (NULL));
 
   /* Install top nodes. */
   install_node (&rip_node, config_write_rip);
index 4eed40b94ae65cdca91ea63f4eea9b260d7021ee..13884ff3b333a3667238183fcf9723d893eb580e 100644 (file)
@@ -1874,7 +1874,7 @@ ripng_request (struct interface *ifp)
 static int
 ripng_update_jitter (int time)
 {
-  return ((rand () % (time + 1)) - (time / 2));
+  return ((random () % (time + 1)) - (time / 2));
 }
 
 void
@@ -2928,7 +2928,7 @@ void
 ripng_init ()
 {
   /* Randomize. */
-  srand (time (NULL));
+  srandom (time (NULL));
 
   /* Install RIPNG_NODE. */
   install_node (&cmd_ripng_node, ripng_config_write);