From: "cron2 (Code Review)" Date: Mon, 26 Jan 2026 16:34:05 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <29af9f48281f432f1dedaab2368cad0f555f4e3a-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="L3m1iXu6rek="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: status: Avoid conversion warnings in status_read/status_printf List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: plaisthos , openvpn-devel --L3m1iXu6rek= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: cron2. cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/14= 85?usp=3Demail ) Change subject: status: Avoid conversion warnings in status_read/status_pri= ntf ...................................................................... status: Avoid conversion warnings in status_read/status_printf Just use explicit casts. len is limited by BCAP and c is limited by being from buf_read_u8. So they are safe. In case of status_printf this is only for Windows. len is limited by sizeof(buf), so also a safe cast. Change-Id: Iff1343a2f8cc7e32b8f36b359a00248e4dc3e8c9 Signed-off-by: Frank Lichtenheld Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1485 Message-Id: <20260122154751.155227-1-frank@...2641...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg35= 398.html Signed-off-by: Gert Doering --- M src/openvpn/status.c 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/openvpn/status.c b/src/openvpn/status.c index 3f57244..d09f367 100644 --- a/src/openvpn/status.c +++ b/src/openvpn/status.c @@ -206,11 +206,6 @@ return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - #define STATUS_PRINTF_MAXLEN 512 void @@ -243,7 +238,7 @@ size_t len =3D strlen(buf); if (len > 0) { - if (write(so->fd, buf, len) !=3D len) + if (write(so->fd, buf, (unsigned int)len) !=3D len) { so->errors =3D true; } @@ -274,16 +269,14 @@ /* read more of file into buffer */ if (c =3D=3D -1) { - int len; - ASSERT(buf_init(&so->read_buf, 0)); - len =3D read(so->fd, BPTR(&so->read_buf), BCAP(&so->read_b= uf)); + ssize_t len =3D read(so->fd, BPTR(&so->read_buf), BCAP(&so= ->read_buf)); if (len <=3D 0) { break; } - ASSERT(buf_inc_len(&so->read_buf, len)); + ASSERT(buf_inc_len(&so->read_buf, (int)len)); continue; } @@ -299,7 +292,7 @@ break; } - buf_write_u8(buf, c); + buf_write_u8(buf, (uint8_t)c); } buf_null_terminate(buf); @@ -307,7 +300,3 @@ return ret; } - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1485?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: Iff1343a2f8cc7e32b8f36b359a00248e4dc3e8c9 Gerrit-Change-Number: 1485 Gerrit-PatchSet: 3 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: cron2 --L3m1iXu6rek= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: cron2.

cron2 submitted this change.

View Change

status: Avoid conversion war=
nings in status_read/status_printf

Just use explicit casts. len is l= imited by BCAP and
c is limited by being from buf_read_u8. So they aresafe.

In case of status_printf this is only for Windows.
len is= limited by sizeof(buf), so also a safe cast.

Change-Id: Iff1343a2f8= cc7e32b8f36b359a00248e4dc3e8c9
Signed-off-by: Frank Lichtenheld <fran= k@...2641...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1485=
Message-Id: <20260122154751.155227-1-frank@...2641...>
URL: ht= tps://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg35398.htm= l
Signed-off-by: Gert Doering <gert@...1296...>
---
M src/op= envpn/status.c
1 file changed, 4 insertions(+), 15 deletions(-)

<= /pre>
diff --git a/src/openvpn/status.c b/src/openvpn/status.c
index 3f57244..d09f367 100644
--- a/src/openvpn/status.c
+++ b/src/openvpn/status.c
@@ -206,11 +206,6= @@
return ret;
}

-#if defined(__GNUC__) |= | defined(__clang__)
-#= pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif

-
#define STATUS_PRINTF_MAXLEN 512<= /span>

void
@@ -243,7 +238,7 @@=
size_t len =3D strlen(buf);
= if (len > 0)
{
- if (write(so->fd, b= uf, len) !=3D len)
+ = if (write(so->fd, buf, (unsigned int)len) !=3D len)

{
so->e= rrors =3D true;
}
@@ -274,= 16 +269,14 @@
/* read more of file into buffer= */
if (c =3D=3D -1)
= {
- = int len;
-
ASSERT(buf_init(&so->read_buf, 0));
<= span style=3D"color: hsl(0, 100%, 40%);">- len =3D read(so-&= gt;fd, BPTR(&so->read_buf), BCAP(&so->read_buf));
<= span style=3D"color: hsl(120, 100%, 40%);">+ ssize_t len =3D= read(so->fd, BPTR(&so->read_buf), BCAP(&so->read_buf));
if (len <=3D 0)
= {
break;
= }

- ASSERT(buf_inc_len(&so->read_buf, len));<= /span>
+ ASSE= RT(buf_inc_len(&so->read_buf, (int)len));
= continue;
}
@@ -299,7 +292,7 @@
break; }

- buf_write_u8(buf, c);
+ buf_write_u8(buf, (uint8_t)c)= ;
}

buf= _null_terminate(buf);
@@ -307,7 +300,3 @@
=
return ret;
}
-
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif


To view, visit change 1485. To unsubscribe, or for help writing mail filt= ers, visit setti= ngs.

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iff1343a2f8cc7e32b8f36b359a0= 0248e4dc3e8c9
Gerrit-Change-Number: 1485
Gerrit-PatchSet: 3
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>
Gerrit-Attention: cron2 <gert@...1296...>= ;
= --L3m1iXu6rek=--