[Openvpn-devel,v1] Remove unused gc_arena variables

Message ID 20261109124623.26716-1-gert@greenie.muc.de
State New
Headers
Series [Openvpn-devel,v1] Remove unused gc_arena variables |

Commit Message

Gert Doering Nov. 9, 2026, 12:46 p.m. UTC
  From: Razvan Cojocaru <razvanc@mailbox.org>

These functions create and free a gc_arena they never allocate from.

Change-Id: Iefcc3cb90f3e6b036a584a74268678dbc17da69f
Signed-off-by: Razvan Cojocaru <razvanc@mailbox.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2149
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2149
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <frank@lichtenheld.com>
  

Patch

diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index ff3bfe5..3bc4de4 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -117,8 +117,6 @@ 
             const char *ifconfig_remote, const char *context, const char *signal_text,
             const char *script_type, struct env_set *es)
 {
-    struct gc_arena gc = gc_new();
-
     if (signal_text)
     {
         setenv_str(es, "signal", signal_text);
@@ -174,8 +172,6 @@ 
         openvpn_run_script(&argv, es, S_FATAL, "--up/--down");
         argv_free(&argv);
     }
-
-    gc_free(&gc);
 }
 
 /*
diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c
index 58f63e6..3410253 100644
--- a/src/openvpn/manage.c
+++ b/src/openvpn/manage.c
@@ -2325,9 +2325,7 @@ 
 
     if (!ignore_sys_error(err, crt_error))
     {
-        struct gc_arena gc = gc_new();
         msg(D_MANAGEMENT, "MANAGEMENT: TCP %s error: %s", prefix, strerror(err));
-        gc_free(&gc);
         return true;
     }
     else
@@ -3151,11 +3149,8 @@ 
 management_notify_client_cr_response(unsigned mda_key_id, const struct man_def_auth_context *mdac,
                                      const struct env_set *es, const char *response)
 {
-    struct gc_arena gc;
     if (management)
     {
-        gc = gc_new();
-
         msg(M_CLIENT, ">CLIENT:CR_RESPONSE,%lu,%u,%s", mdac->cid, mda_key_id, response);
         man_output_extra_env(management, "CLIENT");
         if (management->connection.env_filter_level > 0)
@@ -3163,7 +3158,6 @@ 
             man_output_peer_info_env(management, mdac);
         }
         man_output_env(es, true, management->connection.env_filter_level, "CLIENT");
-        gc_free(&gc);
     }
 }
 
diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
index 3f514d6..3e25a6e 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c
@@ -726,7 +726,6 @@ 
 multi_create_instance(struct multi_context *m, const struct mroute_addr *real,
                       struct link_socket *sock)
 {
-    struct gc_arena gc = gc_new();
     struct multi_instance *mi;
 
     msg(D_MULTI_MEDIUM, "MULTI: multi_create_instance called");
@@ -792,12 +791,10 @@ 
     mi->ev_arg.type = EVENT_ARG_MULTI_INSTANCE;
     mi->ev_arg.u.mi = mi;
 
-    gc_free(&gc);
     return mi;
 
 err:
     multi_close_instance(m, mi, false);
-    gc_free(&gc);
     return NULL;
 }
 
@@ -2243,7 +2240,6 @@ 
     if (mi->context.options.client_connect_script)
     {
         struct argv argv = argv_new();
-        struct gc_arena gc = gc_new();
 
         setenv_str(mi->context.c2.es, "script_type", "client-connect");
 
@@ -2279,7 +2275,6 @@ 
             ccs_delete_deferred_ret_file(mi);
         }
         argv_free(&argv);
-        gc_free(&gc);
     }
     return ret;
 }
diff --git a/src/openvpn/options_string.c b/src/openvpn/options_string.c
index cfc0595..ed4d742 100644
--- a/src/openvpn/options_string.c
+++ b/src/openvpn/options_string.c
@@ -344,7 +344,6 @@ 
 bool
 options_cmp_equal_safe(char *actual, const char *expected, size_t actual_n)
 {
-    struct gc_arena gc = gc_new();
     bool ret = true;
 
     if (actual_n > 0)
@@ -360,7 +359,6 @@ 
             ret = !strcmp(actual, expected);
         }
     }
-    gc_free(&gc);
     return ret;
 }
 
diff --git a/src/openvpn/plugin.c b/src/openvpn/plugin.c
index 08461b8..d1f228e 100644
--- a/src/openvpn/plugin.c
+++ b/src/openvpn/plugin.c
@@ -560,7 +560,6 @@ 
 
     if (p->plugin_handle && (p->plugin_type_mask & OPENVPN_PLUGIN_MASK(type)))
     {
-        struct gc_arena gc = gc_new();
         struct argv a = argv_insert_head(av, p->so_pathname);
 
         dmsg(D_PLUGIN_DEBUG, "PLUGIN_CALL: PRE type=%s", plugin_type_name(type));
@@ -609,7 +608,6 @@ 
         }
 
         argv_free(&a);
-        gc_free(&gc);
     }
     return status;
 }
diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index 53550c4..d0d26c6 100644
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c
@@ -3090,7 +3090,6 @@ 
 void
 get_default_gateway(struct route_gateway_info *rgi, in_addr_t dest, openvpn_net_ctx_t *ctx)
 {
-    struct gc_arena gc = gc_new();
     int sd = -1;
     char best_name[IFNAMSIZ];
 
@@ -3216,7 +3215,6 @@ 
     {
         close(sd);
     }
-    gc_free(&gc);
 }
 
 /* IPv6 implementation using netlink
diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c
index 307b5c6..1fbd07b 100644
--- a/src/openvpn/socket.c
+++ b/src/openvpn/socket.c
@@ -499,7 +499,6 @@ 
                      const struct addrinfo *local, bool do_listen,
                      bool nowait, volatile int *signal_received)
 {
-    struct gc_arena gc = gc_new();
     socket_descriptor_t new_sd = SOCKET_UNDEFINED;
 
     CLEAR(*act);
@@ -521,7 +520,6 @@ 
         get_signal(signal_received);
         if (*signal_received)
         {
-            gc_free(&gc);
             return sd;
         }
 
@@ -552,7 +550,6 @@ 
 
     tcp_connection_established(act);
 
-    gc_free(&gc);
     return new_sd;
 }
 
@@ -803,8 +800,6 @@ 
 static void
 resolve_bind_local(struct link_socket *sock)
 {
-    struct gc_arena gc = gc_new();
-
     /* resolve local address if undefined */
     if (!sock->info.lsa->bind_local)
     {
@@ -846,8 +841,6 @@ 
             sock->info.af = (sa_family_t)sock->info.lsa->bind_local->ai_family;
         }
     }
