[Openvpn-devel,v1] Remove local get_random in test_misc.c
Commit Message
From: Arne Schwabe <arne@rfc2549.org>
The get_random in test_misc.c conflicts
with the get_random function that OpenVPN defines in crypto.h
Also adjust the implementation in mock_get_random.c to match the
prototype in crypto.h
Change-Id: I3db70001be7f39cf84d562517647f1a305962b42
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1834
---
This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1834
This mail reflects revision 1 of this Change.
Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <frank@lichtenheld.com>
@@ -28,7 +28,7 @@
#include <stdint.h>
#include <cmocka.h>
-unsigned long
+int64_t
get_random(void)
{
/* rand() is not very random, but it's C99 and this is just for testing */
@@ -38,6 +38,7 @@
#include "test_common.h"
#include "list.h"
#include "mock_msg.h"
+#include "crypto.h"
#ifdef _WIN32
#include "win32-util.h"
#endif
@@ -141,13 +142,6 @@
return strcmp((const char *)key1, (const char *)key2) == 0;
}
-static uint32_t
-get_random(void)
-{
- /* rand() is not very random, but it's C99 and this is just for testing */
- return (uint32_t)rand();
-}
-
static struct hash_element *
hash_lookup_by_value(struct hash *hash, void *value)
{
@@ -263,7 +257,7 @@
{
struct hash_iterator hi;
struct hash_element *he;
- inc = (get_random() % 3) + 1;
+ inc = ((uint32_t)get_random() % 3) + 1;
hash_iterator_init_range(hash, &hi, base, base + inc);
while ((he = hash_iterator_next(&hi)))