From: "flichtenheld (Code Review)" Date: Fri, 7 Nov 2025 12:11:49 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <002fbf1fad8e01535046079ad4e29146485319b9-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="pmSbtlhMuWI="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: error: Allow status argument to check_status to be ssize_t List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --pmSbtlhMuWI= 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/+/1357?usp=3Demail to review the following change. Change subject: error: Allow status argument to check_status to be ssize_t ...................................................................... error: Allow status argument to check_status to be ssize_t We only check for < 0 so no reason not to allow bigger signed values. This makes it easier to feed result values of read/write to it. Fixes a conversion warning in process_outgoing_tun. Also changes register_activity to int64_t for similar reasons. Change-Id: I750a46246c0d2447a6691e5c25c4732e3d335a63 Signed-off-by: Frank Lichtenheld --- M src/openvpn/error.c M src/openvpn/error.h M src/openvpn/forward.c M src/openvpn/forward.h 4 files changed, 11 insertions(+), 11 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/57/1357/1 diff --git a/src/openvpn/error.c b/src/openvpn/error.c index bd588d4..83eb9eb 100644 --- a/src/openvpn/error.c +++ b/src/openvpn/error.c @@ -621,14 +621,14 @@ * from the OS. */ void -x_check_status(int status, const char *description, struct link_socket *so= ck, struct tuntap *tt) +x_check_status(ssize_t status, const char *description, struct link_socket= *sock, struct tuntap *tt) { const char *extended_msg =3D NULL; bool crt_error =3D false; int my_errno =3D openvpn_errno_maybe_crt(&crt_error); - msg(x_cs_verbose_level, "%s %s returned %d", + msg(x_cs_verbose_level, "%s %s returned %zd", sock ? proto2ascii(sock->info.proto, sock->info.af, true) : "", de= scription, status); if (status < 0) diff --git a/src/openvpn/error.h b/src/openvpn/error.h index 2913498..3088dbb 100644 --- a/src/openvpn/error.h +++ b/src/openvpn/error.h @@ -307,11 +307,11 @@ void set_check_status(unsigned int info_level, unsigned int verbose_level); -void x_check_status(int status, const char *description, struct link_socke= t *sock, +void x_check_status(ssize_t status, const char *description, struct link_s= ocket *sock, struct tuntap *tt); static inline void -check_status(int status, const char *description, struct link_socket *sock= , struct tuntap *tt) +check_status(ssize_t status, const char *description, struct link_socket *= sock, struct tuntap *tt) { if (status < 0 || check_debug_level(x_cs_verbose_level)) { diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index fbef539..d54c679 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -1655,6 +1655,10 @@ #undef MAX_ICMPV6LEN } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + void process_ip_header(struct context *c, unsigned int flags, struct buffer *bu= f, struct link_socket *sock) @@ -1897,7 +1901,7 @@ /* * Write to TUN/TAP device. */ - int size; + ssize_t size; #ifdef LOG_RW if (c->c2.log_rw) @@ -1938,7 +1942,7 @@ if (size !=3D BLEN(&c->c2.to_tun)) { msg(D_LINK_ERRORS, - "TUN/TAP packet was destructively fragmented on write = to %s (tried=3D%d,actual=3D%d)", + "TUN/TAP packet was destructively fragmented on write = to %s (tried=3D%d,actual=3D%zd)", c->c1.tuntap->actual_name, BLEN(&c->c2.to_tun), size); } @@ -1959,10 +1963,6 @@ buf_reset(&c->c2.to_tun); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - void pre_select(struct context *c) { diff --git a/src/openvpn/forward.h b/src/openvpn/forward.h index a575faf..3cd710e 100644 --- a/src/openvpn/forward.h +++ b/src/openvpn/forward.h @@ -343,7 +343,7 @@ } static inline void -register_activity(struct context *c, const int size) +register_activity(struct context *c, const int64_t size) { if (c->options.inactivity_timeout) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1357?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: I750a46246c0d2447a6691e5c25c4732e3d335a63 Gerrit-Change-Number: 1357 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --pmSbtlhMuWI= 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

error: Allow status argument to check_statu=
s to be ssize_t

We only check for < 0 so no reason not to allow b= igger
signed values. This makes it easier to feed result
values of re= ad/write to it. Fixes a conversion warning
in process_outgoing_tun.
<= br>Also changes register_activity to int64_t for similar
reasons.
Change-Id: I750a46246c0d2447a6691e5c25c4732e3d335a63
Signed-off-by: Fra= nk Lichtenheld <frank@...2641...>
---
M src/openvpn/error.c
= M src/openvpn/error.h
M src/openvpn/forward.c
M src/openvpn/forward.h=
4 files changed, 11 insertions(+), 11 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/57/1357=
/1
diff --git a/src/openvpn/error.c b/src/openvpn/error.cindex bd588d4..83eb9eb 100644
--- a/src/openvpn/erro= r.c
+++ b/src/openvpn/error.c
@@ -621,14 +6= 21,14 @@
* from the OS.
*/
void
-x_check_stat= us(int status, const char *description, struct link_socket *sock, struct tu= ntap *tt)
+x_check_st= atus(ssize_t status, const char *description, struct link_socket *sock, str= uct tuntap *tt)
{
const char *extende= d_msg =3D NULL;

bool crt_error =3D f= alse;
int my_errno =3D openvpn_errno_maybe_crt(&cr= t_error);

- msg(x_cs_verbose_level, "%s %s returned %d",
= + msg(x_cs_verbose_level, &q= uot;%s %s returned %zd",
sock ? proto2ascii(s= ock->info.proto, sock->info.af, true) : "", description, st= atus);

if (status < 0)
= diff --git a/src/openvpn/error.h b/src/openvpn/error.h
index 2913498..3088dbb 100644
--- a/src/openvpn/error.h
+++ b/src/openvpn/error.h
@@ -307,11 +307,11= @@

void set_check_status(unsigned int i= nfo_level, unsigned int verbose_level);

-void x_check_status(int status, const c= har *description, struct link_socket *sock,
+void x_check_status(ssize_t status, const char *des= cription, struct link_socket *sock,
st= ruct tuntap *tt);

static inline void
-check_status(int status, = const char *description, struct link_socket *sock, struct tuntap *tt)
+check_status(ssize_t stat= us, const char *description, struct link_socket *sock, struct tuntap *tt)
{
if (status < 0 || check_debug_lev= el(x_cs_verbose_level))
{
diff --git a= /src/openvpn/forward.c b/src/openvpn/forward.c
index fbef53= 9..d54c679 100644
--- a/src/openvpn/forward.c
+++ b/src/openvpn/forward.c

@@ -1655,6 +1655,10 @@
#undef MAX_ICMPV6LEN
}

+#if defined(__GNUC__) || = defined(__clang__)
+#= pragma GCC diagnostic pop
+#endif
+=
void
process_ip_header(struct context *c, unsig= ned int flags, struct buffer *buf,
struc= t link_socket *sock)
@@ -1897,7 +1901,7 @@
= /*
* Write to TUN/TAP device.
= */
- = int size;
+ = ssize_t size;

#ifdef LOG_RW if (c->c2.log_rw)
@@ -1938,7 +1942,7 @@<= /span>
if (size !=3D BLEN(&c->c2.to_tun))

{
msg(D_LINK_ERRO= RS,
- = "TUN/TAP packet was destructively fragmented on write to %s (tried= =3D%d,actual=3D%d)",
+ "TUN/TAP packet was destructively fragmented= on write to %s (tried=3D%d,actual=3D%zd)",
= c->c1.tuntap->actual_name, BLEN(&c->c2.to_tun), siz= e);
}

@@ -19= 59,10 +1963,6 @@
buf_reset(&c->c2.to_tun);
}

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif

-
void
pre_select(s= truct context *c)
{
diff --git a/src/openv= pn/forward.h b/src/openvpn/forward.h
index a575faf..3cd710e= 100644
--- a/src/openvpn/forward.h
+++ b/s= rc/openvpn/forward.h
@@ -343,7 +343,7 @@
}=

static inline void
-register_activity(struct context *c, const= int size)
+register_= activity(struct context *c, const int64_t size)
{ if (c->options.inactivity_timeout)
{

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

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I750a46246c0d2447a6691e5c25c= 4732e3d335a63
Gerrit-Change-Number: 1357
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...>
= --pmSbtlhMuWI=--