From mboxrd@z Thu Jan 1 00:00:00 1970 From: "cron2 (Code Review)" Date: Mon, 15 Dec 2025 15:42:03 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <839b104bfba77cfedd186042b845839a479144cf-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="j+UeS4gVhxQ="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: multi: Fix type handling for hashes, mostly inotify_watchers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: plaisthos , openvpn-devel --j+UeS4gVhxQ= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/13= 12?usp=3Demail ) Change subject: multi: Fix type handling for hashes, mostly inotify_watchers ...................................................................... multi: Fix type handling for hashes, mostly inotify_watchers Change-Id: Idede28c850def5e3b4a17dcbd0a5771f15cfc668 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1312 Message-Id: <20251215145528.18047-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg35= 072.html Signed-off-by: Gert Doering --- M src/openvpn/multi.c 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index d9cb3a9..20d72c1 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -257,7 +257,7 @@ */ int_hash_function(const void *key, uint32_t iv) { - return (unsigned long)key; + return (uint32_t)(uintptr_t)key; } static bool @@ -295,22 +295,23 @@ * to determine which client sent an incoming packet * which is seen on the TCP/UDP socket. */ - m->hash =3D hash_init(t->options.real_hash_size, get_random(), mroute_= addr_hash_function, - mroute_addr_compare_function); + m->hash =3D hash_init(t->options.real_hash_size, (uint32_t)get_random(= ), + mroute_addr_hash_function, mroute_addr_compare_fun= ction); /* * Virtual address hash table. Used to determine * which client to route a packet to. */ - m->vhash =3D hash_init(t->options.virtual_hash_size, get_random(), mro= ute_addr_hash_function, - mroute_addr_compare_function); + m->vhash =3D hash_init(t->options.virtual_hash_size, (uint32_t)get_ran= dom(), + mroute_addr_hash_function, mroute_addr_compare_fu= nction); /* * This hash table is a clone of m->hash but with a * bucket size of one so that it can be used * for fast iteration through the list. */ - m->iter =3D hash_init(1, get_random(), mroute_addr_hash_function, mrou= te_addr_compare_function); + m->iter =3D hash_init(1, (uint32_t)get_random(), mroute_addr_hash_func= tion, + mroute_addr_compare_function); #ifdef ENABLE_MANAGEMENT m->cid_hash =3D hash_init(t->options.real_hash_size, 0, cid_hash_funct= ion, cid_compare_function); @@ -321,8 +322,8 @@ * Mapping between inotify watch descriptors and * multi_instances. */ - m->inotify_watchers =3D - hash_init(t->options.real_hash_size, get_random(), int_hash_functi= on, int_compare_function); + m->inotify_watchers =3D hash_init(t->options.real_hash_size, (uint32_t= )get_random(), + int_hash_function, int_compare_functio= n); #endif /* @@ -609,7 +610,7 @@ #ifdef ENABLE_ASYNC_PUSH if (mi->inotify_watch !=3D -1) { - hash_remove(m->inotify_watchers, (void *)(unsigned long)mi->in= otify_watch); + hash_remove(m->inotify_watchers, (void *)(uintptr_t)mi->inotif= y_watch); mi->inotify_watch =3D -1; } #endif @@ -2821,7 +2822,7 @@ msg(D_MULTI_DEBUG, "MULTI: modified fd %d, mask %d", pevent->wd, p= event->mask); struct multi_instance *mi =3D - hash_lookup(m->inotify_watchers, (void *)(unsigned long)pevent= ->wd); + hash_lookup(m->inotify_watchers, (void *)(uintptr_t)pevent->wd= ); if (pevent->mask & IN_CLOSE_WRITE) { @@ -2840,7 +2841,7 @@ /* this event is _always_ fired when watch is removed or file = is deleted */ if (mi) { - hash_remove(m->inotify_watchers, (void *)(unsigned long)pe= vent->wd); + hash_remove(m->inotify_watchers, (void *)(uintptr_t)pevent= ->wd); mi->inotify_watch =3D -1; } } @@ -2978,14 +2979,14 @@ const char *file) { /* watch acf file */ - long watch_descriptor =3D inotify_add_watch(inotify_fd, file, IN_CLOSE= _WRITE | IN_ONESHOT); + int watch_descriptor =3D inotify_add_watch(inotify_fd, file, IN_CLOSE_= WRITE | IN_ONESHOT); if (watch_descriptor >=3D 0) { if (mi->inotify_watch !=3D -1) { - hash_remove(m->inotify_watchers, (void *)(unsigned long)mi->in= otify_watch); + hash_remove(m->inotify_watchers, (void *)(uintptr_t)mi->inotif= y_watch); } - hash_add(m->inotify_watchers, (const uintptr_t *)watch_descriptor,= mi, true); + hash_add(m->inotify_watchers, (void *)(uintptr_t)watch_descriptor,= mi, true); mi->inotify_watch =3D watch_descriptor; } else -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1312?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: merged Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Idede28c850def5e3b4a17dcbd0a5771f15cfc668 Gerrit-Change-Number: 1312 Gerrit-PatchSet: 10 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --j+UeS4gVhxQ= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 sub= mitted this change.

View Change

multi: Fix type handling for hashes, mostly inot=
ify_watchers

