Skip to contentSkip to conversation

Change in openvpn[master]: socket: Change return types of link_socket_write* to ssize_t

Openvpn-devel In review flichtenheld (Code Review) 2 participants 6 messages Sep 10, 2024 – Sep 19, 2024 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.1725970450000.I7852c06d331326c1dbab7b642254c0c00d4cebb8@...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/+/740?usp=email

to review the following change.

Change subject: socket: Change return types of link_socket_write* to ssize_t
......................................................................

socket: Change return types of link_socket_write* to ssize_t

This is the actual return value of send/sendto/sendmsg. We will leave it to the single caller of link_socket_write() to decide how to map that to the int buffer world. For now just cast it explicitly.

Change-Id I7852c06d331326c1dbab7b642254c0c00d4cebb8

---
M src/openvpn/forward.c
M src/openvpn/socket.c
M src/openvpn/socket.h

3 files changed, 13 insertions(+), 13 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/40/740/1

src/openvpn/forward.c +1 -1
index 40b7cc4..84c23b3 100644
@@ -1790,7 +1790,7 @@
                 socks_preprocess_outgoing_link(c, &to_addr, &size_delta);
 
                 /* Send packet */
-                size = link_socket_write(c->c2.link_socket, &c->c2.to_link, to_addr);
+                size = (int)link_socket_write(c->c2.link_socket, &c->c2.to_link, to_addr);
 
                 /* Undo effect of prepend */
                 link_socket_write_post_size_adjust(&size, size_delta, &c->c2.to_link);
src/openvpn/socket.c +2 -2
index 17c5e76..6c790a0 100644
@@ -3399,7 +3399,7 @@
  * Socket Write Routines
  */
 
-int
+ssize_t
 link_socket_write_tcp(struct link_socket *sock,
                       struct buffer *buf,
                       struct link_socket_actual *to)
@@ -3418,7 +3418,7 @@
 
 #if ENABLE_IP_PKTINFO
 
-size_t
+ssize_t
 link_socket_write_udp_posix_sendmsg(struct link_socket *sock,
                                     struct buffer *buf,
                                     struct link_socket_actual *to)
src/openvpn/socket.h +10 -10
index 47083ad..bbdabfb 100644
@@ -1099,9 +1099,9 @@
  * Socket Write routines
  */
 
-int link_socket_write_tcp(struct link_socket *sock,
-                          struct buffer *buf,
-                          struct link_socket_actual *to);
+ssize_t link_socket_write_tcp(struct link_socket *sock,
+                              struct buffer *buf,
+                              struct link_socket_actual *to);
 
 #ifdef _WIN32
 
@@ -1135,12 +1135,12 @@
 
 #else  /* ifdef _WIN32 */
 
-size_t link_socket_write_udp_posix_sendmsg(struct link_socket *sock,
-                                           struct buffer *buf,
-                                           struct link_socket_actual *to);
+ssize_t link_socket_write_udp_posix_sendmsg(struct link_socket *sock,
+                                            struct buffer *buf,
+                                            struct link_socket_actual *to);
 
 
-static inline size_t
+static inline ssize_t
 link_socket_write_udp_posix(struct link_socket *sock,
                             struct buffer *buf,
                             struct link_socket_actual *to)
@@ -1158,7 +1158,7 @@
                   (socklen_t) af_addr_size(to->dest.addr.sa.sa_family));
 }
 
-static inline size_t
+static inline ssize_t
 link_socket_write_tcp_posix(struct link_socket *sock,
                             struct buffer *buf,
                             struct link_socket_actual *to)
@@ -1168,7 +1168,7 @@
 
 #endif /* ifdef _WIN32 */
 
-static inline size_t
+static inline ssize_t
 link_socket_write_udp(struct link_socket *sock,
                       struct buffer *buf,
                       struct link_socket_actual *to)
@@ -1181,7 +1181,7 @@
 }
 
 /* write a TCP or UDP packet to link */
-static inline int
+static inline ssize_t
 link_socket_write(struct link_socket *sock,
                   struct buffer *buf,
                   struct link_socket_actual *to)

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

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

