diff options
| author | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2020-04-17 10:35:15 -0300 |
|---|---|---|
| committer | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2020-04-17 20:57:43 -0300 |
| commit | 5920b3eb38a6cfd1c9b87106aa7403171408f0bd (patch) | |
| tree | fe6c96488ab537bebfeb07f658b4d500ba20c446 /lib/qobj.c | |
| parent | 4110aa2cb342fb0f025746c4b7df7707f69334c5 (diff) | |
*: 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 'lib/qobj.c')
| -rw-r--r-- | lib/qobj.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/qobj.c b/lib/qobj.c index 1e48b541dc..cb3254cbe9 100644 --- a/lib/qobj.c +++ b/lib/qobj.c @@ -26,6 +26,7 @@ #include "log.h" #include "qobj.h" #include "jhash.h" +#include "network.h" static uint32_t qobj_hash(const struct qobj_node *node) { @@ -53,8 +54,8 @@ void qobj_reg(struct qobj_node *node, const struct qobj_nodetype *type) node->type = type; pthread_rwlock_wrlock(&nodes_lock); do { - node->nid = (uint64_t)random(); - node->nid ^= (uint64_t)random() << 32; + node->nid = (uint64_t)frr_weak_random(); + node->nid ^= (uint64_t)frr_weak_random() << 32; } while (!node->nid || qobj_nodes_find(&nodes, node)); qobj_nodes_add(&nodes, node); pthread_rwlock_unlock(&nodes_lock); |