-
-    gc_free(&gc);
 }
 
 static void
@@ -2673,7 +2666,6 @@ 
 void
 socket_bind_unix(socket_descriptor_t sd, struct sockaddr_un *local, const char *prefix)
 {
-    struct gc_arena gc = gc_new();
     const mode_t orig_umask = umask(0);
 
     if (bind(sd, (struct sockaddr *)local, sizeof(struct sockaddr_un)))
@@ -2683,7 +2675,6 @@ 
     }
 
     umask(orig_umask);
-    gc_free(&gc);
 }
 
 socket_descriptor_t
diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index 943ad9f..bcea331 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -666,7 +666,6 @@ 
 void
 warn_on_use_of_common_subnets(openvpn_net_ctx_t *ctx)
 {
-    struct gc_arena gc = gc_new();
     struct route_gateway_info rgi;
     const unsigned int needed = (RGI_ADDR_DEFINED | RGI_NETMASK_DEFINED);
 
@@ -680,7 +679,6 @@ 
                 "NOTE: your local LAN uses the extremely common subnet address 192.168.0.x or 192.168.1.x.  Be aware that this might create routing conflicts if you connect to the VPN server from public locations such as internet cafes that use the same subnet.");
         }
     }
-    gc_free(&gc);
 }
 
 /*