From: "ordex (Code Review)" Date: Mon, 16 Feb 2026 23:13:21 +0000 References: Reply-To: antonio@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <379b10303b5641f3f002d2a550e67bb558cba9cd-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="apqdCczSIWo="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: options: drop useless init_gc param for init_options() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --apqdCczSIWo= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1536?usp=3Demail to review the following change. Change subject: options: drop useless init_gc param for init_options() ...................................................................... options: drop useless init_gc param for init_options() The init_option() function is always invoked with the second param "init_gc" set to "true". This makes the parameter useless and it can therefore be removed while always taking the "true" branch in the related logic. This way we can also drop the options->gc_owned member as it would also be always set to true. Change-Id: I633d8cbf75ab4da85e16df44684aef60523811c5 Signed-off-by: Antonio Quartulli --- M src/openvpn/openvpn.c M src/openvpn/options.c M src/openvpn/options.h 3 files changed, 12 insertions(+), 18 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/36/1536/1 diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c index b7eca19..f38660f 100644 --- a/src/openvpn/openvpn.c +++ b/src/openvpn/openvpn.c @@ -202,7 +202,7 @@ #endif /* initialize options to default state */ - init_options(&c.options, true); + init_options(&c.options); /* parse command line options, and read configuration file */ parse_argv(&c.options, argc, argv, M_USAGE, OPT_P_DEFAULT, NUL= L, c.es); diff --git a/src/openvpn/options.c b/src/openvpn/options.c index cdb02e9..4e1e32a 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -792,15 +792,12 @@ * will be set to 0. */ void -init_options(struct options *o, const bool init_gc) +init_options(struct options *o) { CLEAR(*o); - if (init_gc) - { - gc_init(&o->gc); - gc_init(&o->dns_options.gc); - o->gc_owned =3D true; - } + gc_init(&o->gc); + gc_init(&o->dns_options.gc); + o->mode =3D MODE_POINT_TO_POINT; o->topology =3D TOP_UNDEF; o->ce.proto =3D PROTO_UDP; @@ -925,11 +922,9 @@ { CLEAR(*o->remote_list); } - if (o->gc_owned) - { - gc_free(&o->gc); - gc_free(&o->dns_options.gc); - } + + gc_free(&o->gc); + gc_free(&o->dns_options.gc); } #ifndef ENABLE_SMALL @@ -2256,7 +2251,7 @@ int dev =3D DEV_TYPE_UNDEF; bool pull =3D false; - init_options(&defaults, true); + init_options(&defaults); if (!options->test_crypto) { @@ -4824,7 +4819,7 @@ #else struct options o; - init_options(&o, true); + init_options(&o); fprintf(fp, usage_message, title_string, o.ce.connect_retry_seconds, o.ce.connect_retry_seconds_max, o.ce.local_port, o.ce.remote_p= ort, TUN_MTU_DEFAULT, @@ -5979,7 +5974,7 @@ struct options sub; struct connection_entry *e; - init_options(&sub, true); + init_options(&sub); sub.ce =3D options->ce; read_config_string("[CONNECTION-OPTIONS]", &sub, p[1], msgleve= l, OPT_P_CONNECTION, option_types_found, es); diff --git a/src/openvpn/options.h b/src/openvpn/options.h index cf9936b..3d8b505 100644 --- a/src/openvpn/options.h +++ b/src/openvpn/options.h @@ -254,7 +254,6 @@ struct options { struct gc_arena gc; - bool gc_owned; /* first config file */ const char *config; @@ -890,7 +889,7 @@ void show_dco_version(const unsigned int flags); -void init_options(struct options *o, const bool init_gc); +void init_options(struct options *o); void uninit_options(struct options *o); -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1536?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I633d8cbf75ab4da85e16df44684aef60523811c5 Gerrit-Change-Number: 1536 Gerrit-PatchSet: 1 Gerrit-Owner: ordex Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --apqdCczSIWo= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: plaisthos.

ordex would like plaisthos to review this change.

V= iew Change

options: drop useless init_gc param for ini=
t_options()

