From: "cron2 (Code Review)" Date: Tue, 11 Nov 2025 18:45:43 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <48900261ce1e9d23388f744d6c19fb647ce3d5fe-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="0IYOQIHj7wI="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Enable -Wtype-limits by default (via -Wextra) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: plaisthos , openvpn-devel --0IYOQIHj7wI= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/12= 07?usp=3Demail ) Change subject: Enable -Wtype-limits by default (via -Wextra) ...................................................................... Enable -Wtype-limits by default (via -Wextra) 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 Acked-by: Arne Schwabe Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1207 Message-Id: <20251111154846.31360-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34= 317.html Signed-off-by: Gert Doering --- M CMakeLists.txt M configure.ac M src/openvpn/event.c M src/openvpn/socket.c 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c9301e6..e812145 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,7 +114,7 @@ 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-un= used-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=3D2 GCCImplicitFall= through) if (WIN32) diff --git a/configure.ac b/configure.ac index 3117e13..f6e4b6d 100644 --- a/configure.ac +++ b/configure.ac @@ -1410,7 +1410,7 @@ 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 -W= no-unused-parameter]) +ACL_CHECK_ADD_COMPILE_FLAGS([-Wextra -Wno-sign-compare -Wno-unused-paramet= er]) # clang doesn't have the different levels but also doesn't include it in -= Wextra ACL_CHECK_ADD_COMPILE_FLAGS([-Wimplicit-fallthrough=3D2]) if test "${WIN32}" =3D "yes"; then diff --git a/src/openvpn/event.c b/src/openvpn/event.c index ca84d19..ca2d0c1 100644 --- a/src/openvpn/event.c +++ b/src/openvpn/event.c @@ -410,6 +410,13 @@ } #endif + /* WSA_WAIT_EVENT_0 =3D=3D 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 @@ return -1; } } +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif } static struct event_set * diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 8eac96d..f7317d1 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -577,7 +577,8 @@ ASSERT(addrinfo); ASSERT(addrinfo->ai_socktype =3D=3D SOCK_STREAM); - if ((sd =3D socket(addrinfo->ai_family, addrinfo->ai_socktype, addrinf= o->ai_protocol)) < 0) + if ((sd =3D socket(addrinfo->ai_family, addrinfo->ai_socktype, addrinf= o->ai_protocol)) + =3D=3D SOCKET_UNDEFINED) { msg(M_ERR, "Cannot create TCP socket"); } @@ -608,7 +609,8 @@ ASSERT(addrinfo); ASSERT(addrinfo->ai_socktype =3D=3D SOCK_DGRAM); - if ((sd =3D socket(addrinfo->ai_family, addrinfo->ai_socktype, addrinf= o->ai_protocol)) < 0) + if ((sd =3D socket(addrinfo->ai_family, addrinfo->ai_socktype, addrinf= o->ai_protocol)) + =3D=3D SOCKET_UNDEFINED) { msg(M_ERR, "UDP: Cannot create UDP/UDP6 socket"); } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1207?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: merged Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Iaabddb6f81cd94863291b193aae9d384a8f9d871 Gerrit-Change-Number: 1207 Gerrit-PatchSet: 7 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --0IYOQIHj7wI= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 sub= mitted this change.

View Change

Enable -Wtype-limits by default (via -Wextra)
Removes a few smaller instances:
- Fix return type check for socke= t() on Windows/Unixy
- Ignore a few instances related to WSAWaitForMult= ipleEvents.
The compiler says the check is currently useless, but
= we follow the API documentation.

