]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
tun: Fix compiler warnings
authorDavid Sommerseth <davids@openvpn.net>
Fri, 11 Nov 2016 13:11:13 +0000 (14:11 +0100)
committerDavid Sommerseth <davids@openvpn.net>
Wed, 16 Nov 2016 17:00:54 +0000 (18:00 +0100)
Fixes two compiler warnings identified by using CFLAGS=-O2

1) ifconfig_ipv6_remote is only used on Solaris, move the
   declaration and assignment of this variable into the
   TARGET_SOLARIS block.

2) Linux have it's own open_tun() function and does not
   depend on open_tun_generic() at all.  So exclude
   open_tun_generic() if TARGET_LINUX is defined.

v2 - Move changes from 1) into the proper if() block
     directly
   - Fix up incorrect comment tags related to changes in 2)

v3 - Minor coding style adjustments and change WIN32 to _WIN32

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1479165185-11730-1-git-send-email-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13063.html

src/openvpn/tun.c

index d37e27e763a22525110017b8799d66a2b97ac5d5..3815f0fc8c21ac3a1f432b2256acddc0c8a1a533 100644 (file)
@@ -751,7 +751,6 @@ do_ifconfig (struct tuntap *tt,
       const char *ifconfig_remote_netmask = NULL;
       const char *ifconfig_broadcast = NULL;
       const char *ifconfig_ipv6_local = NULL;
-      const char *ifconfig_ipv6_remote = NULL;
       bool do_ipv6 = false;
       struct argv argv = argv_new ();
 
@@ -772,7 +771,6 @@ do_ifconfig (struct tuntap *tt,
       if (tt->did_ifconfig_ipv6_setup )
         {
          ifconfig_ipv6_local = print_in6_addr (tt->local_ipv6, 0, &gc);
-         ifconfig_ipv6_remote = print_in6_addr (tt->remote_ipv6, 0, &gc);
          do_ipv6 = true;
        }
 
@@ -915,7 +913,6 @@ do_ifconfig (struct tuntap *tt,
       management_android_control (management, "IFCONFIG", buf_bptr(&out));
 
 #elif defined(TARGET_SOLARIS)
-
       /* Solaris 2.6 (and 7?) cannot set all parameters in one go...
        * example:
        *    ifconfig tun2 10.2.0.2 10.2.0.1 mtu 1450 up
@@ -977,6 +974,9 @@ do_ifconfig (struct tuntap *tt,
 
          if ( tt->type == DEV_TYPE_TUN )
           {
+             const char *ifconfig_ipv6_remote =
+                ifconfig_ipv6_remote = print_in6_addr (tt->remote_ipv6, 0, &gc);
+
              argv_printf (&argv,
                            "%s %s inet6 plumb %s/%d %s up",
                            IFCONFIG_PATH,
@@ -1502,7 +1502,7 @@ read_tun_header (struct tuntap* tt, uint8_t *buf, int len)
 #endif
 
 
-#ifndef _WIN32
+#if !(defined(_WIN32) || defined(TARGET_LINUX))
 static void
 open_tun_generic (const char *dev, const char *dev_type, const char *dev_node,
                  bool dynamic, struct tuntap *tt)
@@ -1604,7 +1604,9 @@ open_tun_generic (const char *dev, const char *dev_type, const char *dev_node,
       tt->actual_name = string_alloc (dynamic_opened ? dynamic_name : dev, NULL);
     }
 }
+#endif /* !_WIN32 && !TARGET_LINUX */
 
+#if !defined(_WIN32)
 static void
 close_tun_generic (struct tuntap *tt)
 {
@@ -1614,8 +1616,7 @@ close_tun_generic (struct tuntap *tt)
     free (tt->actual_name);
   clear_tuntap (tt);
 }
-
-#endif
+#endif /* !_WIN32 */
 
 #if defined (TARGET_ANDROID)
 void