]> git.feebdaed.xyz Git - 0xmirror/openvpn.git/commitdiff
Enable -Wtype-limits by default (via -Wextra)
authorFrank Lichtenheld <frank@lichtenheld.com>
Tue, 11 Nov 2025 15:48:39 +0000 (16:48 +0100)
committerGert Doering <gert@greenie.muc.de>
Tue, 11 Nov 2025 17:58:27 +0000 (18:58 +0100)
Removes a few smaller instances:
 - Fix return type check for socket() on Windows/Unixy
 - Ignore a few instances related to WSAWaitForMultipleEvents.
   The compiler says the check is currently useless, but
   we follow the API documentation.

Change-Id: Iaabddb6f81cd94863291b193aae9d384a8f9d871
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1207
Message-Id: <20251111154846.31360-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34317.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
CMakeLists.txt
configure.ac
src/openvpn/event.c
src/openvpn/socket.c

index c9301e6bb2c14522a9af0852431fe2e26805c1c3..e812145a050430ba7dc2aee5281077596a5cca64 100644 (file)
@@ -114,7 +114,7 @@ else ()
     check_and_add_compiler_flag(-Wstrict-prototypes StrictPrototypes)
     check_and_add_compiler_flag(-Wold-style-definition OldStyleDefinition)
     add_compile_options(-Wconversion -Wno-sign-conversion)
-    add_compile_options(-Wextra -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter)
+    add_compile_options(-Wextra -Wno-sign-compare -Wno-unused-parameter)
     # clang doesn't have the different levels but also doesn't include it in -Wextra
     check_and_add_compiler_flag(-Wimplicit-fallthrough=2 GCCImplicitFallthrough)
     if (WIN32)
index 3117e132345e2b1bea2bafb782cee2f2c95884e8..f6e4b6d78b98a645caeaa0c19eb8b2d4958b106f 100644 (file)
@@ -1410,7 +1410,7 @@ ACL_CHECK_ADD_COMPILE_FLAGS([-Wstrict-prototypes])
 ACL_CHECK_ADD_COMPILE_FLAGS([-Wold-style-definition])
 ACL_CHECK_ADD_COMPILE_FLAGS([-Wconversion -Wno-sign-conversion])
 ACL_CHECK_ADD_COMPILE_FLAGS([-Wall])
-ACL_CHECK_ADD_COMPILE_FLAGS([-Wextra -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter])
+ACL_CHECK_ADD_COMPILE_FLAGS([-Wextra -Wno-sign-compare -Wno-unused-parameter])
 # clang doesn't have the different levels but also doesn't include it in -Wextra
 ACL_CHECK_ADD_COMPILE_FLAGS([-Wimplicit-fallthrough=2])
 if test "${WIN32}" = "yes"; then
index ca84d19bd50017e6fb439baec4e0b177279e7cd0..ca2d0c16e005794538b80c75ef1f94f93013a4fb 100644 (file)
@@ -410,6 +410,13 @@ we_wait(struct event_set *es, const struct timeval *tv, struct event_set_return
     }
 #endif
 
+    /* WSA_WAIT_EVENT_0 == 0 but the API documentation is written in a way
+       that doesn't guarantee that. So we make useless checks. */
+#if defined(__GNUC__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtype-limits"
+#endif
+
     /*
      * First poll our event list with 0 timeout
      */
@@ -474,6 +481,9 @@ we_wait(struct event_set *es, const struct timeval *tv, struct event_set_return
             return -1;
         }
     }
+#if defined(__GNUC__)
+#pragma GCC diagnostic pop
+#endif
 }
 
 static struct event_set *
index 8eac96dd0420c21f8a09f34930e6ea326e7fd80c..f7317d13225ae8eff632ae4bf830121418b33c76 100644 (file)
@@ -577,7 +577,8 @@ create_socket_tcp(struct addrinfo *addrinfo)
     ASSERT(addrinfo);
     ASSERT(addrinfo->ai_socktype == SOCK_STREAM);
 
-    if ((sd = socket(addrinfo->ai_family, addrinfo->ai_socktype, addrinfo->ai_protocol)) < 0)
+    if ((sd = socket(addrinfo->ai_family, addrinfo->ai_socktype, addrinfo->ai_protocol))
+        == SOCKET_UNDEFINED)
     {
         msg(M_ERR, "Cannot create TCP socket");
     }
@@ -608,7 +609,8 @@ create_socket_udp(struct addrinfo *addrinfo, const unsigned int flags)
     ASSERT(addrinfo);
     ASSERT(addrinfo->ai_socktype == SOCK_DGRAM);
 
-    if ((sd = socket(addrinfo->ai_family, addrinfo->ai_socktype, addrinfo->ai_protocol)) < 0)
+    if ((sd = socket(addrinfo->ai_family, addrinfo->ai_socktype, addrinfo->ai_protocol))
+        == SOCKET_UNDEFINED)
     {
         msg(M_ERR, "UDP: Cannot create UDP/UDP6 socket");
     }