From: "flichtenheld (Code Review)" Date: Fri, 13 Feb 2026 18:44:51 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <1ac7b7f5eeb53d8c3aea42de6dc96b4fd51e66fc-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="kE/42zwUu6k="; 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: plaisthos Cc: openvpn-devel --kE/42zwUu6k= 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/+/1523?usp=3Demail to review the following change. 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 --- M src/openvpn/socket.c 1 file changed, 2 insertions(+), 12 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/23/1523/1 diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 698e724..13322f5 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -2523,11 +2523,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) { @@ -2552,11 +2547,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; @@ -2629,10 +2623,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: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Idf5ce8f82e7727505cce67560e0b7423b8e41a40 Gerrit-Change-Number: 1523 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --kE/42zwUu6k= 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

socket: Avoid sign-compare issue by compari=
ng before assignment

The assignment implicitly converts the values, = but
we can just do the comparison before the assignment.

Change-I= d: Idf5ce8f82e7727505cce67560e0b7423b8e41a40
Signed-off-by: Frank Lichte= nheld <frank@...2641...>
---
M src/openvpn/socket.c
1 file c= hanged, 2 insertions(+), 12 deletions(-)

git pul=
l ssh://gerrit.openvpn.net:29418/openvpn refs/changes/23/1523/1
dif=
f --git a/src/openvpn/socket.c b/src/openvpn/socket.c
index= 698e724..13322f5 100644
--- a/src/openvpn/socket.c<= br>+++ b/src/openvpn/socket.c
@@ -2523,11 +2523,6 @@<= /span>
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)
{=
@@ -2552,11 +2547,10 @@

= /* Win32 docs say it's okay to allocate the wsabuf on the stac= k */
wsabuf[0].buf =3D BSTR(&sock->reads.bu= f);
+ /* make = sure maxsize is sane */
+ ASSERT(maxsize <=3D BLEN(&sock->reads.buf)); wsabuf[0].len =3D maxsize ? maxsize : BLEN(&sock->r= eads.buf);

- /* check for buffer overflow */
- ASSERT(wsabuf[0].len <=3D BLEN(&soc= k->reads.buf));
-
/* the overlapped read will signal this event on I/O= completion */
ASSERT(ResetEvent(sock->reads.ov= erlapped.hEvent));
sock->reads.flags =3D 0;
@@ -2629,10 +2623,6 @@
return sock->re= ads.iostate;
}

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic po= p
-#endif
-

int
socket_send_queue(struct link_socket *sock, struct buffer *buf, const s= truct link_socket_actual *to)

{

To view, visit change 1523. To unsubscribe, or for help writing mail = filters, visit s= ettings.

=
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Idf5ce8f82e7727505cce67560e0= b7423b8e41a40
Gerrit-Change-Number: 1523
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...>
= --kE/42zwUu6k=--