Skip to contentSkip to conversation

tun.c on WIN32: remove more unused variables

PATCH In review [email protected]... 3 participants 3 messages Apr 3, 2021 – Apr 4, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tun.c on WIN32: remove more unused variables

From: Selva Nair <[email protected]...>

Fixes:
tun.c: In function ‘do_ifconfig_ipv4’:
tun.c:1217:17: warning: variable ‘ifconfig_remote_netmask’ set but not used [-Wunused-but-set-variable]

     const char *ifconfig_remote_netmask = NULL;
  tun.c:1213:10: warning: unused variable ‘tun’ [-Wunused-variable]
     bool tun = is_tun_p2p(tt);
---
 src/openvpn/tun.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
src/openvpn/tun.c +3 -1
index 6b7c8ef1..8ff825f4 100644
@@ -1207,10 +1207,12 @@ static void
 do_ifconfig_ipv4(struct tuntap *tt, const char *ifname, int tun_mtu,
                  const struct env_set *es, openvpn_net_ctx_t *ctx)
 {
+#if !defined(_WIN32) && !defined(TARGET_ANDROID)
     /*
      * We only handle TUN/TAP devices here, not --dev null devices.
      */
     bool tun = is_tun_p2p(tt);
+#endif
 
 #if !defined(TARGET_LINUX)
     const char *ifconfig_local = NULL;
@@ -1534,7 +1536,7 @@ do_ifconfig_ipv4(struct tuntap *tt, const char *ifname, int tun_mtu,
         msg(M_INFO,
             "******** NOTE:  Please manually set the IP/netmask of '%s' to %s/%s (if it is not already set)",
             ifname, ifconfig_local,
-            print_in_addr_t(tt->adapter_netmask, 0, &gc));
+            ifconfig_remote_netmask);
     }
     else if (tt->options.ip_win32_type == IPW32_SET_DHCP_MASQ || tt->options.ip_win32_type == IPW32_SET_ADAPTIVE)
     {
Signature · 1 line
2.20.1
Acked-by on v1 1/1
#1 lore raw

Hi,

Quoted 21 lines · On 03/04/2021 19:24, [email protected]... wrote:

From: Selva Nair <[email protected]...>

Fixes:
tun.c: In function ‘do_ifconfig_ipv4’:
tun.c:1217:17: warning: variable ‘ifconfig_remote_netmask’ set but not used [-Wunused-but-set-variable]

     const char *ifconfig_remote_netmask = NULL;
  tun.c:1213:10: warning: unused variable ‘tun’ [-Wunused-variable]
     bool tun = is_tun_p2p(tt);
---
 src/openvpn/tun.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
src/openvpn/tun.c +0 -0
index 6b7c8ef1..8ff825f4 100644

src/openvpn/tun.c static void · line 1208

Quoted 2 lines
src/openvpn/tun.c +0 -0
@@ -1207,10 +1207,12 @@ static void
 do_ifconfig_ipv4(struct tuntap *tt, const char *ifname, int tun_mtu,
                  const struct env_set *es, openvpn_net_ctx_t *ctx)

this function....it's an ifdef trap.

Quoted 11 lines
src/openvpn/tun.c +2 -0
 {
+#if !defined(_WIN32) && !defined(TARGET_ANDROID)
     /*
      * We only handle TUN/TAP devices here, not --dev null devices.
      */
     bool tun = is_tun_p2p(tt);
+#endif
 
 #if !defined(TARGET_LINUX)
     const char *ifconfig_local = NULL;

src/openvpn/tun.c do_ifconfig_ipv4(struct tuntap *tt, const char *ifname, int tun_mtu, · line 1539

Quoted 5 lines
src/openvpn/tun.c +1 -1
@@ -1534,7 +1536,7 @@ do_ifconfig_ipv4(struct tuntap *tt, const char *ifname, int tun_mtu,
         msg(M_INFO,
             "******** NOTE:  Please manually set the IP/netmask of '%s' to %s/%s (if it is not already set)",
             ifname, ifconfig_local,
-            print_in_addr_t(tt->adapter_netmask, 0, &gc));
+            ifconfig_remote_netmask);

I think this should just go on the line above?
It will still fit our 80 chars limit.

src/openvpn/tun.c do_ifconfig_ipv4(struct tuntap *tt, const char *ifname, int tun_mtu, · line 1542

Quoted 4 lines
src/openvpn/tun.c +0 -0
     }
     else if (tt->options.ip_win32_type == IPW32_SET_DHCP_MASQ || tt->options.ip_win32_type == IPW32_SET_ADAPTIVE)
     {

Rest looks good.

Compile tested on linux and windows, but couldn't test android. Still I visually verified that this variable is indeed not used in windows and android blocks only (used in all other cases).

Signature · 1 line
Antonio Quartulli
#2 lore raw
In reply to [email protected]...

Test compiled on Ubuntu/MinGW ("just to be sure"). All good.

Your patch has been applied to the master branch.

commit 165cda3169a860186e0446927e80986c31a837ca

Author: Selva Nair
Date:   Sat Apr 3 13:24:03 2021 -0400
     tun.c on WIN32: remove more unused variables

     Signed-off-by: Selva Nair <[email protected]...>
     Acked-by: Antonio Quartulli <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg22019.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering