Skip to contentSkip to conversation

Change in openvpn[master]: Remove local get_random in test_misc.c

Openvpn-devel New plaisthos (Code Review) via Openvpn-devel 3 participants 8 messages Aug 3 – Aug 6 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1785766260000.I3db70001be7f39cf84d562517647f1a305962b42@gerrit.openvpn.net

#1 lore raw

plaisthos has uploaded this change for review. ( http://gerrit.openvpn.net/c/openvpn/+/1834?usp=email )

Change subject: Remove local get_random in test_misc.c
......................................................................

Remove local get_random in test_misc.c

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

---
M tests/unit_tests/openvpn/mock_get_random.c
M tests/unit_tests/openvpn/test_misc.c

2 files changed, 3 insertions(+), 9 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/34/1834/1

tests/unit_tests/openvpn/mock_get_random.c +1 -1
index 0840e31..5cb768b 100644
@@ -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 */
tests/unit_tests/openvpn/test_misc.c +2 -8
index 501286c..8da7abe 100644
@@ -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)))

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1834?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3db70001be7f39cf84d562517647f1a305962b42
Gerrit-Change-Number: 1834
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

flichtenheld has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1834?usp=email )

Change subject: Remove local get_random in test_misc.c
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1834?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3db70001be7f39cf84d562517647f1a305962b42
Gerrit-Change-Number: 1834
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-Reviewer: flichtenheld <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Comment-Date: Mon, 03 Aug 2026 15:10:37 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#3 lore raw

PATCH 1/1 Remove local get_random in test_misc.c

In reply to a message not in the archive

From: Arne Schwabe <[email protected]>

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

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 <[email protected]>

tests/unit_tests/openvpn/mock_get_random.c +1 -1
index 0840e31..5cb768b 100644
@@ -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 */
tests/unit_tests/openvpn/test_misc.c +2 -8
index 501286c..8da7abe 100644
@@ -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)))

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#4 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

ordex has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1834?usp=email )

Change subject: Remove local get_random in test_misc.c
......................................................................

Patch Set 2: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1834?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3db70001be7f39cf84d562517647f1a305962b42
Gerrit-Change-Number: 1834
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-Reviewer: flichtenheld <[email protected]>
Gerrit-Reviewer: ordex <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Comment-Date: Thu, 06 Aug 2026 09:02:27 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#5 lore raw

PATCH v2 1/1 Remove local get_random in test_misc.c

In reply to a message not in the archive

From: Arne Schwabe <[email protected]>

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

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 2 of this Change.

Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]>
Antonio Quartulli <[email protected]>

tests/unit_tests/openvpn/mock_get_random.c +1 -1
index 0840e31..5cb768b 100644
@@ -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 */
tests/unit_tests/openvpn/test_misc.c +2 -8
index 501286c..8da7abe 100644
@@ -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)))

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Acked-by Frank Lichtenheld Acked-by Antonio Quartulli on v2 1/1
#6 lore raw

[Openvpn-devel] [PATCH applied] Re: Remove local get_random in test_misc.c

Straightforward removal of conflicting functions. Tested that it works if I apply this on top of master and 2.7 right now, without any of the other patches in gerrit that might be needed.

Your patch has been applied to the master and release/2.7 branch (keep test code "in sync").

commit 5978a46e3db1013f327bb315d283d5816c3a4526 (master) commit 3402f9aa03776a6055f690b9b63cea933c56ab6e (release/2.7)

Author: Arne Schwabe
Date:   Thu Aug 6 11:09:45 2026 +0200

Remove local get_random in test_misc.c

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1834
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg38155.html

--
kind regards,

Gert Doering

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#7 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#3) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1834?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld, Code-Review+2 by ordex

Change subject: Remove local get_random in test_misc.c
......................................................................

Remove local get_random in test_misc.c

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

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1834
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg38155.html

---
M tests/unit_tests/openvpn/mock_get_random.c
M tests/unit_tests/openvpn/test_misc.c

2 files changed, 3 insertions(+), 9 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/34/1834/3

tests/unit_tests/openvpn/mock_get_random.c +1 -1
index 0840e31..5cb768b 100644
@@ -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 */
tests/unit_tests/openvpn/test_misc.c +2 -8
index cd86fd2..4d046ce 100644
@@ -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
@@ -143,13 +144,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)
 {
@@ -266,7 +260,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)))

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1834?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3db70001be7f39cf84d562517647f1a305962b42
Gerrit-Change-Number: 1834
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-Reviewer: flichtenheld <[email protected]>
Gerrit-Reviewer: ordex <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#8 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1834?usp=email )

Change subject: Remove local get_random in test_misc.c
......................................................................

Remove local get_random in test_misc.c

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

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1834
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg38155.html

---
M tests/unit_tests/openvpn/mock_get_random.c
M tests/unit_tests/openvpn/test_misc.c

2 files changed, 3 insertions(+), 9 deletions(-)
tests/unit_tests/openvpn/mock_get_random.c +1 -1
index 0840e31..5cb768b 100644
@@ -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 */
tests/unit_tests/openvpn/test_misc.c +2 -8
index cd86fd2..4d046ce 100644
@@ -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
@@ -143,13 +144,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)
 {
@@ -266,7 +260,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)))

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1834?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3db70001be7f39cf84d562517647f1a305962b42
Gerrit-Change-Number: 1834
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-Reviewer: flichtenheld <[email protected]>
Gerrit-Reviewer: ordex <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel