From: "cron2 (Code Review)" Date: Thu, 12 Mar 2026 07:38:46 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="i0R3UPjyW4U="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: socket: Avoid sign-compare issue by comparing before assignment List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: plaisthos , openvpn-devel --i0R3UPjyW4U= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/15= 23?usp=3Demail ) Change subject: socket: Avoid sign-compare issue by comparing before assign= ment ...................................................................... socket: Avoid sign-compare issue by comparing before assignment The assignment implicitly converts the values, but we can just do the comparison before the assignment. Change-Id: Idf5ce8f82e7727505cce67560e0b7423b8e41a40 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1523 Message-Id: <20260306163202.2586-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg35= 961.html Signed-off-by: Gert Doering --- M src/openvpn/socket.c 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 8d2d110..5df0792 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -2550,11 +2550,6 @@ return WSAGetLastError(); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - int socket_recv_queue(struct link_socket *sock, int maxsize) { @@ -2579,11 +2574,10 @@ /* Win32 docs say it's okay to allocate the wsabuf on the stack */ wsabuf[0].buf =3D BSTR(&sock->reads.buf); + /* make sure maxsize is sane */ + ASSERT(maxsize <=3D BLEN(&sock->reads.buf)); wsabuf[0].len =3D maxsize ? maxsize : BLEN(&sock->reads.buf); - /* check for buffer overflow */ - ASSERT(wsabuf[0].len <=3D BLEN(&sock->reads.buf)); - /* the overlapped read will signal this event on I/O completion */ ASSERT(ResetEvent(sock->reads.overlapped.hEvent)); sock->reads.flags =3D 0; @@ -2656,10 +2650,6 @@ return sock->reads.iostate; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - int socket_send_queue(struct link_socket *sock, struct buffer *buf, const stru= ct link_socket_actual *to) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1523?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: Idf5ce8f82e7727505cce67560e0b7423b8e41a40 Gerrit-Change-Number: 1523 Gerrit-PatchSet: 5 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --i0R3UPjyW4U= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 sub= mitted this change.

View Change

socket: Avoid sign-compare issue by comparing be=
fore assignment

The assignment implicitly converts the values, butwe can just do the comparison before the assignment.

Change-Id: Id= f5ce8f82e7727505cce67560e0b7423b8e41a40
Signed-off-by: Frank Lichtenheld= <frank@...2641...>
Acked-by: Gert Doering <gert@...1296...>=
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1523
Message-Id: = <20260306163202.2586-1-gert@...1296...>
URL: https://www.mail-arch= ive.com/openvpn-devel@lists.sourceforge.net/msg35961.html
Signed-off-by:= Gert Doering <gert@...1296...>
---
M src/openvpn/socket.c
1= file changed, 2 insertions(+), 12 deletions(-)

diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c
index 8d2d110..5df0792 100644
--- a/src/openvpn/socket.c
+++ b/src/openvpn/socket.c
@@ -2550,11 +2550= ,6 @@
return WSAGetLastError();
}


-#if def= ined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-compare&qu= ot;
-#endif
<= span style=3D"color: hsl(0, 100%, 40%);">-
int
<= span> socket_recv_queue(struct link_socket *sock, int maxsize)
{
@@ -2579,11 +2574,10 @@

= /* Win32 docs say it's okay to allocate the wsabuf on th= e stack */
wsabuf[0].buf =3D BSTR(&sock->re= ads.buf);
+ /*= make sure maxsize is sane */
+ ASSERT(maxsize <=3D BLEN(&sock->reads.buf));

wsabuf[0].len =3D maxsize ? maxsize : BLEN(&sock= ->reads.buf);

- /* check for buffer overflow */
- ASSERT(wsabuf[0].len <=3D BLEN(&= amp;sock->reads.buf));
-
/* the overlapped read will signal this event= on I/O completion */
ASSERT(ResetEvent(sock->r= eads.overlapped.hEvent));
sock->reads.flags =3D= 0;
@@ -2656,10 +2650,6 @@
return sock= ->reads.iostate;
}

-#if defined(__GNUC__) || defined(__clang= __)
-#pragma GCC diagno= stic pop
-#endif=
-
int=
socket_send_queue(struct link_socket *sock, struct buffer *buf, = const struct link_socket_actual *to)
{

To view, visit change 1523. To unsubscribe, or for help writin= g mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Idf5ce8f82e7727505cce67560e0= b7423b8e41a40
Gerrit-Change-Number: 1523
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --i0R3UPjyW4U=--