From: "cron2 (Code Review)" Date: Wed, 24 Sep 2025 07:43:31 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="GY1HHaxtu3c="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: multi_io_init: simplify List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: plaisthos , openvpn-devel --GY1HHaxtu3c= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/12= 09?usp=3Demail ) Change subject: multi_io_init: simplify ...................................................................... multi_io_init: simplify We take two values and try to massage them in various ways. But this function only has one caller and that puts exactly the same value into both of them. So simplify the code. Change-Id: I9cb8aa6ef01445cb99758583aba8ae8f9ded0862 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1209 Message-Id: <20250923160459.32273-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg33= 176.html Signed-off-by: Gert Doering --- M src/openvpn/multi.c M src/openvpn/multi_io.c M src/openvpn/multi_io.h 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index 9256127..1d2ee53 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -411,7 +411,7 @@ /* * Initialize multi-socket I/O wait object */ - m->multi_io =3D multi_io_init(t->options.max_clients, &m->max_clients); + m->multi_io =3D multi_io_init(m->max_clients); m->tcp_queue_limit =3D t->options.tcp_queue_limit; /* diff --git a/src/openvpn/multi_io.c b/src/openvpn/multi_io.c index ece789c..0bfbb63 100644 --- a/src/openvpn/multi_io.c +++ b/src/openvpn/multi_io.c @@ -113,21 +113,18 @@ } struct multi_io * -multi_io_init(int maxevents, int *maxclients) +multi_io_init(const int maxclients) { struct multi_io *multi_io; - const int extra_events =3D BASE_N_EVENTS; - ASSERT(maxevents >=3D 1); - ASSERT(maxclients); + ASSERT(maxclients >=3D 1); ALLOC_OBJ_CLEAR(multi_io, struct multi_io); - multi_io->maxevents =3D maxevents + extra_events; + multi_io->maxevents =3D maxclients + BASE_N_EVENTS; multi_io->es =3D event_set_init(&multi_io->maxevents, 0); wait_signal(multi_io->es, MULTI_IO_SIG); ALLOC_ARRAY(multi_io->esr, struct event_set_return, multi_io->maxevent= s); - *maxclients =3D max_int(min_int(multi_io->maxevents - extra_events, *m= axclients), 1); - msg(D_MULTI_LOW, "MULTI IO: MULTI_IO INIT maxclients=3D%d maxevents=3D= %d", *maxclients, + msg(D_MULTI_LOW, "MULTI IO: MULTI_IO INIT maxclients=3D%d maxevents=3D= %d", maxclients, multi_io->maxevents); return multi_io; } diff --git a/src/openvpn/multi_io.h b/src/openvpn/multi_io.h index 07eb3d4..4a3c60d 100644 --- a/src/openvpn/multi_io.h +++ b/src/openvpn/multi_io.h @@ -61,7 +61,7 @@ #endif }; -struct multi_io *multi_io_init(int maxevents, int *maxclients); +struct multi_io *multi_io_init(int maxclients); void multi_io_free(struct multi_io *multi_io); -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1209?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I9cb8aa6ef01445cb99758583aba8ae8f9ded0862 Gerrit-Change-Number: 1209 Gerrit-PatchSet: 2 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --GY1HHaxtu3c= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

multi_io_init: simplify

We take two va= lues and try to massage them in various
ways. But this function only has= one caller and that
puts exactly the same value into both of them. Sosimplify the code.

Change-Id: I9cb8aa6ef01445cb99758583aba8ae8f9de= d0862
Signed-off-by: Frank Lichtenheld <frank@...2641...>
Acked= -by: Gert Doering <gert@...1296...>
Gerrit URL: https://gerrit.ope= nvpn.net/c/openvpn/+/1209
Message-Id: <20250923160459.32273-1-gert@...1186...= .1296...>
URL: https://www.mail-archive.com/openvpn-devel@...1011...= eforge.net/msg33176.html
Signed-off-by: Gert Doering <gert@...1296...= >
---
M src/openvpn/multi.c
M src/openvpn/multi_io.c
M src/o= penvpn/multi_io.h
3 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
i= ndex 9256127..1d2ee53 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c
@@ -411,7 +411,7 @@
/*
* Initialize multi-socket I/O = wait object
*/
- m->multi_io =3D multi_io_init(t->options.max_clien= ts, &m->max_clients);
+ m->multi_io =3D multi_io_init(m->max_clients); m->tcp_queue_limit =3D t->options.tcp_queue_limit;=

/*
diff --git a/src/openvp= n/multi_io.c b/src/openvpn/multi_io.c
index ece789c..0bfbb6= 3 100644
--- a/src/openvpn/multi_io.c
+++ b= /src/openvpn/multi_io.c
@@ -113,21 +113,18 @@
}


struct multi_io *
-multi_io_init(int maxevents, int *maxc= lients)
+multi_io_ini= t(const int maxclients)
{
struct mult= i_io *multi_io;
- co= nst int extra_events =3D BASE_N_EVENTS;

- ASSERT(maxevents >=3D 1);=
- ASSERT(maxclients);
+ ASSERT(maxclients &g= t;=3D 1);

ALLOC_OBJ_CLEAR(multi_io, = struct multi_io);
- = multi_io->maxevents =3D maxevents + extra_events;
+ multi_io->maxevents =3D maxclients= + BASE_N_EVENTS;
multi_io->es =3D event_set_init(&= amp;multi_io->maxevents, 0);
wait_signal(multi_io-&= gt;es, MULTI_IO_SIG);
ALLOC_ARRAY(multi_io->esr, st= ruct event_set_return, multi_io->maxevents);
- *maxclients =3D max_int(min_int(multi_io->= maxevents - extra_events, *maxclients), 1);
- msg(D_MULTI_LOW, "MULTI IO: MULTI_IO INIT ma= xclients=3D%d maxevents=3D%d", *maxclients,
+ msg(D_MULTI_LOW, "MULTI IO: MULTI_IO = INIT maxclients=3D%d maxevents=3D%d", maxclients,
= multi_io->maxevents);
return multi_io;<= br> }
diff --git a/src/openvpn/multi_io.h b/src/openv= pn/multi_io.h
index 07eb3d4..4a3c60d 100644
--- a/src/openvpn/multi_io.h

+++ b/src/openvpn/multi_io.h<= /span>
@@ -61,7 +61,7 @@
#endif
= };

-s= truct multi_io *multi_io_init(int maxevents, int *maxclients);
+struct multi_io *multi_io_init(i= nt maxclients);


void multi_io_free(struc= t multi_io *multi_io);


<= p>To view, visit change 1209. To unsubscribe, or for help writing mail filters= , visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9cb8aa6ef01445cb99758583aba= 8ae8f9ded0862
Gerrit-Change-Number: 1209
Gerrit-PatchSet: 2
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>
Gerrit-MessageType: merged
--GY1HHaxtu3c=--