[Openvpn-devel] Remove unused addr_inet4or6, addr_guess_family and inline addr_copy_sa

Message ID 20221109110749.1245175-1-arne@rfc2549.org
State Accepted
Headers show
Series [Openvpn-devel] Remove unused addr_inet4or6, addr_guess_family and inline addr_copy_sa | expand

Commit Message

Arne Schwabe Nov. 9, 2022, 11:07 a.m. UTC
addr_copy_sa is just a single line and putting that simple assignment
into an extra function does not really improve clarity.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
---
 src/openvpn/socket.h | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

Comments

Gert Doering Nov. 11, 2022, 8:23 a.m. UTC | #1
Acked-by: Gert Doering <gert@greenie.muc.de>

My first thought was "trivial enough", the second thought was "oh wait"
- the old code copies "src->addr" to "dst->addr", while the new code copies
"src" to "dst".  Now, src/dst are "struct openvpn_sockaddr" here, which
is a struct containing only one member, "->addr" (which is a union) - so
the copying does the same thing, just with shorter source code lines.

Of course I have actually tested this :-) - the windows function has
only been compile tested (github actions, no errors) and the unix
function has been client-side tested with tests including TCP.

Your patch has been applied to the master branch.

commit 470d1d149aac162fac3390e7dcb29c2a9ea7dba4
Author: Arne Schwabe
Date:   Wed Nov 9 12:07:49 2022 +0100

     Remove unused addr_inet4or6, addr_guess_family and inline addr_copy_sa

     Signed-off-by: Arne Schwabe <arne@rfc2549.org>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20221109110749.1245175-1-arne@rfc2549.org>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25493.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/socket.h b/src/openvpn/socket.h
index 462afa31b..94c8b6dff 100644
--- a/src/openvpn/socket.h
+++ b/src/openvpn/socket.h
@@ -863,20 +863,6 @@  addr_zero_host(struct openvpn_sockaddr *addr)
     }
 }
 
-static inline void
-addr_copy_sa(struct openvpn_sockaddr *dst, const struct openvpn_sockaddr *src)
-{
-    dst->addr = src->addr;
-}
-
-static inline bool
-addr_inet4or6(struct sockaddr *addr)
-{
-    return addr->sa_family == AF_INET || addr->sa_family == AF_INET6;
-}
-
-int addr_guess_family(sa_family_t af, const char *name);
-
 static inline int
 af_addr_size(sa_family_t af)
 {
@@ -1052,7 +1038,7 @@  link_socket_read_udp_win32(struct link_socket *sock,
     sockethandle_t sh = { .s = sock->sd };
     if (sock->info.dco_installed)
     {
-        addr_copy_sa(&from->dest, &sock->info.lsa->actual.dest);
+        from->dest = sock->info.lsa->actual.dest;
         sh.is_handle = true;
     }
     return sockethandle_finalize(sh, &sock->reads, buf, from);
@@ -1089,7 +1075,7 @@  link_socket_read(struct link_socket *sock,
     else if (proto_is_tcp(sock->info.proto)) /* unified TCPv4 and TCPv6 */
     {
         /* from address was returned by accept */
-        addr_copy_sa(&from->dest, &sock->info.lsa->actual.dest);
+        from->dest = sock->info.lsa->actual.dest;
         return link_socket_read_tcp(sock, buf);
     }
     else