#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. ( http://gerrit.openvpn.net/c/openvpn/+/740?usp=email )

Change subject: socket: Change return types of link_socket_write* to ssize_t
......................................................................

Patch Set 1: Code-Review+2

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7852c06d331326c1dbab7b642254c0c00d4cebb8
Gerrit-Change-Number: 740
Gerrit-PatchSet: 1
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, 18 Sep 2024 20:48:22 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw

PATCH 1/1 socket: Change return types of link_socket_write* to ssize_t

In reply to a message not in the archive

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

This is the actual return value of send/sendto/sendmsg. We will leave it to the single caller of link_socket_write() to decide how to map that to the int buffer world. For now just cast it explicitly.

Change-Id I7852c06d331326c1dbab7b642254c0c00d4cebb8

---

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/+/740
This mail reflects revision 1 of this Change.

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

src/openvpn/forward.c +1 -1
index 40b7cc4..84c23b3 100644
@@ -1790,7 +1790,7 @@
                 socks_preprocess_outgoing_link(c, &to_addr, &size_delta);
 
                 /* Send packet */
-                size = link_socket_write(c->c2.link_socket, &c->c2.to_link, to_addr);
+                size = (int)link_socket_write(c->c2.link_socket, &c->c2.to_link, to_addr);
 
                 /* Undo effect of prepend */
                 link_socket_write_post_size_adjust(&size, size_delta, &c->c2.to_link);
src/openvpn/socket.c +2 -2
index 17c5e76..6c790a0 100644
@@ -3399,7 +3399,7 @@
  * Socket Write Routines
  */
 
-int
+ssize_t
 link_socket_write_tcp(struct link_socket *sock,
                       struct buffer *buf,
                       struct link_socket_actual *to)
@@ -3418,7 +3418,7 @@
 
 #if ENABLE_IP_PKTINFO
 
-size_t
+ssize_t
 link_socket_write_udp_posix_sendmsg(struct link_socket *sock,
                                     struct buffer *buf,
                                     struct link_socket_actual *to)
src/openvpn/socket.h +10 -10
index 47083ad..bbdabfb 100644
@@ -1099,9 +1099,9 @@
  * Socket Write routines
  */
 
-int link_socket_write_tcp(struct link_socket *sock,
-                          struct buffer *buf,
-                          struct link_socket_actual *to);
+ssize_t link_socket_write_tcp(struct link_socket *sock,
+                              struct buffer *buf,
+                              struct link_socket_actual *to);
 
 #ifdef _WIN32
 
@@ -1135,12 +1135,12 @@
 
 #else  /* ifdef _WIN32 */
 
-size_t link_socket_write_udp_posix_sendmsg(struct link_socket *sock,
-                                           struct buffer *buf,
-                                           struct link_socket_actual *to);
+ssize_t link_socket_write_udp_posix_sendmsg(struct link_socket *sock,
+                                            struct buffer *buf,
+                                            struct link_socket_actual *to);
 
 
-static inline size_t
+static inline ssize_t
 link_socket_write_udp_posix(struct link_socket *sock,
                             struct buffer *buf,
                             struct link_socket_actual *to)
@@ -1158,7 +1158,7 @@
                   (socklen_t) af_addr_size(to->dest.addr.sa.sa_family));
 }
 
-static inline size_t
+static inline ssize_t
 link_socket_write_tcp_posix(struct link_socket *sock,
                             struct buffer *buf,
                             struct link_socket_actual *to)
@@ -1168,7 +1168,7 @@
 
 #endif /* ifdef _WIN32 */
 
-static inline size_t
+static inline ssize_t
 link_socket_write_udp(struct link_socket *sock,
                       struct buffer *buf,
                       struct link_socket_actual *to)
@@ -1181,7 +1181,7 @@
 }
 
 /* write a TCP or UDP packet to link */
-static inline int
+static inline ssize_t
 link_socket_write(struct link_socket *sock,
                   struct buffer *buf,
                   struct link_socket_actual *to)
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: socket: Change return types of link_socket_write* to ssize_t

