Quagga: Fix code to use srandom/random
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>
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index d261bb5..6a2e41e 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -65,7 +65,7 @@
static int
bgp_start_jitter (int time)
{
- return ((rand () % (time + 1)) - (time / 2));
+ return ((random () % (time + 1)) - (time / 2));
}
/* Check if suppress start/restart of sessions to peer. */
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index ad4de79..7c2988c 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -420,7 +420,7 @@
master = bm->master;
/* Initializations. */
- srand (time (NULL));
+ srandom (time (NULL));
signal_init (master, array_size(bgp_signals), bgp_signals);
zprivs_init (&bgpd_privs);
cmd_init (1);
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index 5467cfd..20bf2eb 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -884,12 +884,7 @@
route_match_probability (void *rule, struct prefix *prefix,
route_map_object_t type, void *object)
{
- long r;
-#if _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE >= 500
- r = random();
-#else
- r = (long) rand();
-#endif
+ long r = random();
switch (*(long *) rule)
{
@@ -911,12 +906,6 @@
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));
diff --git a/isisd/isis_main.c b/isisd/isis_main.c
index 60ecb75..e1af71f 100644
--- a/isisd/isis_main.c
+++ b/isisd/isis_main.c
@@ -320,7 +320,7 @@
master = thread_master_create ();
/* random seed from time */
- srand (time (NULL));
+ srandom (time (NULL));
/*
* initializations
diff --git a/isisd/isis_misc.c b/isisd/isis_misc.c
index 968fa05..2dfd7cc 100644
--- a/isisd/isis_misc.c
+++ b/isisd/isis_misc.c
@@ -510,7 +510,7 @@
* 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;
diff --git a/lib/command.c b/lib/command.c
index 3a59f24..641cf20 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -4144,7 +4144,7 @@
install_element (VIEW_NODE, &show_work_queues_cmd);
install_element (ENABLE_NODE, &show_work_queues_cmd);
}
- srand(time(NULL));
+ srandom(time(NULL));
}
static void
diff --git a/ripd/ripd.c b/ripd/ripd.c
index 9d355ec..b42ca72 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -2859,7 +2859,7 @@
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;
}
@@ -4132,7 +4132,7 @@
rip_init (void)
{
/* Randomize for triggered update random(). */
- srand (time (NULL));
+ srandom (time (NULL));
/* Install top nodes. */
install_node (&rip_node, config_write_rip);
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index 4a7f52f..97a1392 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -1936,7 +1936,7 @@
static int
ripng_update_jitter (int time)
{
- return ((rand () % (time + 1)) - (time / 2));
+ return ((random () % (time + 1)) - (time / 2));
}
void
@@ -3084,7 +3084,7 @@
ripng_init ()
{
/* Randomize. */
- srand (time (NULL));
+ srandom (time (NULL));
/* Install RIPNG_NODE. */
install_node (&cmd_ripng_node, ripng_config_write);