Change-Id: Iaabddb6f81cd94863291= b193aae9d384a8f9d871
Signed-off-by: Frank Lichtenheld <frank@...2724...= ..>
Acked-by: Arne Schwabe <arne-openvpn@...1227...>
Gerrit = URL: https://gerrit.openvpn.net/c/openvpn/+/1207
Message-Id: <2025111= 1154846.31360-1-gert@...1296...>
URL: https://www.mail-archive.com/op= envpn-devel@lists.sourceforge.net/msg34317.html
Signed-off-by: Gert Doer= ing <gert@...1296...>
---
M CMakeLists.txt
M configure.acM src/openvpn/event.c
M src/openvpn/socket.c
4 files changed, 16 ins= ertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c9301= e6..e812145 100644
--- a/CMakeLists.txt
+++= b/CMakeLists.txt
@@ -114,7 +114,7 @@
= check_and_add_compiler_flag(-Wstrict-prototypes StrictPrototypes) check_and_add_compiler_flag(-Wold-style-definition OldStyleDefi= nition)
add_compile_options(-Wconversion -Wno-sign-con= version)
- add_compi= le_options(-Wextra -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter= )
+ add_compile_op= tions(-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=3D2 GCCImplicitFallthrough)
if (WIN32)

diff --git a/configure.ac b/configure.ac
index= 3117e13..f6e4b6d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1410,7 +1410,7 @@
= 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 -W= no-type-limits -Wno-unused-parameter])
+ACL_CHECK_ADD_COMPILE_FLAGS([-Wextra -Wno-sign-compare -= Wno-unused-parameter])
# clang doesn't have the differ= ent levels but also doesn't include it in -Wextra
ACL_= CHECK_ADD_COMPILE_FLAGS([-Wimplicit-fallthrough=3D2])
if t= est "${WIN32}" =3D "yes"; then
diff --g= it a/src/openvpn/event.c b/src/openvpn/event.c
index ca84d1= 9..ca2d0c1 100644
--- a/src/openvpn/event.c
+++ b/src/openvpn/event.c
@@ -410,6 +410,13 @@
<= span> }
#endif

+ /* WSA_WAIT_EVENT_0 =3D=3D 0 but the = API documentation is written in a way
+ that doesn't guarantee that. So we make useles= s checks. */
+#if def= ined(__GNUC__)
+#prag= ma GCC diagnostic push
+#endif
+
/*
*= First poll our event list with 0 timeout
*/@@ -474,6 +481,9 @@
return -1;<= br> }
}
+#if defined(__GNUC__)
+#pragma GCC diagnostic pop
+#endif
}

static struct event_set *
diff --git a/= src/openvpn/socket.c b/src/openvpn/socket.c
index 8eac96d..= f7317d1 100644
--- a/src/openvpn/socket.c
+= ++ b/src/openvpn/socket.c
@@ -577,7 +577,8 @@
ASSERT(addrinfo);
ASSERT(addrinfo->ai_sockt= ype =3D=3D SOCK_STREAM);

- if ((sd =3D socket(addrinfo->ai_family, addrinf= o->ai_socktype, addrinfo->ai_protocol)) < 0)
+ if ((sd =3D socket(addrinfo->ai_fa= mily, addrinfo->ai_socktype, addrinfo->ai_protocol))
+ =3D=3D SOCKET_UNDEFINED)

{
msg(M_ERR, "Cannot create= TCP socket");
}
@@ -608,7 +609,8= @@
ASSERT(addrinfo);
ASSERT(addr= info->ai_socktype =3D=3D SOCK_DGRAM);

- if ((sd =3D socket(addrinfo->ai= _family, addrinfo->ai_socktype, addrinfo->ai_protocol)) < 0)

+ if ((sd =3D socket(ad= drinfo->ai_family, addrinfo->ai_socktype, addrinfo->ai_protocol))<= /span>
+ =3D=3D SOCKE= T_UNDEFINED)
{
msg(M_ERR, &qu= ot;UDP: Cannot create UDP/UDP6 socket");
}=

To view, visit change 1207. To unsubscribe, or fo= r help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iaabddb6f81cd94863291b193aae= 9d384a8f9d871
Gerrit-Change-Number: 1207
Gerrit-PatchSet: 7
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --0IYOQIHj7wI=--