From: "flichtenheld (Code Review)" Date: Fri, 30 Jan 2026 16:11:05 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <4500403236333562b750a87d6f9824eb0088fe13-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="J3qnaFAUBHY="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: error: Use SOCKET_UNDEFINED instead of -1 to avoid sign error on Windows List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --J3qnaFAUBHY= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1501?usp=3Demail to review the following change. Change subject: error: Use SOCKET_UNDEFINED instead of -1 to avoid sign err= or on Windows ...................................................................... error: Use SOCKET_UNDEFINED instead of -1 to avoid sign error on Windows While here also mark a comparison we know is safe with an explicit cast. Change-Id: I96b6acffd7e5149d4c9488a06e43c62711b31cfc Signed-off-by: Frank Lichtenheld --- M src/openvpn/error.c 1 file changed, 13 insertions(+), 24 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/01/1501/1 diff --git a/src/openvpn/error.c b/src/openvpn/error.c index 6fb4f32..2900352 100644 --- a/src/openvpn/error.c +++ b/src/openvpn/error.c @@ -97,15 +97,10 @@ forked =3D true; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - bool set_debug_level(const int level, const unsigned int flags) { - if (level >=3D 0 && level <=3D M_DEBUG_LEVEL) + if (level >=3D 0 && (unsigned int)level <=3D M_DEBUG_LEVEL) { x_debug_level =3D (msglvl_t)level; return true; @@ -118,10 +113,6 @@ return false; } =20 -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - bool set_mute_cutoff(const int cutoff) { @@ -621,11 +612,6 @@ x_cs_verbose_level =3D verbose_level; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - /* * Called after most socket or tun/tap operations, via the inline * function check_status(). @@ -674,15 +660,22 @@ { if (extended_msg) { - msg(x_cs_info_level, "%s %s [%s]: %s (fd=3D" SOCKET_PRINTF= ",code=3D%d)", description, - sock ? proto2ascii(sock->info.proto, sock->info.af, tr= ue) : "", extended_msg, - openvpn_strerror(my_errno, crt_error, &gc), sock ? soc= k->sd : -1, my_errno); + msg(x_cs_info_level, "%s %s [%s]: %s (fd=3D" SOCKET_PRINTF= ",code=3D%d)", + description, + sock ? proto2ascii(sock->info.proto, sock->info.af, tr= ue) : "", + extended_msg, + openvpn_strerror(my_errno, crt_error, &gc), + sock ? sock->sd : SOCKET_UNDEFINED, + my_errno); } else { - msg(x_cs_info_level, "%s %s: %s (fd=3D" SOCKET_PRINTF ",co= de=3D%d)", description, + msg(x_cs_info_level, "%s %s: %s (fd=3D" SOCKET_PRINTF ",co= de=3D%d)", + description, sock ? proto2ascii(sock->info.proto, sock->info.af, tr= ue) : "", - openvpn_strerror(my_errno, crt_error, &gc), sock ? soc= k->sd : -1, my_errno); + openvpn_strerror(my_errno, crt_error, &gc), + sock ? sock->sd : SOCKET_UNDEFINED, + my_errno); } if (x_cs_err_delay_ms) @@ -694,10 +687,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - /* * In multiclient mode, put a client-specific prefix * before each message. -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1501?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I96b6acffd7e5149d4c9488a06e43c62711b31cfc Gerrit-Change-Number: 1501 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --J3qnaFAUBHY= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: plaisthos.

flichtenheld would like plaisthos to review this change.

V= iew Change

error: Use SOCKET_UNDEFINED instead of -1 t=
o avoid sign error on Windows

While here also mark a comparison we k= now is safe
with an explicit cast.

Change-Id: I96b6acffd7e5149d4c= 9488a06e43c62711b31cfc
Signed-off-by: Frank Lichtenheld <frank@...2716...= 1...>
---
M src/openvpn/error.c
1 file changed, 13 insertions(+= ), 24 deletions(-)

git pull ssh://gerrit.openvpn=
.net:29418/openvpn refs/changes/01/1501/1
diff --git a/src/openvpn/=
error.c b/src/openvpn/error.c
index 6fb4f32..2900352 100644=
--- a/src/openvpn/error.c
+++ b/src/openvp= n/error.c
@@ -97,15 +97,10 @@
forked = =3D true;
}

-#if defined(__GNUC__) || defined(__clang__)=
-#pragma GCC diagnostic push<= /span>
-#pragma GCC diagnostic= ignored "-Wsign-compare"
-#endif
-<= /span>
bool
set_debug_level(const int level, con= st unsigned int flags)
{
- if (level >=3D 0 && level <=3D M_DEBU= G_LEVEL)
+ if (lev= el >=3D 0 && (unsigned int)level <=3D M_DEBUG_LEVEL) {
x_debug_level =3D (msglvl_t)level;<= /span>
return true;
@@ -118,10 +113,6 @@<= /span>
return false;
}

-#if defined(__GNUC__) || = defined(__clang__)
-#pr= agma GCC diagnostic pop
-#endif
-
bool

set_mute_cutoff(const int cutoff)
{

@@ -621,11 +612,6 @@
x_cs_verbose= _level =3D verbose_level;
}

-#if defined(__GNUC__) || defined(_= _clang__)

-#pragma GCC = diagnostic push
-#pragm= a GCC diagnostic ignored "-Wsign-compare"
-#endif
-
/*
* Called after most= socket or tun/tap operations, via the inline
* function = check_status().
@@ -674,15 +660,22 @@
= {
if (extended_msg)
= {
- = msg(x_cs_info_level, "%s %s [%s]: %s (fd=3D" SOCKET_PRINTF &qu= ot;,code=3D%d)", description,
- sock ? proto2ascii(sock->info.proto, so= ck->info.af, true) : "", extended_msg,
- openvpn_strerror(my_err= no, crt_error, &gc), sock ? sock->sd : -1, my_errno);
+ msg(x_cs_info_leve= l, "%s %s [%s]: %s (fd=3D" SOCKET_PRINTF ",code=3D%d)",=

+ = description,
+ = sock ? proto2ascii(sock->info.proto, sock->info.af, tru= e) : "",
+ = extended_msg,
+ openvpn_strerror(my_errno, crt_error, &= ;gc),
+ = sock ? sock->sd : SOCKET_UNDEFINED,
+ my_errno);
= }
else
= {
- msg(= x_cs_info_level, "%s %s: %s (fd=3D" SOCKET_PRINTF ",code=3D%= d)", description,
+ description,
= sock ? proto2ascii(sock->info.proto, sock->info.af, true) : &= quot;",
- = openvpn_strerror(my_errno, crt_error, &gc), sock ? sock->= sd : -1, my_errno);
+= openvpn_strerror(my_errno, crt_error, &gc),<= br>+ sock ? = sock->sd : SOCKET_UNDEFINED,
+ my_errno);
}

if (x_cs_err_delay_ms)=
@@ -694,10 +687,6 @@
}
}

-#if de= fined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
/*
* In multiclient mode, put a c= lient-specific prefix
* before each message.

To view, visit change 1501. To unsubscribe, or for help= writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I96b6acffd7e5149d4c9488a06e4= 3c62711b31cfc
Gerrit-Change-Number: 1501
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
= --J3qnaFAUBHY=--