diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2015-06-19 19:26:19 -0400 |
---|---|---|
committer | Paul Jakma <paul@quagga.net> | 2015-06-21 14:39:26 +0100 |
commit | f31bab4fbf367a4417784ba9873e524d42242036 (patch) | |
tree | c624feca43613e738e4756ad6b3b555c1402e465 /bgpd | |
parent | 771626860adfc30c00f70d993ccb8f4d7c0c0c63 (diff) | |
download | quagga-f31bab4fbf367a4417784ba9873e524d42242036.tar.bz2 quagga-f31bab4fbf367a4417784ba9873e524d42242036.tar.xz |
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>
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_fsm.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_main.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_routemap.c | 13 |
3 files changed, 3 insertions, 14 deletions
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index d261bb59..6a2e41e8 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -65,7 +65,7 @@ static int bgp_start (struct peer *); 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 ad4de798..7c2988cd 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -420,7 +420,7 @@ main (int argc, char **argv) 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 5467cfdc..20bf2eba 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -884,12 +884,7 @@ static route_map_result_t 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 @@ 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)); |