This is fallout from the -Wconversion patch set (commit 53449cb61f) where it turned out that the whole link_socket* call chain used inconsistent return types - so now it's consistent with sendmsg() etc., all using ssize_t. Stared-at-code and asked GHA :-)

Your patch has been applied to the master branch.

commit 2cc77debf0221fa0cef3ea470c1328d25397d021 (master)

Author: Frank Lichtenheld
Date:   Wed Sep 18 22:48:44 2024 +0200
     socket: Change return types of link_socket_write* to ssize_t

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg29323.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 (#2) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/740?usp=email )

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

Change subject: socket: Change return types of link_socket_write* to ssize_t
......................................................................

socket: Change return types of link_socket_write* to ssize_t

This is the actual return value of send/sendto/sendmsg. We will leave it to the single caller of link_socket_write() to decide how to map that to the int buffer world. For now just cast it explicitly.

Change-Id I7852c06d331326c1dbab7b642254c0c00d4cebb8

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg29323.html

---
M src/openvpn/forward.c
M src/openvpn/socket.c
M src/openvpn/socket.h

3 files changed, 13 insertions(+), 13 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/40/740/2

src/openvpn/forward.c +1 -1
index 374ba47..8c02407 100644
@@ -1792,7 +1792,7 @@
                 socks_preprocess_outgoing_link(c, &to_addr, &size_delta);
 
                 /* Send packet */
-                size = link_socket_write(c->c2.link_socket, &c->c2.to_link, to_addr);
+                size = (int)link_socket_write(c->c2.link_socket, &c->c2.to_link, to_addr);
 
                 /* Undo effect of prepend */
                 link_socket_write_post_size_adjust(&size, size_delta, &c->c2.to_link);
src/openvpn/socket.c +2 -2
index 17c5e76..6c790a0 100644
@@ -3399,7 +3399,7 @@
  * Socket Write Routines
  */
 
-int
+ssize_t
 link_socket_write_tcp(struct link_socket *sock,
                       struct buffer *buf,
                       struct link_socket_actual *to)
@@ -3418,7 +3418,7 @@
 
 #if ENABLE_IP_PKTINFO
 
-size_t
+ssize_t
 link_socket_write_udp_posix_sendmsg(struct link_socket *sock,
                                     struct buffer *buf,
                                     struct link_socket_actual *to)
src/openvpn/socket.h +10 -10
index 47083ad..bbdabfb 100644
@@ -1099,9 +1099,9 @@
  * Socket Write routines
  */
 
-int link_socket_write_tcp(struct link_socket *sock,
-                          struct buffer *buf,
-                          struct link_socket_actual *to);
+ssize_t link_socket_write_tcp(struct link_socket *sock,
+                              struct buffer *buf,
+                              struct link_socket_actual *to);
 
 #ifdef _WIN32
 
@@ -1135,12 +1135,12 @@
 
 #else  /* ifdef _WIN32 */
 
-size_t link_socket_write_udp_posix_sendmsg(struct link_socket *sock,
-                                           struct buffer *buf,
-                                           struct link_socket_actual *to);
+ssize_t link_socket_write_udp_posix_sendmsg(struct link_socket *sock,
+                                            struct buffer *buf,
+                                            struct link_socket_actual *to);
 
 
-static inline size_t
+static inline ssize_t
 link_socket_write_udp_posix(struct link_socket *sock,
                             struct buffer *buf,
                             struct link_socket_actual *to)
@@ -1158,7 +1158,7 @@
                   (socklen_t) af_addr_size(to->dest.addr.sa.sa_family));
 }
 
-static inline size_t
+static inline ssize_t
 link_socket_write_tcp_posix(struct link_socket *sock,
                             struct buffer *buf,
                             struct link_socket_actual *to)
@@ -1168,7 +1168,7 @@
 
 #endif /* ifdef _WIN32 */
 
-static inline size_t
+static inline ssize_t
 link_socket_write_udp(struct link_socket *sock,
                       struct buffer *buf,
                       struct link_socket_actual *to)
