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));