From: "cron2 (Code Review)" Date: Wed, 11 Mar 2026 14:57:39 +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="5h4z/kIvOhg="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: tun: Avoid sign-compare issues in tun_read_queue List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: plaisthos , openvpn-devel --5h4z/kIvOhg= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/15= 25?usp=3Demail ) Change subject: tun: Avoid sign-compare issues in tun_read_queue ...................................................................... tun: Avoid sign-compare issues in tun_read_queue Just use the same type that the other values already have. While here review and remove some other useless casts in msg() calls. Change-Id: Ifc7ad2407b9cca8cfcef79d7392a058735416139 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1525 Message-Id: <20260306162925.2359-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg35= 956.html Signed-off-by: Gert Doering --- M src/openvpn/tun.c 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 7f96602..7a173c5 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -3273,24 +3273,18 @@ #elif defined(_WIN32) -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - int tun_read_queue(struct tuntap *tt, int maxsize) { if (tt->reads.iostate =3D=3D IOSTATE_INITIAL) { - DWORD len; BOOL status; int err; /* reset buf to its initial state */ tt->reads.buf =3D tt->reads.buf_init; - len =3D maxsize ? maxsize : BLEN(&tt->reads.buf); + int len =3D maxsize ? maxsize : BLEN(&tt->reads.buf); ASSERT(len <=3D BLEN(&tt->reads.buf)); /* the overlapped read will signal this event on I/O completion */ @@ -3307,8 +3301,8 @@ tt->reads.iostate =3D IOSTATE_IMMEDIATE_RETURN; tt->reads.status =3D 0; - dmsg(D_WIN32_IO, "WIN32 I/O: TAP Read immediate return [%d,%d]= ", (int)len, - (int)tt->reads.size); + dmsg(D_WIN32_IO, "WIN32 I/O: TAP Read immediate return [%d,%lu= ]", len, + tt->reads.size); } else { @@ -3317,7 +3311,7 @@ { tt->reads.iostate =3D IOSTATE_QUEUED; tt->reads.status =3D err; - dmsg(D_WIN32_IO, "WIN32 I/O: TAP Read queued [%d]", (int)l= en); + dmsg(D_WIN32_IO, "WIN32 I/O: TAP Read queued [%d]", len); } else /* error occurred */ { @@ -3325,7 +3319,7 @@ ASSERT(SetEvent(tt->reads.overlapped.hEvent)); tt->reads.iostate =3D IOSTATE_IMMEDIATE_RETURN; tt->reads.status =3D err; - dmsg(D_WIN32_IO, "WIN32 I/O: TAP Read error [%d] : %s", (i= nt)len, + dmsg(D_WIN32_IO, "WIN32 I/O: TAP Read error [%d] : %s", le= n, strerror_win32(status, &gc)); gc_free(&gc); } @@ -3362,8 +3356,8 @@ tt->writes.status =3D 0; - dmsg(D_WIN32_IO, "WIN32 I/O: TAP Write immediate return [%d,%d= ]", BLEN(&tt->writes.buf), - (int)tt->writes.size); + dmsg(D_WIN32_IO, "WIN32 I/O: TAP Write immediate return [%d,%l= u]", BLEN(&tt->writes.buf), + tt->writes.size); } else { @@ -5457,14 +5451,14 @@ if (DeviceIoControl(tt->hand, TAP_WIN_IOCTL_GET_VERSION, &info, sizeof= (info), &info, sizeof(info), &len, NULL)) { - msg(D_TUNTAP_INFO, "TAP-Windows Driver Version %d.%d %s", (int)inf= o[0], (int)info[1], + msg(D_TUNTAP_INFO, "TAP-Windows Driver Version %lu.%lu %s", info[0= ], info[1], (info[2] ? "(DEBUG)" : "")); } if (!(info[0] =3D=3D TAP_WIN_MIN_MAJOR && info[1] >=3D TAP_WIN_MIN_MIN= OR)) { msg(M_FATAL, "ERROR: This version of " PACKAGE_NAME - " requires a TAP-Windows driver that is at least version %d.%d= -- If you recently upgraded your " PACKAGE_NAME + " requires a TAP-Windows driver that is at least version %u.%u= -- If you recently upgraded your " PACKAGE_NAME " distribution, a reboot is probably required at this point to= get Windows to see the new driver.", TAP_WIN_MIN_MAJOR, TAP_WIN_MIN_MINOR); } @@ -5475,8 +5469,8 @@ if (tt->type =3D=3D DEV_TYPE_TUN && info[0] =3D=3D 9 && info[1] < 8) { msg(M_INFO, - "WARNING: Tap-Win32 driver version %d.%d does not support IPv= 6 in TUN mode. IPv6 will not work. Upgrade your Tap-Win32 driver.", - (int)info[0], (int)info[1]); + "WARNING: Tap-Win32 driver version %lu.%lu does not support I= Pv6 in TUN mode. IPv6 will not work. Upgrade your Tap-Win32 driver.", + info[0], info[1]); } /* tap driver 9.8 (2.2.0 and 2.2.1 release) is buggy @@ -5484,8 +5478,7 @@ if (tt->type =3D=3D DEV_TYPE_TUN && info[0] =3D=3D 9 && info[1] =3D=3D= 8) { msg(M_FATAL, - "ERROR: Tap-Win32 driver version %d.%d is buggy regarding sma= ll IPv4 packets in TUN mode. Upgrade your Tap-Win32 driver.", - (int)info[0], (int)info[1]); + "ERROR: Tap-Win32 driver version 9.8 is buggy regarding small= IPv4 packets in TUN mode. Upgrade your Tap-Win32 driver."); } } @@ -5497,7 +5490,7 @@ if (DeviceIoControl(tt->hand, TAP_WIN_IOCTL_GET_MTU, &mtu, sizeof(mtu)= , &mtu, sizeof(mtu), &len, NULL)) { - msg(D_MTU_INFO, "TAP-Windows MTU=3D%d", (int)mtu); + msg(D_MTU_INFO, "TAP-Windows MTU=3D%lu", mtu); } } @@ -5618,10 +5611,6 @@ gc_free(&gc); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - static void tuntap_set_connected(const struct tuntap *tt) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1525?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: Ifc7ad2407b9cca8cfcef79d7392a058735416139 Gerrit-Change-Number: 1525 Gerrit-PatchSet: 5 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --5h4z/kIvOhg= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 sub= mitted this change.

