Browse code

Remove unused and unecessary argv interfaces

Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Acked-by: David Sommerseth <davids@redhat.com>
Message-Id: <1477672963-5724-3-git-send-email-heiko.hund@sophos.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg12812.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Heiko Hund authored on 2016/10/29 01:42:38
Showing 5 changed files
... ...
@@ -39,7 +39,7 @@
39 39
 #include "argv.h"
40 40
 #include "options.h"
41 41
 
42
-void
42
+static void
43 43
 argv_init (struct argv *a)
44 44
 {
45 45
   a->capacity = 0;
... ...
@@ -157,12 +157,6 @@ argv_extract_cmd_name (const char *path)
157 157
   return ret;
158 158
 }
159 159
 
160
-const char *
161
-argv_system_str (const struct argv *a)
162
-{
163
-  return a->system_str;
164
-}
165
-
166 160
 static struct argv
167 161
 argv_clone (const struct argv *a, const size_t headroom)
168 162
 {
... ...
@@ -199,7 +193,7 @@ argv_insert_head (const struct argv *a, const char *head)
199 199
   return r;
200 200
 }
201 201
 
202
-char *
202
+static char *
203 203
 argv_term (const char **f)
204 204
 {
205 205
   const char *p = *f;
... ...
@@ -272,33 +266,13 @@ argv_msg_prefix (const int msglev, const struct argv *a, const char *prefix)
272 272
   gc_free (&gc);
273 273
 }
274 274
 
275
-void
276
-argv_printf (struct argv *a, const char *format, ...)
277
-{
278
-  va_list arglist;
279
-  va_start (arglist, format);
280
-  argv_printf_arglist (a, format, 0, arglist);
281
-  va_end (arglist);
282
- }
283
-
284
-void
285
-argv_printf_cat (struct argv *a, const char *format, ...)
286
-{
287
-  va_list arglist;
288
-  va_start (arglist, format);
289
-  argv_printf_arglist (a, format, APA_CAT, arglist);
290
-  va_end (arglist);
291
-}
292
-
293
-void
294
-argv_printf_arglist (struct argv *a, const char *format, const unsigned int flags, va_list arglist)
275
+static void
276
+argv_printf_arglist (struct argv *a, const char *format, va_list arglist)
295 277
 {
296 278
   struct gc_arena gc = gc_new ();
297 279
   char *term;
298 280
   const char *f = format;
299 281
 
300
-  if (!(flags & APA_CAT))
301
-    argv_reset (a);
302 282
   argv_extend (a, 1); /* ensure trailing NULL */
303 283
 
304 284
   while ((term = argv_term (&f)) != NULL)
... ...
@@ -409,3 +383,22 @@ argv_printf_arglist (struct argv *a, const char *format, const unsigned int flag
409 409
     }
410 410
   gc_free (&gc);
411 411
 }
412
+
413
+void
414
+argv_printf (struct argv *a, const char *format, ...)
415
+{
416
+  va_list arglist;
417
+  argv_reset (a);
418
+  va_start (arglist, format);
419
+  argv_printf_arglist (a, format, arglist);
420
+  va_end (arglist);
421
+ }
422
+
423
+void
424
+argv_printf_cat (struct argv *a, const char *format, ...)
425
+{
426
+  va_list arglist;
427
+  va_start (arglist, format);
428
+  argv_printf_arglist (a, format, arglist);
429
+  va_end (arglist);
430
+}
... ...
@@ -40,18 +40,12 @@ struct argv {
40 40
   char *system_str;
41 41
 };
42 42
 
43
-void argv_init (struct argv *a);
44 43
 struct argv argv_new (void);
45 44
 void argv_reset (struct argv *a);
46
-char *argv_term (const char **f);
47 45
 const char *argv_str (const struct argv *a, struct gc_arena *gc, const unsigned int flags);
48 46
 struct argv argv_insert_head (const struct argv *a, const char *head);
49 47
 void argv_msg (const int msglev, const struct argv *a);
50 48
 void argv_msg_prefix (const int msglev, const struct argv *a, const char *prefix);
