Skip to contentSkip to conversation

Change in openvpn[master]: error: Allow status argument to check_status to be ssize_t

Openvpn-devel In review flichtenheld (Code Review) 2 participants 6 messages Nov 7, 2025 – Nov 26, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1762517501000.I750a46246c0d2447a6691e5c25c4732e3d335a63@...2715...

#1 lore raw

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=email

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

---
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

src/openvpn/error.c +2 -2
index bd588d4..83eb9eb 100644
@@ -621,14 +621,14 @@
  * from the OS.
  */
 void
-x_check_status(int status, const char *description, struct link_socket *sock, struct tuntap *tt)
+x_check_status(ssize_t status, const char *description, struct link_socket *sock, struct tuntap *tt)
 {
     const char *extended_msg = NULL;
 
     bool crt_error = false;
     int my_errno = 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) : "", description, status);
 
     if (status < 0)
src/openvpn/error.h +2 -2
index 2913498..3088dbb 100644
@@ -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_socket *sock,
+void x_check_status(ssize_t status, const char *description, struct link_socket *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))
     {
src/openvpn/forward.c +6 -6
index fbef539..d54c679 100644
@@ -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 *buf,
                   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 != BLEN(&c->c2.to_tun))
             {
                 msg(D_LINK_ERRORS,
-                    "TUN/TAP packet was destructively fragmented on write to %s (tried=%d,actual=%d)",
+                    "TUN/TAP packet was destructively fragmented on write to %s (tried=%d,actual=%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)
 {
src/openvpn/forward.h +1 -1
index a575faf..3cd710e 100644
@@ -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=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I750a46246c0d2447a6691e5c25c4732e3d335a63
Gerrit-Change-Number: 1357
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1357?usp=email )

Change subject: error: Allow status argument to check_status to be ssize_t
......................................................................

Patch Set 4: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1357?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I750a46246c0d2447a6691e5c25c4732e3d335a63
Gerrit-Change-Number: 1357
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 26 Nov 2025 11:40:31 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#3 lore raw

PATCH v4 1/1 error: Allow status argument to check_status to be ssize_t

In reply to a message not in the archive

From: Frank Lichtenheld <[email protected]...>

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

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1357
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1357
This mail reflects revision 4 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

src/openvpn/error.c +2 -2
index bd588d4..83eb9eb 100644
@@ -621,14 +621,14 @@
  * from the OS.
  */
 void
-x_check_status(int status, const char *description, struct link_socket *sock, struct tuntap *tt)
+x_check_status(ssize_t status, const char *description, struct link_socket *sock, struct tuntap *tt)
 {
     const char *extended_msg = NULL;
 
     bool crt_error = false;
     int my_errno = 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) : "", description, status);
 
     if (status < 0)
src/openvpn/error.h +2 -2
index 2913498..3088dbb 100644
@@ -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_socket *sock,
+void x_check_status(ssize_t status, const char *description, struct link_socket *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))
     {
src/openvpn/forward.c +6 -6
index f01fb4c..e592eb5 100644
@@ -1673,6 +1673,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 *buf,
                   struct link_socket *sock)
@@ -1915,7 +1919,7 @@
         /*
          * Write to TUN/TAP device.
          */
-        int size;
+        ssize_t size;
 
 #ifdef LOG_RW
         if (c->c2.log_rw)
@@ -1956,7 +1960,7 @@
             if (size != BLEN(&c->c2.to_tun))
             {
                 msg(D_LINK_ERRORS,
-                    "TUN/TAP packet was destructively fragmented on write to %s (tried=%d,actual=%d)",
+                    "TUN/TAP packet was destructively fragmented on write to %s (tried=%d,actual=%zd)",
                     c->c1.tuntap->actual_name, BLEN(&c->c2.to_tun), size);
             }
 
