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 /tests | |
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 'tests')
-rw-r--r-- | tests/lib/test_checksum.c | 3 | ||||
-rw-r--r-- | tests/lib/test_zlog.c | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/tests/lib/test_checksum.c b/tests/lib/test_checksum.c index 13d35b0e9..ddb76c8f9 100644 --- a/tests/lib/test_checksum.c +++ b/tests/lib/test_checksum.c @@ -23,6 +23,7 @@ #include <time.h> #include "checksum.h" +#include "network.h" struct thread_master *master; @@ -477,7 +478,7 @@ int main(int argc, char **argv) exercise %= MAXDATALEN; for (i = 0; i < exercise; i += sizeof(long int)) { - long int rand = random(); + long int rand = frr_weak_random(); for (j = sizeof(long int); j > 0; j--) buffer[i + (sizeof(long int) - j)] = diff --git a/tests/lib/test_zlog.c b/tests/lib/test_zlog.c index 3042cc6cc..48fa7bce9 100644 --- a/tests/lib/test_zlog.c +++ b/tests/lib/test_zlog.c @@ -20,6 +20,7 @@ #include <zebra.h> #include <memory.h> #include "log.h" +#include "network.h" /* maximum amount of data to hexdump */ #define MAXDATA 16384 @@ -37,7 +38,7 @@ static bool test_zlog_hexdump(void) uint8_t d[nl]; for (unsigned int i = 0; i < nl; i++) - d[i] = random(); + d[i] = frr_weak_random(); zlog_hexdump(d, nl - 1); nl += 1 + (nl / 2); |