anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0048-shared-avoid-semi-duplicating-socket_address_equal.patch

923a60
From ea81ddfdc0eadfb62e28ed998d33c5e1d3b3abab Mon Sep 17 00:00:00 2001
923a60
From: Michal Schmidt <mschmidt@redhat.com>
923a60
Date: Fri, 20 Feb 2015 02:13:03 +0100
923a60
Subject: [PATCH] shared: avoid semi-duplicating socket_address_equal()
923a60
923a60
Just call socket_address_equal() from socket_address_matches_fd()
923a60
instead of implementing similar comparing of addresses.
923a60
923a60
(cherry picked from commit 02233928a502e46fc125118dba7234ba3e48dc15)
923a60
---
923a60
 src/shared/socket-util.c | 18 +-----------------
923a60
 1 file changed, 1 insertion(+), 17 deletions(-)
923a60
923a60
diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c
923a60
index c31f60ec7e..deecce8a80 100644
923a60
--- a/src/shared/socket-util.c
923a60
+++ b/src/shared/socket-util.c
923a60
@@ -464,23 +464,7 @@ bool socket_address_matches_fd(const SocketAddress *a, int fd) {
923a60
                         return false;
923a60
         }
923a60
 
923a60
-        switch (b.sockaddr.sa.sa_family) {
923a60
-
923a60
-        case AF_INET:
923a60
-                return b.sockaddr.in.sin_port == a->sockaddr.in.sin_port &&
923a60
-                        b.sockaddr.in.sin_addr.s_addr == a->sockaddr.in.sin_addr.s_addr;
923a60
-
923a60
-        case AF_INET6:
923a60
-                return b.sockaddr.in6.sin6_port == a->sockaddr.in6.sin6_port &&
923a60
-                        memcmp(&b.sockaddr.in6.sin6_addr, &a->sockaddr.in6.sin6_addr, sizeof(struct in6_addr)) == 0;
923a60
-
923a60
-        case AF_UNIX:
923a60
-                return b.sockaddr.size == a->size &&
923a60
-                        memcmp(b.sockaddr.un.sun_path, a->sockaddr.un.sun_path, b.size - offsetof(struct sockaddr_un, sun_path)) == 0;
923a60
-
923a60
-        }
923a60
-
923a60
-        return false;
923a60
+        return socket_address_equal(a, &b);
923a60
 }
923a60
 
923a60
 int sockaddr_pretty(const struct sockaddr *_sa, socklen_t salen, bool translate_ipv6, char **ret) {