Change-Id: Idede28c850def5e3b4a17dcbd0a5771f15cfc668Signed-off-by: Frank Lichtenheld <frank@...2641...>
Acked-by: Ger= t Doering <gert@...1296...>
Gerrit URL: https://gerrit.openvpn.net= /c/openvpn/+/1312
Message-Id: <20251215145528.18047-1-gert@...1296...= >
URL: https://www.mail-archive.com/openvpn-devel@...1223...= et/msg35072.html
Signed-off-by: Gert Doering <gert@...1296...>
= ---
M src/openvpn/multi.c
1 file changed, 15 insertions(+), 14 deleti= ons(-)

diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
i= ndex d9cb3a9..20d72c1 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c
@@ -257,7 +257,7 @@
*/
int_hash_function(const void *key, uin= t32_t iv)
{
- return (unsigned long)key;
+ return (uint32_t)(uintptr_t)key;
}

static bool
@@ -295,22 +2= 95,23 @@
* to determine which client sent an incoming= packet
* which is seen on the TCP/UDP socket.=
*/
- = m->hash =3D hash_init(t->options.real_hash_size, get_random(), mrout= e_addr_hash_function,
-= mroute_addr_compare_function);
+ m->hash =3D hash_init(t->optio= ns.real_hash_size, (uint32_t)get_random(),
+ mroute_addr_hash_function, m= route_addr_compare_function);

/*

* Virtual address hash table. Used to determine<= br> * which client to route a packet to.
*= /
- m->vhash =3D = hash_init(t->options.virtual_hash_size, get_random(), mroute_addr_hash_f= unction,
- = mroute_addr_compare_function);
+ m->vhash =3D hash_init(t->options.virtual_= hash_size, (uint32_t)get_random(),
+ mroute_addr_hash_function, mroute_a= ddr_compare_function);

/*
= * This hash table is a clone of m->hash but with a * bucket size of one so that it can be used
= * for fast iteration through the list.
*/<= br>- m->iter =3D hash_init(= 1, get_random(), mroute_addr_hash_function, mroute_addr_compare_function);<= /span>
+ m->iter =3D h= ash_init(1, (uint32_t)get_random(), mroute_addr_hash_function,
+ mroute_a= ddr_compare_function);


#ifdef ENABLE_MAN= AGEMENT
m->cid_hash =3D hash_init(t->options.rea= l_hash_size, 0, cid_hash_function, cid_compare_function);
@= @ -321,8 +322,8 @@
* Mapping between inotify watch de= scriptors and
* multi_instances.
= */
- m->inotify= _watchers =3D
- = hash_init(t->options.real_hash_size, get_random(), int_hash_function, in= t_compare_function);
= + m->inotify_watchers =3D hash_init(t->options.real_hash_size, (ui= nt32_t)get_random(),
= + int_hash_function, int_compare_functio= n);
#endif

/*
@@ -609,7 +610,7 @@
#ifdef ENABLE_ASYNC_PUSH
if (mi->inotify_watch !=3D -1)
= {
- h= ash_remove(m->inotify_watchers, (void *)(unsigned long)mi->inotify_wa= tch);
+ ha= sh_remove(m->inotify_watchers, (void *)(uintptr_t)mi->inotify_watch);=
mi->inotify_watch =3D -1;
= }
#endif
@@ -2821,7 +2822,7 @@
msg(D_MULTI_DEBUG, "MULTI: modified fd %d, mask= %d", pevent->wd, pevent->mask);

struct multi_instance *mi =3D

- hash_lookup(m->inotify_watchers, (void *= )(unsigned long)pevent->wd);
+ hash_lookup(m->inotify_watchers, (void *)(uintpt= r_t)pevent->wd);

if (pevent-&= gt;mask & IN_CLOSE_WRITE)
{
@@= -2840,7 +2841,7 @@
/* this event is _always_ = fired when watch is removed or file is deleted */
= if (mi)
{
- hash_remove(m->inotify_watchers, (v= oid *)(unsigned long)pevent->wd);
+ hash_remove(m->inotify_watchers, (void = *)(uintptr_t)pevent->wd);
mi->inotif= y_watch =3D -1;
}
}
@@ -2978,14 +2979,14 @@
= const char *file)
{
/* watch acf = file */
- long watch= _descriptor =3D inotify_add_watch(inotify_fd, file, IN_CLOSE_WRITE | IN_ONE= SHOT);
+ int watch= _descriptor =3D inotify_add_watch(inotify_fd, file, IN_CLOSE_WRITE | IN_ONE= SHOT);
if (watch_descriptor >=3D 0)
{

if (mi->inotify_watch !=3D -1) {
- = hash_remove(m->inotify_watchers, (void *)(unsigned long)mi->= inotify_watch);
+ = hash_remove(m->inotify_watchers, (void *)(uintptr_t)mi->inoti= fy_watch);
}
- hash_add(m->inotify_watchers, (const uintptr_t *= )watch_descriptor, mi, true);
+ hash_add(m->inotify_watchers, (void *)(uintptr_t)watch= _descriptor, mi, true);
mi->inotify_watch =3D w= atch_descriptor;
}
else

To view, visit change 1312. To unsubscribe, or for h= elp writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Idede28c850def5e3b4a17dcbd0a= 5771f15cfc668
Gerrit-Change-Number: 1312
Gerrit-PatchSet: 10
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --j+UeS4gVhxQ=--