diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-04-05 22:24:10 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-04-10 18:59:42 -0400 |
commit | 1c6330456c5ae76085c63d2a7cf3d722596e545a (patch) | |
tree | 3b6a50e4fd7e7342679b3deb0f254b545567e7f5 /src/libsystemd-daemon | |
parent | 0affed79d2e30013f07cb94e6f07e3fcb81c02fa (diff) |
Use initalization instead of explicit zeroing in more places
Diffstat (limited to 'src/libsystemd-daemon')
-rw-r--r-- | src/libsystemd-daemon/sd-daemon.c | 21 |
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; |