The init_option() function is always invoked with the se= cond
param "init_gc" set to "true".
This makes th= e parameter useless and it can therefore be removed
while always taking = the "true" branch in the related logic.

This way we can al= so drop the options->gc_owned member as it
would also be always set t= o true.

Change-Id: I633d8cbf75ab4da85e16df44684aef60523811c5
Sign= ed-off-by: Antonio Quartulli <antonio@...2726...>
---
M src/ope= nvpn/openvpn.c
M src/openvpn/options.c
M src/openvpn/options.h
3 f= iles changed, 12 insertions(+), 18 deletions(-)

=
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/36/1536/1
diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c
index b7eca19..f38660f 100644
--- a/src/openvpn/openvpn= .c
+++ b/src/openvpn/openvpn.c
@@ -202,7 +2= 02,7 @@
#endif

= /* initialize options to default state */
- init_options(&c.options, true);
+ init_option= s(&c.options);

/* parse = command line options, and read configuration file */
= parse_argv(&c.options, argc, argv, M_USAGE, OPT_P_DEFAULT, NULL,= c.es);
diff --git a/src/openvpn/options.c b/src/openvpn/op= tions.c
index cdb02e9..4e1e32a 100644
--- a= /src/openvpn/options.c
+++ b/src/openvpn/options.c@@ -792,15 +792,12 @@
* will be set to 0.<= br> */
void
-init_options(struct options *o, const bool init_gc)+init_options(struct options *= o)
{
CLEAR(*o);
- if (init_gc)
- {
- gc_init(&o->gc);
- gc_init(&o->dns_options.gc);
= - o->gc_owned =3D true;=
- }
+ gc_init(&o->gc);
<= br>+ gc_init(&o->dns_= options.gc);
+=
o->mode =3D MODE_POINT_TO_POINT;
o-&= gt;topology =3D TOP_UNDEF;
o->ce.proto =3D PROTO_UD= P;
@@ -925,11 +922,9 @@
{
CLEAR(*o->remote_list);
}
- if (o->gc_owned)
= - {
- gc_free(&o->gc);
- gc_free(&o->dns_options= .gc);
- }
= +
+ gc_free(&o->gc);
+ gc_free(&o->dns_options.gc);
}

#ifndef ENABLE_SMALL
@@ -2256,7 +2251,7 @@
int dev =3D DEV_T= YPE_UNDEF;
bool pull =3D false;

- init_options(&defa= ults, true);
+ ini= t_options(&defaults);

if (!optio= ns->test_crypto)
{
@@ -4824,7 +4819= ,7 @@
#else

struct = options o;
- init_op= tions(&o, true);
= + init_options(&o);

fprintf(f= p, usage_message, title_string, o.ce.connect_retry_seconds,
o.ce.connect_retry_seconds_max, o.ce.local_port, o.ce.remote_= port, TUN_MTU_DEFAULT,

@@ -5979,7 +5974,7 @@
struct options sub;

struct conn= ection_entry *e;

- init_options(&sub, true);
+ init_options(&sub);
sub.ce =3D options->ce;
= read_config_string("[CONNECTION-OPTIONS]", &sub, p[1], = msglevel, OPT_P_CONNECTION,
= option_types_found, es);
diff --git a/src/openvpn/options.= h b/src/openvpn/options.h
index cf9936b..3d8b505 100644
--- a/src/openvpn/options.h
+++ b/src/openvpn/= options.h
@@ -254,7 +254,6 @@
struct optio= ns
{
struct gc_arena gc;
- bool gc_owned;


/* first config file */
const = char *config;
@@ -890,7 +889,7 @@
<= br> void show_dco_version(const unsigned int flags);
=
-void init_options(st= ruct options *o, const bool init_gc);
+void init_options(struct options *o);

void uninit_options(struct options *o);


To view, visit change 1536. To unsubscribe, = or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I633d8cbf75ab4da85e16df44684= aef60523811c5
Gerrit-Change-Number: 1536
Gerrit-PatchSet: 1
Gerrit-Owner: ordex <antonio@...2726...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
= --apqdCczSIWo=--