Re: [Openvpn-devel] [PATCH] Make MSVC happy about route.c

2016-01-08 Thread Fish Wang
Thanks for your response. I'll ship a patch for master soon :-)

Best,
Fish

-Original Message-
From: Gert Doering [mailto:g...@greenie.muc.de] 
Sent: Friday, January 8, 2016 10:23 AM
To: Fish <fish.t...@gmail.com>
Cc: openvpn-devel@lists.sourceforge.net
Subject: Re: [Openvpn-devel] [PATCH] Make MSVC happy about route.c

Hi,

On Mon, Dec 14, 2015 at 01:06:16PM -0800, Fish wrote:
> Move the definition of out to the beginning of functions to comply with
> old-style C compilers. Tested on MSVC 2010.
[..]
>  #elif defined (WIN32)
> -
> -  struct buffer out = alloc_buf_gc (64, );
> +  out = alloc_buf_gc(64, );
>buf_printf (, "interface=%d", tt->adapter_index );
>device = buf_bptr();

As things turns out, this is now actually no longer needed in the 
release/2.3 branch, as with the new code from Lev, this looks like:

#elif defined (WIN32)

  if (win32_version_info() != WIN_XP)
{
  struct buffer out = alloc_buf_gc (64, );
  buf_printf (, "interface=%d", tt->adapter_index );
  device = buf_bptr();
}

... and as such, avoids this VS2010 pitfall (thanks anyway!).

Master still has problematic code here, so if VS2010 compatibility is
desired, I'd appreciate a patch for it.

gert

-- 
USENET is *not* the non-clickable part of WWW!

//www.muc.de/~gert/
Gert Doering - Munich, Germany
g...@greenie.muc.de
fax: +49-89-35655025
g...@net.informatik.tu-muenchen.de




Re: [Openvpn-devel] [PATCH] Make MSVC happy about route.c

2016-01-08 Thread Gert Doering
Hi,

On Mon, Dec 14, 2015 at 01:06:16PM -0800, Fish wrote:
> Move the definition of out to the beginning of functions to comply with
> old-style C compilers. Tested on MSVC 2010.
[..]
>  #elif defined (WIN32)
> -
> -  struct buffer out = alloc_buf_gc (64, );
> +  out = alloc_buf_gc(64, );
>buf_printf (, "interface=%d", tt->adapter_index );
>device = buf_bptr();

As things turns out, this is now actually no longer needed in the 
release/2.3 branch, as with the new code from Lev, this looks like:

#elif defined (WIN32)
 
  if (win32_version_info() != WIN_XP)
{
  struct buffer out = alloc_buf_gc (64, );
  buf_printf (, "interface=%d", tt->adapter_index );
  device = buf_bptr();
}
 
... and as such, avoids this VS2010 pitfall (thanks anyway!).

Master still has problematic code here, so if VS2010 compatibility is
desired, I'd appreciate a patch for it.

gert

-- 
USENET is *not* the non-clickable part of WWW!
   //www.muc.de/~gert/
Gert Doering - Munich, Germany g...@greenie.muc.de
fax: +49-89-35655025g...@net.informatik.tu-muenchen.de


signature.asc
Description: PGP signature


Re: [Openvpn-devel] [PATCH] Make MSVC happy about route.c

2015-12-14 Thread Lev Stipakov

ACK.

I don't have VC2010, but at least on 2013 it compiles nicely.



[Openvpn-devel] [PATCH] Make MSVC happy about route.c

2015-12-14 Thread Fish
Move the definition of out to the beginning of functions to comply with
old-style C compilers. Tested on MSVC 2010.
---
 src/openvpn/route.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index cf5a067..c4459f9 100644
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c
@@ -1551,6 +1551,9 @@ add_route_ipv6 (struct route_ipv6 *r6, const struct 
tuntap *tt, unsigned int fla
 {
   struct gc_arena gc;
   struct argv argv;
+#ifdef WIN32
+  struct buffer out;
+#endif

   const char *network;
   const char *gateway;
@@ -1622,8 +1625,7 @@ add_route_ipv6 (struct route_ipv6 *r6, const struct 
tuntap *tt, unsigned int fla
   status = openvpn_execve_check (, es, 0, "ERROR: Linux route -6/-A inet6 
add command failed");

 #elif defined (WIN32)
-
-  struct buffer out = alloc_buf_gc (64, );
+  out = alloc_buf_gc(64, );
   buf_printf (, "interface=%d", tt->adapter_index );
   device = buf_bptr();

@@ -1900,6 +1902,9 @@ delete_route_ipv6 (const struct route_ipv6 *r6, const 
struct tuntap *tt, unsigne
 {
   struct gc_arena gc;
   struct argv argv;
+#ifdef WIN32
+  struct buffer out;
+#endif
   const char *network;
   const char *gateway;
   const char *device = tt->actual_name;
@@ -1958,7 +1963,7 @@ delete_route_ipv6 (const struct route_ipv6 *r6, const 
struct tuntap *tt, unsigne

 #elif defined (WIN32)

-  struct buffer out = alloc_buf_gc (64, );
+  out = alloc_buf_gc(64, );
   buf_printf (, "interface=%d", tt->adapter_index );
   device = buf_bptr();

-- 
2.6.4