View Change

tun: Avoid sign-compare issues in tun_read_queue=


Just use the same type that the other values
already have.
While here review and remove some other useless
casts in msg() calls.<= br>
Change-Id: Ifc7ad2407b9cca8cfcef79d7392a058735416139
Signed-off-b= y: Frank Lichtenheld <frank@...2641...>
Acked-by: Gert Doering <= ;gert@...1296...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/= 1525
Message-Id: <20260306162925.2359-1-gert@...1296...>
URL: h= ttps://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg35956.ht= ml
Signed-off-by: Gert Doering <gert@...1296...>
---
M src/o= penvpn/tun.c
1 file changed, 13 insertions(+), 24 deletions(-)

diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index= 7f96602..7a173c5 100644
--- a/src/openvpn/tun.c
= +++ b/src/openvpn/tun.c
@@ -3273,24 +3273,18 @@

#elif defined(_WIN32)

-#if defined(__GNUC__) || de= fined(__clang__)
-#prag= ma GCC diagnostic push
= -#pragma GCC diagnostic ignored "-Wsign-compare"
-#endif
-
int
tun_read_queue= (struct tuntap *tt, int maxsize)
{
if= (tt->reads.iostate =3D=3D IOSTATE_INITIAL)
{
- DWORD len; BOOL status;
int err;
<= span>

/* reset buf to its initial state */=
tt->reads.buf =3D tt->reads.buf_init;

- len =3D = maxsize ? maxsize : BLEN(&tt->reads.buf);
+ int len =3D maxsize ? maxsize : BLEN(&= amp;tt->reads.buf);
ASSERT(len <=3D BLEN(&am= p;tt->reads.buf));

/* the ove= rlapped read will signal this event on I/O completion */
@@= -3307,8 +3301,8 @@
tt->reads.iostate =3D I= OSTATE_IMMEDIATE_RETURN;
tt->reads.status = =3D 0;

+ dmsg(D_WIN32_IO, "WIN32 I/O: TAP = Read immediate return [%d,%lu]", len,
+ tt->reads.size);
}

else
{=
@@ -3317,7 +3311,7 @@
{
tt->reads.iostate =3D IOSTATE_QUEUED;
tt->reads.status =3D err;
- dmsg(D_WIN32_IO, "WIN32 I/O= : TAP Read queued [%d]", (int)len);
+ dmsg(D_WIN32_IO, "WIN32 I/O: TAP = Read queued [%d]", len);
}
else /* error occurred */
{

@@ -3325,7 +3319,7 @@
ASSERT(= SetEvent(tt->reads.overlapped.hEvent));
= tt->reads.iostate =3D IOSTATE_IMMEDIATE_RETURN;
= tt->reads.status =3D err;
- dmsg(D_WIN32_IO, "WIN32 I/O: TAP Read= error [%d] : %s", (int)len,
+ dmsg(D_WIN32_IO, "WIN32 I/O: TAP Read er= ror [%d] : %s", len,
strerror_wi= n32(status, &gc));
gc_free(&gc);
}
@@ -3362,8 +3356,8 @@<= br>
tt->writes.status =3D 0;<= br>
- = dmsg(D_WIN32_IO, "WIN32 I/O: TAP Write immediate return [%d,%d]"= , BLEN(&tt->writes.buf),
- (int)tt->writes.size);
+ dmsg(D_WIN32_IO, "WIN32 = I/O: TAP Write immediate return [%d,%lu]", BLEN(&tt->writes.buf= ),
+ = tt->writes.size);
}
el= se
{
@@ -5457,14 +5451,14 @@
if (DeviceIoControl(tt->hand, TAP_WIN_IOCTL_GET_VERSION,= &info, sizeof(info), &info,
= sizeof(info), &len, NULL))
{
- msg(D_TUNTAP_INFO, "TAP-Win= dows Driver Version %d.%d %s", (int)info[0], (int)info[1],
<= span style=3D"color: hsl(120, 100%, 40%);">+ msg(D_TUNTAP_INFO, &quo= t;TAP-Windows Driver Version %lu.%lu %s", info[0], info[1],

= (info[2] ? "(DEBUG)" : ""));<= br> }
if (!(info[0] =3D=3D TAP_WIN_MIN_MAJOR= && info[1] >=3D TAP_WIN_MIN_MINOR))
{
msg(M_FATAL,
"ERROR:= This version of " PACKAGE_NAME
- " requires a TAP-Windows driver that is at= least version %d.%d -- If you recently upgraded your " PACKAGE_NAME
+ " re= quires a TAP-Windows driver that is at least version %u.%u -- If you recent= ly upgraded your " PACKAGE_NAME
" di= stribution, a reboot is probably required at this point to get Windows to s= ee the new driver.",
TAP_WIN_MIN_MAJOR, T= AP_WIN_MIN_MINOR);
}
@@ -5475,8 +5469,= 8 @@
if (tt->type =3D=3D DEV_TYPE_TUN && in= fo[0] =3D=3D 9 && info[1] < 8)
{
= msg(M_INFO,
- "WARNING: Tap-Win32 driver version %d.%d does not su= pport IPv6 in TUN mode. IPv6 will not work. Upgrade your Tap-Win32 driver.&= quot;,
- (in= t)info[0], (int)info[1]);
+ "WARNING: Tap-Win32 driver version %lu.%lu does not= support IPv6 in TUN mode. IPv6 will not work. Upgrade your Tap-Win32 drive= r.",
+ = info[0], info[1]);
}

/* tap driver 9.8 (2.2.0 and 2.2.1 release) is buggy

@@ -5484,8 +5478,7 @@

if (tt->type =3D=3D DEV_TYP= E_TUN && info[0] =3D=3D 9 && info[1] =3D=3D 8)
{

msg(M_FATAL,
- "ERROR: Tap-Win32 driver versi= on %d.%d is buggy regarding small IPv4 packets in TUN mode. Upgrade your Ta= p-Win32 driver.",
= - (int)info[0], (int)info[1]);
+ "ERROR: Tap-Win32 driver version 9.= 8 is buggy regarding small IPv4 packets in TUN mode. Upgrade your Tap-Win32= driver.");
}
}
=
@@ -5497,7 +5490,7 @@
if (DeviceIoCo= ntrol(tt->hand, TAP_WIN_IOCTL_GET_MTU, &mtu, sizeof(mtu), &mtu, = sizeof(mtu), &len,
NULL))
{
- = msg(D_MTU_INFO, "TAP-Windows MTU=3D%d", (int)mtu);+ msg(D_MTU_INFO, "= ;TAP-Windows MTU=3D%lu", mtu);
}
= }

@@ -5618,10 +5611,6 @@
gc_free(&gc);

}

-#if defined(__GNUC__) || defined(__c= lang__)
-#pragma GCC di= agnostic pop
-#endif

-
static= void
tuntap_set_connected(const struct tuntap *tt)=
{

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

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ifc7ad2407b9cca8cfcef79d7392= a058735416139
Gerrit-Change-Number: 1525
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>
= --5h4z/kIvOhg=--