]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
options: drop useless init_gc param for init_options()
authorAntonio Quartulli <antonio@mandelbit.com>
Tue, 17 Feb 2026 13:56:05 +0000 (14:56 +0100)
committerGert Doering <gert@greenie.muc.de>
Sat, 28 Feb 2026 09:55:38 +0000 (10:55 +0100)
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 <antonio@mandelbit.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1536
Message-Id: <20260217135605.154129-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg35695.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 92937c267b20e3e1ffd4e0e80d8048a57da7edb6)

src/openvpn/openvpn.c
src/openvpn/options.c
src/openvpn/options.h
tests/unit_tests/openvpn/test_options_parse.c

index b7eca1962f436ac4102a91d6930cf73e398420e2..f38660f2a25be66d2d5fede8f129248118654cd8 100644 (file)
@@ -202,7 +202,7 @@ openvpn_main(int argc, char *argv[])
 #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, NULL, c.es);
index 2bca6474c299a3a5e6f9471dbb1540bc22a96c86..8a47cd0758e3ac92a789b3364c7307fa9d1c8898 100644 (file)
@@ -797,15 +797,12 @@ static const char usage_message[] =
  * 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 = true;
-    }
+    gc_init(&o->gc);
+    gc_init(&o->dns_options.gc);
+
     o->mode = MODE_POINT_TO_POINT;
     o->topology = TOP_UNDEF;
     o->ce.proto = PROTO_UDP;
@@ -933,11 +930,9 @@ uninit_options(struct options *o)
     {
         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
@@ -2267,7 +2262,7 @@ options_postprocess_verify_ce(const struct options *options, const struct connec
     int dev = DEV_TYPE_UNDEF;
     bool pull = false;
 
-    init_options(&defaults, true);
+    init_options(&defaults);
 
     if (!options->test_crypto)
     {
@@ -4842,7 +4837,7 @@ usage(void)
 #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_port, TUN_MTU_DEFAULT,
@@ -5997,7 +5992,7 @@ add_option(struct options *options, char *p[], bool is_inline, const char *file,
             struct options sub;
             struct connection_entry *e;
 
-            init_options(&sub, true);
+            init_options(&sub);
             sub.ce = options->ce;
             read_config_string("[CONNECTION-OPTIONS]", &sub, p[1], msglevel, OPT_P_CONNECTION,
                                option_types_found, es);
index 16cfdb53d91c374ae9d1bcde21ea5b42af254bb1..781c258d3832f75a91d6d1977d2a349d29a196fc 100644 (file)
@@ -254,7 +254,6 @@ struct verify_hash_list
 struct options
 {
     struct gc_arena gc;
-    bool gc_owned;
 
     /* first config file */
     const char *config;
@@ -893,7 +892,7 @@ void show_windows_version(const unsigned int flags);
 
 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);
 
index bb34f01e4a6d733a781db69c6eea04fb479f34b2..0b3d7fe2596b03baa44af9442a61a920b73e4a9f 100644 (file)
@@ -248,7 +248,6 @@ test_read_config(void **state)
     CLEAR(o); /* NB: avoiding init_options to limit dependencies */
     gc_init(&o.gc);
     gc_init(&o.dns_options.gc);
-    o.gc_owned = true;
 
     char *p_expect_someopt[MAX_PARMS];
     char *p_expect_otheropt[MAX_PARMS];