51
-const char *argv_system_str (const struct argv *a);
52
-
53
-#define APA_CAT (1<<0) /* concatentate onto existing struct argv list */
54
-void argv_printf_arglist (struct argv *a, const char *format, const unsigned int flags, va_list arglist);
55 49
 
56 50
 void argv_printf (struct argv *a, const char *format, ...)
57 51
 #ifdef __GNUC__
... ...
@@ -60,9 +60,8 @@ get_console_input_systemd (const char *prompt, const bool echo, char *input, con
60 60
 {
61 61
     int std_out;
62 62
     bool ret = false;
63
-    struct argv argv;
63
+    struct argv argv = argv_new ();
64 64
 
65
-    argv_init (&argv);
66 65
     argv_printf (&argv, SYSTEMD_ASK_PASSWORD_PATH);
67 66
 #ifdef SYSTEMD_NEWER_THAN_216
68 67
     /* the --echo support arrived in upstream systemd 217 */
... ...
@@ -1395,7 +1395,7 @@ add_route (struct route_ipv4 *r,
1395 1395
 	   const struct env_set *es)
1396 1396
 {
1397 1397
   struct gc_arena gc;
1398
-  struct argv argv;
1398
+  struct argv argv = argv_new ();
1399 1399
   const char *network;
1400 1400
   const char *netmask;
1401 1401
   const char *gateway;
... ...
@@ -1406,7 +1406,6 @@ add_route (struct route_ipv4 *r,
1406 1406
     return;
1407 1407
 
1408 1408
   gc_init (&gc);
1409
-  argv_init (&argv);
1410 1409
 
1411 1410
   network = print_in_addr_t (r->network, 0, &gc);
1412 1411
   netmask = print_in_addr_t (r->netmask, 0, &gc);
... ...
@@ -1671,7 +1670,7 @@ void
1671 1671
 add_route_ipv6 (struct route_ipv6 *r6, const struct tuntap *tt, unsigned int flags, const struct env_set *es)
1672 1672
 {
1673 1673
   struct gc_arena gc;
1674
-  struct argv argv;
1674
+  struct argv argv = argv_new ();
1675 1675
 
1676 1676
   const char *network;
1677 1677
   const char *gateway;
... ...
@@ -1693,7 +1692,6 @@ add_route_ipv6 (struct route_ipv6 *r6, const struct tuntap *tt, unsigned int fla
1693 1693
 #endif
1694 1694
 
1695 1695
   gc_init (&gc);
1696
-  argv_init (&argv);
1697 1696
 
1698 1697
   route_ipv6_clear_host_bits (r6);
1699 1698
 
... ...
@@ -1933,7 +1931,7 @@ delete_route (struct route_ipv4 *r,
1933 1933
 	      const struct env_set *es)
1934 1934
 {
1935 1935
   struct gc_arena gc;
1936
-  struct argv argv;
1936
+  struct argv argv = argv_new ();
1937 1937
   const char *network;
1938 1938
   const char *netmask;
1939 1939
   const char *gateway;
... ...
@@ -1943,7 +1941,6 @@ delete_route (struct route_ipv4 *r,
1943 1943
     return;
1944 1944
 
1945 1945
   gc_init (&gc);
1946
-  argv_init (&argv);
1947 1946
 
1948 1947
   network = print_in_addr_t (r->network, 0, &gc);
1949 1948
   netmask = print_in_addr_t (r->netmask, 0, &gc);
... ...
@@ -2108,7 +2105,7 @@ void
2108 2108
 delete_route_ipv6 (const struct route_ipv6 *r6, const struct tuntap *tt, unsigned int flags, const struct env_set *es)
2109 2109
 {
2110 2110
   struct gc_arena gc;
2111
-  struct argv argv;
2111
+  struct argv argv = argv_new ();
2112 2112
   const char *network;
2113 2113
   const char *gateway;
2114 2114
   const char *device = tt->actual_name;
... ...
@@ -2126,7 +2123,6 @@ delete_route_ipv6 (const struct route_ipv6 *r6, const struct tuntap *tt, unsigne
2126 2126
 #endif
2127 2127
 
2128 2128
   gc_init (&gc);
2129
-  argv_init (&argv);
2130 2129
 
2131 2130
   network = print_in6_addr( r6->network, 0, &gc);
2132 2131
   gateway = print_in6_addr( r6->gateway, 0, &gc);
... ...
@@ -753,9 +753,7 @@ do_ifconfig (struct tuntap *tt,
753 753
       const char *ifconfig_ipv6_local = NULL;
754 754
       const char *ifconfig_ipv6_remote = NULL;
755 755
       bool do_ipv6 = false;
756
-      struct argv argv;
757
-
758
-      argv_init (&argv);
756
+      struct argv argv = argv_new ();
759 757
 
760 758
       msg( M_DEBUG, "do_ifconfig, tt->did_ifconfig_ipv6_setup=%d",
761 759
 	            tt->did_ifconfig_ipv6_setup );
... ...
@@ -1864,9 +1862,8 @@ close_tun (struct tuntap *tt)
1864 1864
     {
1865 1865
 	if (tt->type != DEV_TYPE_NULL && tt->did_ifconfig)
1866 1866
 	  {
1867
-	    struct argv argv;
1867
+	    struct argv argv = argv_new ();
1868 1868
 	    struct gc_arena gc = gc_new ();
1869
-	    argv_init (&argv);
1870 1869
 
1871 1870
 #ifdef ENABLE_IPROUTE
1872 1871
 	    if (is_tun_p2p (tt))
... ...
@@ -2149,8 +2146,7 @@ solaris_close_tun (struct tuntap *tt)
2149 2149
       /* IPv6 interfaces need to be 'manually' de-configured */
2150 2150
       if ( tt->did_ifconfig_ipv6_setup )
2151 2151
 	{
2152
-	  struct argv argv;
2153
-	  argv_init (&argv);
2152
+	  struct argv argv = argv_new ();
2154 2153
 	  argv_printf( &argv, "%s %s inet6 unplumb",
2155 2154
 		       IFCONFIG_PATH, tt->actual_name );
2156 2155
 	  argv_msg (M_INFO, &argv);
... ...
@@ -2213,8 +2209,7 @@ static void
2213 2213
 solaris_error_close (struct tuntap *tt, const struct env_set *es, 
2214 2214
                      const char *actual, bool unplumb_inet6 )
2215 2215
 {
2216
-  struct argv argv;
2217
-  argv_init (&argv);
2216
+  struct argv argv = argv_new ();
2218 2217
 
2219 2218
   if (unplumb_inet6)
2220 2219
     {
... ...
@@ -2306,12 +2301,11 @@ close_tun (struct tuntap* tt)
2306 2306
   else if (tt)
2307 2307
     {
2308 2308
       struct gc_arena gc = gc_new ();
2309
-      struct argv argv;
2309
+      struct argv argv = argv_new ();
2310 2310
 
2311 2311
       /* setup command, close tun dev (clears tt->actual_name!), run command
2312 2312
        */
2313 2313
 
2314
-      argv_init (&argv);
2315 2314
       argv_printf (&argv, "%s %s destroy",
2316 2315
                           IFCONFIG_PATH, tt->actual_name);
2317 2316
 
... ...
@@ -2392,12 +2386,11 @@ close_tun (struct tuntap *tt)
2392 2392
   else if (tt)
2393 2393
     {
2394 2394
       struct gc_arena gc = gc_new ();
2395
-      struct argv argv;
2395
+      struct argv argv = argv_new ();
2396 2396
 
2397 2397
       /* setup command, close tun dev (clears tt->actual_name!), run command
2398 2398
        */
2399 2399
 
2400
-      argv_init (&argv);
2401 2400
       argv_printf (&argv, "%s %s destroy",
2402 2401
                           IFCONFIG_PATH, tt->actual_name);
2403 2402
 
... ...
@@ -2512,12 +2505,11 @@ close_tun (struct tuntap *tt)
2512 2512
     }
2513 2513
   else if (tt)				/* close and destroy */
2514 2514
     {
2515
-      struct argv argv;
2515
+      struct argv argv = argv_new ();
2516 2516
 
2517 2517
       /* setup command, close tun dev (clears tt->actual_name!), run command
2518 2518
        */
2519 2519
 
2520
-      argv_init (&argv);
2521 2520
       argv_printf (&argv, "%s %s destroy",
2522 2521
                           IFCONFIG_PATH, tt->actual_name);
2523 2522
 
... ...
@@ -2848,8 +2840,7 @@ close_tun (struct tuntap* tt)
2848 2848
   if (tt)
2849 2849
     {
2850 2850
       struct gc_arena gc = gc_new ();
2851
-      struct argv argv;
2852
-      argv_init (&argv);
2851
+      struct argv argv = argv_new ();
2853 2852
 
2854 2853
       if (tt->did_ifconfig_ipv6_setup )
2855 2854
 	{
... ...
@@ -2899,7 +2890,6 @@ open_tun (const char *dev, const char *dev_type, const char *dev_node, struct tu
2899 2899
   char tunname[256];
2900 2900
   char dynamic_name[20];
2901 2901
   const char *p;
2902
-  struct argv argv;
2903 2902
 
2904 2903
   if (tt->type == DEV_TYPE_NULL)
2905 2904
     {
... ...
@@ -2950,8 +2940,8 @@ open_tun (const char *dev, const char *dev_type, const char *dev_node, struct tu
2950 2950
 
2951 2951
       /* tunnel device must be created with 'ifconfig tapN create'
2952 2952
        */
2953
+      struct argv argv = argv_new ();
2953 2954
       struct env_set *es = env_set_create (NULL);
2954
-      argv_init (&argv);
2955 2955
       argv_printf (&argv, "%s %s create", IFCONFIG_PATH, dev);
2956 2956
       argv_msg (M_INFO, &argv);
2957 2957
       env_set_add( es, "ODMDIR=/etc/objrepos" );
... ...
@@ -2983,15 +2973,13 @@ void
2983 2983
 close_tun (struct tuntap* tt)
2984 2984
 {
2985 2985
   struct gc_arena gc = gc_new ();
2986
-  struct argv argv;
2986
+  struct argv argv = argv_new ();
2987 2987
   struct env_set *es = env_set_create (NULL);
2988 2988
 
2989 2989
   if (!tt) return;
2990 2990
 
2991 2991
   /* persistent devices need IP address unconfig, others need destroyal
2992 2992
    */
2993
-  argv_init (&argv);
2994
-
2995 2993
   if (tt->persistent_if)
2996 2994
     {
2997 2995
       argv_printf (&argv, "%s %s 0.0.0.0 down",
... ...
@@ -4515,15 +4503,13 @@ netsh_command (const struct argv *a, int n, int msglevel)
4515 4515
 void
4516 4516
 ipconfig_register_dns (const struct env_set *es)
4517 4517
 {
4518
-  struct argv argv;
4518
+  struct argv argv = argv_new ();
4519 4519
   bool status;
4520 4520
   const char err[] = "ERROR: Windows ipconfig command failed";
4521 4521
 
4522 4522
   msg (D_TUNTAP_INFO, "Start net commands...");
4523 4523
   netcmd_semaphore_lock ();
4524 4524
 
4525
-  argv_init (&argv);
4526
-
4527 4525
   argv_printf (&argv, "%s%sc stop dnscache",
4528 4526
 	       get_win_sys_path(),
4529 4527
 	       WIN_NET_PATH_SUFFIX);
... ...
@@ -4791,8 +4777,7 @@ static void
4791 4791
 netsh_enable_dhcp (const struct tuntap_options *to,
4792 4792
 		   const char *actual_name)
4793 4793
 {
4794
-  struct argv argv;
4795
-  argv_init (&argv);
4794
+  struct argv argv = argv_new ();
4796 4795
 
4797 4796
   /* example: netsh interface ip set address my-tap dhcp */
4798 4797
   argv_printf (&argv,
... ...
@@ -5558,8 +5543,7 @@ close_tun (struct tuntap *tt)
5558 5558
           else
5559 5559
             {
5560 5560
               const char *ifconfig_ipv6_local;
5561
-              struct argv argv;
5562
-              argv_init (&argv);
5561
+              struct argv argv = argv_new ();
5563 5562
 
5564 5563
               /* remove route pointing to interface */
5565 5564
               delete_route_connected_v6_net(tt, NULL);