Re: [Openvpn-devel] [PATCH v3] msvc: fix various level2 warnings

2020-06-26 Thread Gert Doering
Hi,

On Thu, Jun 25, 2020 at 01:31:39PM +0300, Lev Stipakov wrote:
>  case AF_INET:
>  if (setsockopt
> -(sd, IPPROTO_IP, IP_MTU_DISCOVER, _type, 
> sizeof(mtu_type)))
> +(sd, IPPROTO_IP, IP_MTU_DISCOVER, (const char 
> *)_type, sizeof(mtu_type)))

If windows really needs a cast here, please cast to (void *).

Windows can then cast to "const char *" under the hood - which should be
warning free.  But for all other platforms, casting to "const char *" is
not a good change (other parts of socket.c use "void *" already today).

If you are touching the lines anway, please add sensible line wrapping, 
like:

case AF_INET:
if (setsockopt(sd, IPPROTO_IP, IP_MTU_DISCOVER, 
   (void *) _type, sizeof(mtu_ type)))

and not this very weird style with wrapping after the function name.

(Whatever uncrustify might have been thinking, it's ugly)

gert
-- 
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
 Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany g...@greenie.muc.de


signature.asc
Description: PGP signature
___
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel


[Openvpn-devel] [PATCH v3] msvc: fix various level2 warnings

2020-06-25 Thread Lev Stipakov
From: Lev Stipakov 

Also set warnings level to level2 and
enable "treat warnings as errors" flag.

Signed-off-by: Lev Stipakov 
---

 v3:
  - use proper format specifier for unsigned long long
  - add comment about cast for qsort()
  - remove unused parameter in delete_route_connected_v6_net() 

 v2:
  - rebase on top of master

 src/compat/Debug.props   |  1 -
 src/openvpn/block_dns.c  |  3 ---
 src/openvpn/crypto_openssl.c |  3 ++-
 src/openvpn/init.c   |  2 +-
 src/openvpn/mtu.c|  4 ++--
 src/openvpn/openvpn.vcxproj  | 26 +-
 src/openvpn/options.c|  2 +-
 src/openvpn/route.c  |  2 +-
 src/openvpn/ssl_openssl.c|  2 +-
 src/openvpn/tun.c| 12 ++--
 10 files changed, 31 insertions(+), 26 deletions(-)

diff --git a/src/compat/Debug.props b/src/compat/Debug.props
index e5e9f681..31bb9d91 100644
--- a/src/compat/Debug.props
+++ b/src/compat/Debug.props
@@ -15,7 +15,6 @@
   
_DEBUG;%(PreprocessorDefinitions)
   MultiThreadedDebugDLL
   EditAndContinue
-  true
 
   
   
diff --git a/src/openvpn/block_dns.c b/src/openvpn/block_dns.c
index 889d6bb9..f4718fc2 100644
--- a/src/openvpn/block_dns.c
+++ b/src/openvpn/block_dns.c
@@ -109,9 +109,6 @@ DEFINE_GUID(
 
 static WCHAR *FIREWALL_NAME = L"OpenVPN";
 
-VOID NETIOAPI_API_
-InitializeIpInterfaceEntry(PMIB_IPINTERFACE_ROW Row);
-
 /*
  * Default msg handler does nothing
  */
diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c
index 2027d8dc..521cfca1 100644
--- a/src/openvpn/crypto_openssl.c
+++ b/src/openvpn/crypto_openssl.c
@@ -315,7 +315,8 @@ show_available_ciphers(void)
 }
 }
 
-qsort(cipher_list, num_ciphers, sizeof(*cipher_list), cipher_name_cmp);
+/* cast to non-const to prevent warning */
+qsort((EVP_CIPHER *)cipher_list, num_ciphers, sizeof(*cipher_list), 
cipher_name_cmp);
 
 for (i = 0; i < num_ciphers; i++)
 {
diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index 2c8db68d..2af25c1a 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -1812,7 +1812,7 @@ do_open_tun(struct context *c)
 #ifdef _WIN32
 /* store (hide) interactive service handle in tuntap_options */
 c->c1.tuntap->options.msg_channel = c->options.msg_channel;
-msg(D_ROUTE, "interactive service msg_channel=%u", (unsigned int) 
c->options.msg_channel);
+msg(D_ROUTE, "interactive service msg_channel=%" PRIu64, (unsigned long 
long) c->options.msg_channel);
 #endif
 
 /* allocate route list structure */
diff --git a/src/openvpn/mtu.c b/src/openvpn/mtu.c
index 04868cd6..8178ff06 100644
--- a/src/openvpn/mtu.c
+++ b/src/openvpn/mtu.c
@@ -175,7 +175,7 @@ set_mtu_discover_type(int sd, int mtu_type, sa_family_t 
proto_af)
 #if defined(HAVE_SETSOCKOPT) && defined(IP_MTU_DISCOVER)
 case AF_INET:
 if (setsockopt
-(sd, IPPROTO_IP, IP_MTU_DISCOVER, _type, 
sizeof(mtu_type)))
+(sd, IPPROTO_IP, IP_MTU_DISCOVER, (const char 
*)_type, sizeof(mtu_type)))
 {
 msg(M_ERR, "Error setting IP_MTU_DISCOVER type=%d on 
TCP/UDP socket",
 mtu_type);
@@ -186,7 +186,7 @@ set_mtu_discover_type(int sd, int mtu_type, sa_family_t 
proto_af)
 #if defined(HAVE_SETSOCKOPT) && defined(IPV6_MTU_DISCOVER)
 case AF_INET6:
 if (setsockopt
-(sd, IPPROTO_IPV6, IPV6_MTU_DISCOVER, _type, 
sizeof(mtu_type)))
+(sd, IPPROTO_IPV6, IPV6_MTU_DISCOVER, (const char 
*)_type, sizeof(mtu_type)))
 {
 msg(M_ERR, "Error setting IPV6_MTU_DISCOVER type=%d on 
TCP6/UDP6 socket",
 mtu_type);
diff --git a/src/openvpn/openvpn.vcxproj b/src/openvpn/openvpn.vcxproj
index 53ac5482..c34733ea 100644
--- a/src/openvpn/openvpn.vcxproj
+++ b/src/openvpn/openvpn.vcxproj
@@ -28,23 +28,23 @@
   
 Application
 true
-Unicode
+NotSet
 v142
   
   
 Application
 true
-Unicode
+NotSet
 v142
   
   
 Application
-Unicode
+NotSet
 v142
   
   
 Application
-Unicode
+NotSet
 v142
   
   
@@ -74,7 +74,9 @@
 
   
..\compat;$(TAP_WINDOWS_HOME)/include;$(OPENSSL_HOME)/include;$(LZO_HOME)/include;$(PKCS11H_HOME)/include;%(AdditionalIncludeDirectories)
   
_CONSOLE;%(PreprocessorDefinitions)
-  
UNICODE;%(UndefinePreprocessorDefinitions)
+  
%(UndefinePreprocessorDefinitions)
+  Level2
+  true
 
 
 
@@ -87,7 +89,9 @@
 
   
..\compat;$(TAP_WINDOWS_HOME)/include;$(OPENSSL_HOME)/include;$(LZO_HOME)/include;$(PKCS11H_HOME)/include;%(AdditionalIncludeDirectories)
   
_CONSOLE;%(PreprocessorDefinitions)
-  
UNICODE;%(UndefinePreprocessorDefinitions)
+  
%(UndefinePreprocessorDefinitions)
+  Level2
+  true
 
 
 
@@ -100,7 +104,9 @@