From 3cb4674019567ef93e4a463dd145fd3af6242877 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 10 Jul 2014 21:16:40 +0200 Subject: libsystemd: make use of our common sockaddr_union everywhere --- src/libsystemd/sd-bus/bus-internal.h | 7 +------ src/libsystemd/sd-daemon/sd-daemon.c | 11 ++--------- 2 files changed, 3 insertions(+), 15 deletions(-) (limited to 'src/libsystemd') diff --git a/src/libsystemd/sd-bus/bus-internal.h b/src/libsystemd/sd-bus/bus-internal.h index d1183d69c4..618e82c98f 100644 --- a/src/libsystemd/sd-bus/bus-internal.h +++ b/src/libsystemd/sd-bus/bus-internal.h @@ -237,12 +237,7 @@ struct sd_bus { Hashmap *vtable_methods; Hashmap *vtable_properties; - union { - struct sockaddr sa; - struct sockaddr_un un; - struct sockaddr_in in; - struct sockaddr_in6 in6; - } sockaddr; + union sockaddr_union sockaddr; socklen_t sockaddr_size; char *kernel; diff --git a/src/libsystemd/sd-daemon/sd-daemon.c b/src/libsystemd/sd-daemon/sd-daemon.c index 7caa63db14..46241f77ff 100644 --- a/src/libsystemd/sd-daemon/sd-daemon.c +++ b/src/libsystemd/sd-daemon/sd-daemon.c @@ -37,6 +37,7 @@ #include "util.h" #include "path-util.h" +#include "socket-util.h" #include "sd-daemon.h" _public_ int sd_listen_fds(int unset_environment) { @@ -196,14 +197,6 @@ static int sd_is_socket_internal(int fd, int type, int listening) { return 1; } -union sockaddr_union { - struct sockaddr sa; - struct sockaddr_in in4; - struct sockaddr_in6 in6; - struct sockaddr_un un; - struct sockaddr_storage storage; -}; - _public_ int sd_is_socket(int fd, int family, int type, int listening) { int r; @@ -261,7 +254,7 @@ _public_ int sd_is_socket_inet(int fd, int family, int type, int listening, uint if (l < sizeof(struct sockaddr_in)) return -EINVAL; - return htons(port) == sockaddr.in4.sin_port; + return htons(port) == sockaddr.in.sin_port; } else { if (l < sizeof(struct sockaddr_in6)) return -EINVAL; -- cgit v1.2.3-54-g00ecf