diff options
author | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2020-04-17 15:35:15 +0200 |
---|---|---|
committer | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2020-04-18 01:57:43 +0200 |
commit | 5920b3eb38a6cfd1c9b87106aa7403171408f0bd (patch) | |
tree | fe6c96488ab537bebfeb07f658b4d500ba20c446 /babeld/util.c | |
parent | Merge pull request #6248 from donaldsharp/zebra_snmp (diff) | |
download | frr-5920b3eb38a6cfd1c9b87106aa7403171408f0bd.tar.xz frr-5920b3eb38a6cfd1c9b87106aa7403171408f0bd.zip |
*: replace all random() calls
Replace all `random()` calls with a function called `frr_weak_random()`
and make it clear that it is only supposed to be used for weak random
applications.
Use the annotation described by the Coverity Scan documentation to
ignore `random()` call warnings.
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Diffstat (limited to 'babeld/util.c')
-rw-r--r-- | babeld/util.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/babeld/util.c b/babeld/util.c index c6606e4f0..e99bd861d 100644 --- a/babeld/util.c +++ b/babeld/util.c @@ -39,6 +39,8 @@ THE SOFTWARE. #include <netinet/in.h> #include <arpa/inet.h> +#include "lib/network.h" + #include "babel_main.h" #include "babeld.h" #include "util.h" @@ -51,7 +53,7 @@ roughly(int value) else if(value <= 1) return value; else - return value * 3 / 4 + random() % (value / 2); + return value * 3 / 4 + frr_weak_random() % (value / 2); } /* d = s1 - s2 */ @@ -145,7 +147,7 @@ timeval_min_sec(struct timeval *d, time_t secs) { if(d->tv_sec == 0 || d->tv_sec > secs) { d->tv_sec = secs; - d->tv_usec = random() % 1000000; + d->tv_usec = frr_weak_random() % 1000000; } } |