[S] Change in openvpn[master]: Remove local get_random in test_misc.c
"plaisthos \(Code Review\) via Openvpn-devel" <[email protected]> Mon, 3 Aug 2026 14:11:09 +0000
| Newsgroups | gmane.network.openvpn.devel |
|---|---|
| Message-ID | <[email protected]> |
--===============6539555916348876115==
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Content-Type: multipart/alternative; boundary="LyLTOgWmEkY="; charset=UTF-8
--LyLTOgWmEkY=
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
plaisthos has uploaded this change for review=2E ( http://gerrit=2Eopenvpn=
=2Enet/c/openvpn/+/1834?usp=3Demail )
Change subject: Remove local get_ra=
ndom in test_misc=2Ec
=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=
=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=
=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=
=2E=2E=2E
Remove local get_random in test_misc=2Ec
The get_random in test=
_misc=2Ec conflicts
with the get_random function that OpenVPN defines in cr=
ypto=2Eh
Also adjust the implementation in mock_get_random=2Ec to match the=
prototype in crypto=2Eh
Change-Id: I3db70001be7f39cf84d562517647f1a305962=
b42
Signed-off-by: Arne Schwabe <arne@rfc2549=2Eorg>
---
M tests/unit_tests=
/openvpn/mock_get_random=2Ec
M tests/unit_tests/openvpn/test_misc=2Ec
2 fil=
es changed, 3 insertions(+), 9 deletions(-)
git pull ssh://gerrit=2Eop=
envpn=2Enet:29418/openvpn refs/changes/34/1834/1
diff --git a/tests/unit_t=
ests/openvpn/mock_get_random=2Ec b/tests/unit_tests/openvpn/mock_get_random=
=2Ec
index 0840e31=2E=2E5cb768b 100644
--- a/tests/unit_tests/openvpn/mock_=
get_random=2Ec
+++ b/tests/unit_tests/openvpn/mock_get_random=2Ec
@@ -28,7 =
+28,7 @@
#include <stdint=2Eh>
#include <cmocka=2Eh>
-unsigned long
+in=
t64_t
get_random(void)
{
/* rand() is not very random, but it's C99 =
and this is just for testing */
diff --git a/tests/unit_tests/openvpn/test_=
misc=2Ec b/tests/unit_tests/openvpn/test_misc=2Ec
index 501286c=2E=2E8da7ab=
e 100644
--- a/tests/unit_tests/openvpn/test_misc=2Ec
+++ b/tests/unit_test=
s/openvpn/test_misc=2Ec
@@ -38,6 +38,7 @@
#include "test_common=2Eh"
#inc=
lude "list=2Eh"
#include "mock_msg=2Eh"
+#include "crypto=2Eh"
#ifdef _WI=
N32
#include "win32-util=2Eh"
#endif
@@ -141,13 +142,6 @@
return str=
cmp((const char *)key1, (const char *)key2) =3D=3D 0;
}
-static uint32_t=
-get_random(void)
-{
- /* rand() is not very random, but it's C99 and t=
his is just for testing */
- return (uint32_t)rand();
-}
-
static struc=
t hash_element *
hash_lookup_by_value(struct hash *hash, void *value)
{
@=
@ -263,7 +257,7 @@
{
struct hash_iterator hi;
=
struct hash_element *he;
- inc =3D (get_random() % 3) + 1;=
+ inc =3D ((uint32_t)get_random() % 3) + 1;
hash_i=
terator_init_range(hash, &hi, base, base + inc);
while ((he =
=3D hash_iterator_next(&hi)))
--
To view, visit http://gerrit=2Eopenvpn=
=2Enet/c/openvpn/+/1834?usp=3Demail
To unsubscribe, or for help writing mai=
l filters, visit http://gerrit=2Eopenvpn=2Enet/settings?usp=3Demail
Gerrit=
-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerri=
t-Change-Id: I3db70001be7f39cf84d562517647f1a305962b42
Gerrit-Change-Number=
: 1834
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <arne-openvpn@rfc2549=2Eo=
rg>
Gerrit-CC: openvpn-devel <openvpn-devel@lists=2Esourceforge=2Enet>
--LyLTOgWmEkY=
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE html><html><head><style></style></head><body><p>plaisthos has upl=
oaded this change for <strong>review</strong>=2E</p><p><a href=3D"http://ge=
rrit=2Eopenvpn=2Enet/c/openvpn/+/1834?usp=3Demail">View Change</a></p><pre =
class=3D"blocks" style=3D"font-family: monospace,monospace; white-space: pr=
e-wrap;">Remove local get_random in test_misc=2Ec<br><br>The get_random in =
test_misc=2Ec conflicts<br>with the get_random function that OpenVPN define=
s in crypto=2Eh<br>Also adjust the implementation in mock_get_random=2Ec to=
match the<br>prototype in crypto=2Eh<br><br>Change-Id: I3db70001be7f39cf84=
d562517647f1a305962b42<br>Signed-off-by: Arne Schwabe <arne@rfc2549=2Eor=
g><br>---<br>M tests/unit_tests/openvpn/mock_get_random=2Ec<br>M tests/u=
nit_tests/openvpn/test_misc=2Ec<br>2 files changed, 3 insertions(+), 9 dele=
tions(-)<br><br></pre><pre class=3D"blocks" style=3D"font-family: monospace=
,monospace; white-space: pre-wrap;">git pull ssh://gerrit=2Eopenvpn=2Enet:2=
9418/openvpn refs/changes/34/1834/1</pre><pre style=3D"font-family: monospa=
ce,monospace; white-space: pre-wrap;"><span>diff --git a/tests/unit_tests/o=
penvpn/mock_get_random=2Ec b/tests/unit_tests/openvpn/mock_get_random=2Ec</=
span><br><span>index 0840e31=2E=2E5cb768b 100644</span><br><span>--- a/test=
s/unit_tests/openvpn/mock_get_random=2Ec</span><br><span>+++ b/tests/unit_t=
ests/openvpn/mock_get_random=2Ec</span><br><span>@@ -28,7 +28,7 @@</span><b=
r><span> #include <stdint=2Eh></span><br><span> #include <cmocka=
=2Eh></span><br><span> </span><br><span style=3D"color: hsl(0, 100%, 40%=
);">-unsigned long</span><br><span style=3D"color: hsl(120, 100%, 40%);">+i=
nt64_t</span><br><span> get_random(void)</span><br><span> {</span><br><span=
> /* rand() is not very random, but it's C99 and this is just for t=
esting */</span><br><span>diff --git a/tests/unit_tests/openvpn/test_misc=
=2Ec b/tests/unit_tests/openvpn/test_misc=2Ec</span><br><span>index 501286c=
=2E=2E8da7abe 100644</span><br><span>--- a/tests/unit_tests/openvpn/test_mi=
sc=2Ec</span><br><span>+++ b/tests/unit_tests/openvpn/test_misc=2Ec</span><=
br><span>@@ -38,6 +38,7 @@</span><br><span> #include "test_common=2Eh&=
quot;</span><br><span> #include "list=2Eh"</span><br><span> #incl=
ude "mock_msg=2Eh"</span><br><span style=3D"color: hsl(120, 100%,=
40%);">+#include "crypto=2Eh"</span><br><span> #ifdef _WIN32</sp=
an><br><span> #include "win32-util=2Eh"</span><br><span> #endif</=
span><br><span>@@ -141,13 +142,6 @@</span><br><span> return strcmp((con=
st char *)key1, (const char *)key2) =3D=3D 0;</span><br><span> }</span><br>=
<span> </span><br><span style=3D"color: hsl(0, 100%, 40%);">-static uint32_=
t</span><br><span style=3D"color: hsl(0, 100%, 40%);">-get_random(void)</sp=
an><br><span style=3D"color: hsl(0, 100%, 40%);">-{</span><br><span style=
=3D"color: hsl(0, 100%, 40%);">- /* rand() is not very random, but it=
9;s C99 and this is just for testing */</span><br><span style=3D"color: hsl=
(0, 100%, 40%);">- return (uint32_t)rand();</span><br><span style=3D"col=
or: hsl(0, 100%, 40%);">-}</span><br><span style=3D"color: hsl(0, 100%, 40%=
);">-</span><br><span> static struct hash_element *</span><br><span> hash_l=
ookup_by_value(struct hash *hash, void *value)</span><br><span> {</span><br=
><span>@@ -263,7 +257,7 @@</span><br><span> {</span><br><span> =
struct hash_iterator hi;</span><br><span> struct hash_e=
lement *he;</span><br><span style=3D"color: hsl(0, 100%, 40%);">- =
inc =3D (get_random() % 3) + 1;</span><br><span style=3D"color: hsl(120, =
100%, 40%);">+ inc =3D ((uint32_t)get_random() % 3) + 1;</span><=
br><span> hash_iterator_init_range(hash, &hi, base, base + =
inc);</span><br><span> </span><br><span> while ((he =3D hash_it=
erator_next(&hi)))</span><br><span></span><br></pre><p>To view, visit <=
a href=3D"http://gerrit=2Eopenvpn=2Enet/c/openvpn/+/1834?usp=3Demail">chang=
e 1834</a>=2E To unsubscribe, or for help writing mail filters, visit <a hr=
ef=3D"http://gerrit=2Eopenvpn=2Enet/settings?usp=3Demail">settings</a>=2E</=
p><div itemscope itemtype=3D"http://schema=2Eorg/EmailMessage"><div itemsco=
pe itemprop=3D"action" itemtype=3D"http://schema=2Eorg/ViewAction"><link it=
emprop=3D"url" href=3D"http://gerrit=2Eopenvpn=2Enet/c/openvpn/+/1834?usp=
=3Demail"/><meta itemprop=3D"name" content=3D"View Change"/></div></div>
<=
div style=3D"display:none"> Gerrit-MessageType: newchange </div>
<div style=
=3D"display:none"> Gerrit-Project: openvpn </div>
<div style=3D"display:non=
e"> Gerrit-Branch: master </div>
<div style=3D"display:none"> Gerrit-Change=
-Id: I3db70001be7f39cf84d562517647f1a305962b42 </div>
<div style=3D"display=
:none"> Gerrit-Change-Number: 1834 </div>
<div style=3D"display:none"> Gerr=
it-PatchSet: 1 </div>
<div style=3D"display:none"> Gerrit-Owner: plaisthos =
<arne-openvpn@rfc2549=2Eorg> </div>
<div style=3D"display:none"> Gerr=
it-CC: openvpn-devel <openvpn-devel@lists=2Esourceforge=2Enet> </div>=
</body></html>
--LyLTOgWmEkY=--
--===============6539555916348876115==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
--===============6539555916348876115==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
--===============6539555916348876115==--