aboutsummaryrefslogtreecommitdiffstats
path: root/vppinfra
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2016-11-11 17:27:51 -0500
committerDamjan Marion <dmarion.lists@gmail.com>2016-11-12 00:05:41 +0000
commitf5179c71449792a059be2b753f4c43ba8c438d71 (patch)
tree6aad4c5c7cef24e74f99a9c6bb7c031733acd3a0 /vppinfra
parent4cecc611bedde8a9a1b2ad1454dd84f30a1652cb (diff)
Clean up coverity warnings, VPP-486
Change-Id: I709e7cf0bb52d8e6cdc9ddb3b7648660204aa3bd Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'vppinfra')
-rw-r--r--vppinfra/vppinfra/random.h17
1 files changed, 7 insertions, 10 deletions
diff --git a/vppinfra/vppinfra/random.h b/vppinfra/vppinfra/random.h
index fad05898350..5c139d05490 100644
--- a/vppinfra/vppinfra/random.h
+++ b/vppinfra/vppinfra/random.h
@@ -119,17 +119,14 @@ random_default_seed (void)
#endif
/** \brief 64-bit random number generator
-
- created via two calls to random_u32(). Quick and dirty.
-*/
+ * Again, constants courtesy of Donald Knuth.
+ *
+ */
always_inline u64
-random_u64 (u32 * seed)
+random_u64 (u64 * seed)
{
- u64 result;
-
- result = (u64) random_u32 (seed) << 32;
- result |= random_u32 (seed);
- return result;
+ *seed = 6364136223846793005ULL * *seed + 1442695040888963407ULL;
+ return *seed;
}
/** \brief machine word size random number generator */
@@ -138,7 +135,7 @@ always_inline uword
random_uword (u32 * seed)
{
if (sizeof (uword) == sizeof (u64))
- return random_u64 (seed);
+ return random_u64 ((u64 *) seed);
else
return random_u32 (seed);
}