@@ -1181,7 +1181,7 @@
 }
 
 /* write a TCP or UDP packet to link */
-static inline int
+static inline ssize_t
 link_socket_write(struct link_socket *sock,
                   struct buffer *buf,
                   struct link_socket_actual *to)

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

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

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

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

Change subject: socket: Change return types of link_socket_write* to ssize_t
......................................................................

socket: Change return types of link_socket_write* to ssize_t

This is the actual return value of send/sendto/sendmsg. We will leave it to the single caller of link_socket_write() to decide how to map that to the int buffer world. For now just cast it explicitly.

Change-Id I7852c06d331326c1dbab7b642254c0c00d4cebb8

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg29323.html

---
M src/openvpn/forward.c
M src/openvpn/socket.c
M src/openvpn/socket.h

3 files changed, 13 insertions(+), 13 deletions(-)
src/openvpn/forward.c +1 -1
index 374ba47..8c02407 100644
@@ -1792,7 +1792,7 @@
                 socks_preprocess_outgoing_link(c, &to_addr, &size_delta);
 
                 /* Send packet */
-                size = link_socket_write(c->c2.link_socket, &c->c2.to_link, to_addr);
+                size = (int)link_socket_write(c->c2.link_socket, &c->c2.to_link, to_addr);
 
                 /* Undo effect of prepend */
                 link_socket_write_post_size_adjust(&size, size_delta, &c->c2.to_link);
src/openvpn/socket.c +2 -2
index 17c5e76..6c790a0 100644
@@ -3399,7 +3399,7 @@
  * Socket Write Routines
  */
 
-int
+ssize_t
 link_socket_write_tcp(struct link_socket *sock,
                       struct buffer *buf,
                       struct link_socket_actual *to)
@@ -3418,7 +3418,7 @@
 
 #if ENABLE_IP_PKTINFO
 
-size_t
+ssize_t
 link_socket_write_udp_posix_sendmsg(struct link_socket *sock,
                                     struct buffer *buf,
                                     struct link_socket_actual *to)
src/openvpn/socket.h +10 -10
index 47083ad..bbdabfb 100644
@@ -1099,9 +1099,9 @@
  * Socket Write routines
  */
 
-int link_socket_write_tcp(struct link_socket *sock,
-                          struct buffer *buf,
-                          struct link_socket_actual *to);
+ssize_t link_socket_write_tcp(struct link_socket *sock,
+                              struct buffer *buf,
+                              struct link_socket_actual *to);
 
 #ifdef _WIN32
 
@@ -1135,12 +1135,12 @@
 
 #else  /* ifdef _WIN32 */
 
-size_t link_socket_write_udp_posix_sendmsg(struct link_socket *sock,
-                                           struct buffer *buf,
-                                           struct link_socket_actual *to);
+ssize_t link_socket_write_udp_posix_sendmsg(struct link_socket *sock,
+                                            struct buffer *buf,
+                                            struct link_socket_actual *to);
 
 
-static inline size_t
+static inline ssize_t
 link_socket_write_udp_posix(struct link_socket *sock,
                             struct buffer *buf,
                             struct link_socket_actual *to)
@@ -1158,7 +1158,7 @@
                   (socklen_t) af_addr_size(to->dest.addr.sa.sa_family));
 }
 
-static inline size_t
+static inline ssize_t
 link_socket_write_tcp_posix(struct link_socket *sock,
                             struct buffer *buf,
                             struct link_socket_actual *to)
@@ -1168,7 +1168,7 @@
 
 #endif /* ifdef _WIN32 */
 
-static inline size_t
+static inline ssize_t
 link_socket_write_udp(struct link_socket *sock,
                       struct buffer *buf,
                       struct link_socket_actual *to)
@@ -1181,7 +1181,7 @@
 }
 
 /* write a TCP or UDP packet to link */
-static inline int
+static inline ssize_t
 link_socket_write(struct link_socket *sock,
                   struct buffer *buf,
                   struct link_socket_actual *to)

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

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