From: "flichtenheld (Code Review)" Date: Tue, 16 Sep 2025 15:36:07 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <8fd8ea06859225d4483ee2e7d5db8ce6a9c4a59d-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="XYs1+aR4f9U="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: ps: Fix conversion warnings related to send/recv return values List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --XYs1+aR4f9U= 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/+/1194?usp=3Demail to review the following change. Change subject: ps: Fix conversion warnings related to send/recv return val= ues ...................................................................... ps: Fix conversion warnings related to send/recv return values We know that these values can't be big since they are limited to the size of the input buffer. So we can explicitly cast them to int if required. Change-Id: Id070d1a45d45f9029309d23df7f3cab9ce792205 Signed-off-by: Frank Lichtenheld --- M src/openvpn/ps.c 1 file changed, 9 insertions(+), 18 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/94/1194/1 diff --git a/src/openvpn/ps.c b/src/openvpn/ps.c index 1d14367..31e7c25 100644 --- a/src/openvpn/ps.c +++ b/src/openvpn/ps.c @@ -475,11 +475,6 @@ return true; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - /* * This function runs in the context of the background proxy process. * Receive a control message from the parent (sent by the port_share_sendm= sg @@ -539,7 +534,7 @@ if (status >=3D 2 && command =3D=3D COMMAND_REDIRECT) { - buf.len =3D status - 1; + buf.len =3D (int)status - 1; if (proxy_entry_new(list, es, server_addr, received_fd, &b= uf, journal_dir)) { CLEAR(buf); /* we gave the buffer to proxy_entry_new */ @@ -566,7 +561,7 @@ proxy_connection_io_recv(struct proxy_connection *pc) { /* recv data from socket */ - const int status =3D recv(pc->sd, BPTR(&pc->buf), BCAP(&pc->buf), MSG_= NOSIGNAL); + const ssize_t status =3D recv(pc->sd, BPTR(&pc->buf), BCAP(&pc->buf), = MSG_NOSIGNAL); if (status < 0) { return (errno =3D=3D EAGAIN) ? IOSTAT_EAGAIN_ON_READ : IOSTAT_READ= _ERROR; @@ -577,8 +572,8 @@ { return IOSTAT_READ_ERROR; } - dmsg(D_PS_PROXY_DEBUG, "PORT SHARE PROXY: read[%d] %d", (int)pc->s= d, status); - pc->buf.len =3D status; + dmsg(D_PS_PROXY_DEBUG, "PORT SHARE PROXY: read[%d] %zd", (int)pc->= sd, status); + pc->buf.len =3D (int)status; } return IOSTAT_GOOD; } @@ -587,7 +582,7 @@ proxy_connection_io_send(struct proxy_connection *pc, int *bytes_sent) { const socket_descriptor_t sd =3D pc->counterpart->sd; - const int status =3D send(sd, BPTR(&pc->buf), BLEN(&pc->buf), MSG_NOSI= GNAL); + const ssize_t status =3D send(sd, BPTR(&pc->buf), BLEN(&pc->buf), MSG_= NOSIGNAL); if (status < 0) { @@ -596,17 +591,17 @@ } else { - *bytes_sent +=3D status; + *bytes_sent +=3D (int)status; if (status !=3D pc->buf.len) { - dmsg(D_PS_PROXY_DEBUG, "PORT SHARE PROXY: partial write[%d], t= ried=3D%d got=3D%d", (int)sd, + dmsg(D_PS_PROXY_DEBUG, "PORT SHARE PROXY: partial write[%d], t= ried=3D%d got=3D%zd", (int)sd, pc->buf.len, status); - buf_advance(&pc->buf, status); + buf_advance(&pc->buf, (int)status); return IOSTAT_EAGAIN_ON_WRITE; } else { - dmsg(D_PS_PROXY_DEBUG, "PORT SHARE PROXY: wrote[%d] %d", (int)= sd, status); + dmsg(D_PS_PROXY_DEBUG, "PORT SHARE PROXY: wrote[%d] %zd", (int= )sd, status); pc->buf.len =3D 0; pc->buf.offset =3D 0; } @@ -797,10 +792,6 @@ msg(M_INFO, "PORT SHARE PROXY: proxy exiting"); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - /* * Called from the main OpenVPN process to enable the port * share proxy. -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1194?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Id070d1a45d45f9029309d23df7f3cab9ce792205 Gerrit-Change-Number: 1194 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-MessageType: newchange --XYs1+aR4f9U= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: plaisthos.

flichtenheld would like plaisthos to review this change.

V= iew Change

ps: Fix conversion warnings related to send/recv return valu=
es

