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/network.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/network.c')
| -rw-r--r-- | lib/network.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/network.c b/lib/network.c index 411661a5e1..d2482bd55e 100644 --- a/lib/network.c +++ b/lib/network.c @@ -121,3 +121,21 @@ float ntohf(float net) { return htonf(net); } + +/** + * Helper function that returns a random long value. The main purpose of + * this function is to hide a `random()` call that gets flagged by coverity + * scan and put it into one place. + * + * The main usage of this function should be for generating jitter or weak + * random values for simple purposes. + * + * See 'man 3 random' for more information. + * + * \returns random long integer. + */ +long frr_weak_random(void) +{ + /* coverity[dont_call] */ + return random(); +} |