@@ -1977,10 +1981,6 @@
     buf_reset(&c->c2.to_tun);
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 void
 pre_select(struct context *c)
 {
src/openvpn/forward.h +1 -1
index a575faf..3cd710e 100644
@@ -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)
     {
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: error: Allow status argument to check_status to be ssize_t

Most of this is really straightforward.

The "int64_t" for register_activity() seems a bit excessive ("we know that whatever comes back there will not be larger than 1 IP packet, so 64kbytes max...") - but then, this is all inlined, and the compiler can do whatever his integer rules make it feel happy, and efficient.

Your patch has been applied to the master branch.

commit ea2f8ef6fa19e7619e3dc2e7addc1a067f472abc

Author: Frank Lichtenheld
Date:   Wed Nov 26 12:40:40 2025 +0100
     error: Allow status argument to check_status to be ssize_t

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1357
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg34701.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#5) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1357?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

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

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1357
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34701.html

---
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/5

src/openvpn/error.c +2 -2
index bd588d4..83eb9eb 100644
@@ -621,14 +621,14 @@
  * from the OS.
  */
 void
-x_check_status(int status, const char *description, struct link_socket *sock, struct tuntap *tt)
+x_check_status(ssize_t status, const char *description, struct link_socket *sock, struct tuntap *tt)
 {
     const char *extended_msg = NULL;
 
     bool crt_error = false;
     int my_errno = 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) : "", description, status);
 
     if (status < 0)
src/openvpn/error.h +2 -2
index 2913498..3088dbb 100644
@@ -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_socket *sock,
+void x_check_status(ssize_t status, const char *description, struct link_socket *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))
     {
src/openvpn/forward.c +6 -6
index ccb8404..bc600d6 100644
@@ -1673,6 +1673,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 *buf,
                   struct link_socket *sock)
@@ -1915,7 +1919,7 @@
         /*
          * Write to TUN/TAP device.
          */
-        int size;
+        ssize_t size;
 
 #ifdef LOG_RW
         if (c->c2.log_rw)
@@ -1956,7 +1960,7 @@
             if (size != BLEN(&c->c2.to_tun))
             {
                 msg(D_LINK_ERRORS,
-                    "TUN/TAP packet was destructively fragmented on write to %s (tried=%d,actual=%d)",
+                    "TUN/TAP packet was destructively fragmented on write to %s (tried=%d,actual=%zd)",
                     c->c1.tuntap->actual_name, BLEN(&c->c2.to_tun), size);
             }
 
@@ -1977,10 +1981,6 @@
     buf_reset(&c->c2.to_tun);
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 void
 pre_select(struct context *c)
 {
src/openvpn/forward.h +1 -1
index a575faf..3cd710e 100644
@@ -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=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I750a46246c0d2447a6691e5c25c4732e3d335a63
Gerrit-Change-Number: 1357
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1357?usp=email )

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

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1357
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34701.html

---
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(-)
src/openvpn/error.c +2 -2
index bd588d4..83eb9eb 100644
@@ -621,14 +621,14 @@
  * from the OS.
  */
 void
-x_check_status(int status, const char *description, struct link_socket *sock, struct tuntap *tt)
+x_check_status(ssize_t status, const char *description, struct link_socket *sock, struct tuntap *tt)
 {
     const char *extended_msg = NULL;
 
     bool crt_error = false;
     int my_errno = 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) : "", description, status);
 
     if (status < 0)
src/openvpn/error.h +2 -2
index 2913498..3088dbb 100644
@@ -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_socket *sock,
+void x_check_status(ssize_t status, const char *description, struct link_socket *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))
     {
src/openvpn/forward.c +6 -6
index ccb8404..bc600d6 100644
@@ -1673,6 +1673,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 *buf,
                   struct link_socket *sock)
@@ -1915,7 +1919,7 @@
         /*
          * Write to TUN/TAP device.
          */
-        int size;
+        ssize_t size;
 
 #ifdef LOG_RW
         if (c->c2.log_rw)
@@ -1956,7 +1960,7 @@
             if (size != BLEN(&c->c2.to_tun))
             {
                 msg(D_LINK_ERRORS,
-                    "TUN/TAP packet was destructively fragmented on write to %s (tried=%d,actual=%d)",
+                    "TUN/TAP packet was destructively fragmented on write to %s (tried=%d,actual=%zd)",
                     c->c1.tuntap->actual_name, BLEN(&c->c2.to_tun), size);
             }
 
@@ -1977,10 +1981,6 @@
     buf_reset(&c->c2.to_tun);
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 void
 pre_select(struct context *c)
 {
src/openvpn/forward.h +1 -1
index a575faf..3cd710e 100644
@@ -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=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I750a46246c0d2447a6691e5c25c4732e3d335a63
Gerrit-Change-Number: 1357
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>