We know that these values can't be big since they are limited=
to the size of the input buffer. So we can explicitly cast
them to i= nt if required.

Change-Id: Id070d1a45d45f9029309d23df7f3cab9ce792205=
Signed-off-by: Frank Lichtenheld <frank@...2641...>
---
M s= rc/openvpn/ps.c
1 file changed, 9 insertions(+), 18 deletions(-)

=
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/94/1194/1
diff --git a/src/openvpn/ps.c b/src/openvpn/ps.c
ind= ex 1d14367..31e7c25 100644
--- a/src/openvpn/ps.c+++ b/src/openvpn/ps.c
@@ -475,11 +475,6 @@ return true;
}

-#if defined(__GNUC__) || defined(_= _clang__)
-#pragma GCC = diagnostic push
-#pragm= a GCC diagnostic ignored "-Wconversion"
-#endif
-
/*
* This function runs in= the context of the background proxy process.
* Receive a= control message from the parent (sent by the port_share_sendmsg
= @@ -539,7 +534,7 @@

if= (status >=3D 2 && command =3D=3D COMMAND_REDIRECT)
{
- = buf.len =3D status - 1;
+ buf.len =3D (int)status - 1;
if (proxy_entry_new(list, es, server_addr, received_fd,= &buf, journal_dir))
{
CLEAR(buf); /* we gave the buffer to proxy_entry_new = */
@@ -566,7 +561,7 @@
proxy_connection_io= _recv(struct proxy_connection *pc)
{
= /* recv data from socket */
- const int status =3D recv(pc->sd, BPTR(&pc->buf), BCAP(= &pc->buf), MSG_NOSIGNAL);
+ const ssize_t status =3D recv(pc->sd, BPTR(&pc->= buf), BCAP(&pc->buf), MSG_NOSIGNAL);
if (status= < 0)
{
return (errno =3D= =3D EAGAIN) ? IOSTAT_EAGAIN_ON_READ : IOSTAT_READ_ERROR;
@@= -577,8 +572,8 @@
{
r= eturn IOSTAT_READ_ERROR;
}
- dmsg(D_PS_PROXY_DEBUG, "PORT S= HARE PROXY: read[%d] %d", (int)pc->sd, status);
- pc->buf.len =3D status;=
+ dmsg(D_PS_PROXY_DE= BUG, "PORT SHARE PROXY: read[%d] %zd", (int)pc->sd, status);
+ pc->buf.le= n =3D (int)status;
}
return IOSTA= T_GOOD;
}
@@ -587,7 +582,7 @@
proxy_connection_io_send(struct proxy_connection *pc, int *bytes_sent)=

{
const socket_descriptor_t sd =3D p= c->counterpart->sd;
- const int status =3D send(sd, BPTR(&pc->buf), BLEN(&pc-&= gt;buf), MSG_NOSIGNAL);
+ const ssize_t status =3D send(sd, BPTR(&pc->buf), BLEN(&= pc->buf), MSG_NOSIGNAL);

if (stat= us < 0)
{
@@ -596,17 +591,17 @@

}
else
{=
- *bytes_sent +=3D sta= tus;
+ *bytes_= sent +=3D (int)status;
if (status !=3D pc->buf.= len)
{
- dmsg(D_PS_PROXY_DEBUG, "PORT SHARE PROXY: partia= l write[%d], tried=3D%d got=3D%d", (int)sd,
+ dmsg(D_PS_PROXY_DEBUG, "PORT = SHARE PROXY: partial write[%d], tried=3D%d got=3D%zd", (int)sd,=
pc->buf.len, status);
- buf_advance(&pc->buf, st= atus);
+ b= uf_advance(&pc->buf, (int)status);
retu= rn IOSTAT_EAGAIN_ON_WRITE;
}
= else
{
- dmsg(D_PS_PROXY_DEBUG, "PORT SHARE PROXY: wr= ote[%d] %d", (int)sd, status);
+ dmsg(D_PS_PROXY_DEBUG, "PORT SHARE PROXY: = wrote[%d] %zd", (int)sd, status);
pc->= buf.len =3D 0;
pc->buf.offset =3D 0;=
}
@@ -797,10 +792,6 @@
= msg(M_INFO, "PORT SHARE PROXY: proxy exiting");
}

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
/*
* Called from the main= OpenVPN process to enable the port
* share proxy.=

To view, visit change 1194. To unsubscribe, or fo= r help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id070d1a45d45f9029309d23df7f= 3cab9ce792205
Gerrit-Change-Number: 1194
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...>
Gerrit-MessageType: newchange
--XYs1+aR4f9U=--