summaryrefslogtreecommitdiff
path: root/src/libsystemd-daemon
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsystemd-daemon')
-rw-r--r--src/libsystemd-daemon/sd-daemon.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/libsystemd-daemon/sd-daemon.c b/src/libsystemd-daemon/sd-daemon.c
index 9cc1c37b46..41f4b588df 100644
--- a/src/libsystemd-daemon/sd-daemon.c
+++ b/src/libsystemd-daemon/sd-daemon.c
@@ -278,11 +278,8 @@ _sd_export_ int sd_is_socket(int fd, int family, int type, int listening) {
return r;
if (family > 0) {
- union sockaddr_union sockaddr;
- socklen_t l;
-
- memset(&sockaddr, 0, sizeof(sockaddr));
- l = sizeof(sockaddr);
+ union sockaddr_union sockaddr = {};
+ socklen_t l = sizeof(sockaddr);
if (getsockname(fd, &sockaddr.sa, &l) < 0)
return -errno;
@@ -297,8 +294,8 @@ _sd_export_ int sd_is_socket(int fd, int family, int type, int listening) {
}
_sd_export_ int sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port) {
- union sockaddr_union sockaddr;
- socklen_t l;
+ union sockaddr_union sockaddr = {};
+ socklen_t l = sizeof(sockaddr);
int r;
if (family != 0 && family != AF_INET && family != AF_INET6)
@@ -308,9 +305,6 @@ _sd_export_ int sd_is_socket_inet(int fd, int family, int type, int listening, u
if (r <= 0)
return r;
- memset(&sockaddr, 0, sizeof(sockaddr));
- l = sizeof(sockaddr);
-
if (getsockname(fd, &sockaddr.sa, &l) < 0)
return -errno;
@@ -343,17 +337,14 @@ _sd_export_ int sd_is_socket_inet(int fd, int family, int type, int listening, u
}
_sd_export_ int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length) {
- union sockaddr_union sockaddr;
- socklen_t l;
+ union sockaddr_union sockaddr = {};
+ socklen_t l = sizeof(sockaddr);
int r;
r = sd_is_socket_internal(fd, type, listening);
if (r <= 0)
return r;
- memset(&sockaddr, 0, sizeof(sockaddr));
- l = sizeof(sockaddr);
-
if (getsockname(fd, &sockaddr.sa, &l) < 0)
return -errno;