diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-03-02 15:51:31 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-03-02 15:55:44 +0100 |
commit | f36a9d5909019845d131e0c6c61f22b1d1956ca1 (patch) | |
tree | 7023bf19207e1903da61bef6a87d3a4fa2317178 /src/journal/journald-native.c | |
parent | test-sizeof: print size socklen_t (diff) | |
download | systemd-f36a9d5909019845d131e0c6c61f22b1d1956ca1.tar.xz systemd-f36a9d5909019845d131e0c6c61f22b1d1956ca1.zip |
tree-wide: use the return value from sockaddr_un_set_path()
It fully initializes the address structure, so no need for pre-initialization,
and also returns the length of the address, so no need to recalculate using
SOCKADDR_UN_LEN().
socklen_t is unsigned, so let's not use an int for it. (It doesn't matter, but
seems cleaner and more portable to not assume anything about the type.)
Diffstat (limited to 'src/journal/journald-native.c')
-rw-r--r-- | src/journal/journald-native.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c index 30d988544f..f2b867da3d 100644 --- a/src/journal/journald-native.c +++ b/src/journal/journald-native.c @@ -457,13 +457,13 @@ int server_open_native_socket(Server *s, const char *native_socket) { assert(native_socket); if (s->native_fd < 0) { - union sockaddr_union sa = { - .un.sun_family = AF_UNIX, - }; + union sockaddr_union sa; + size_t sa_len; r = sockaddr_un_set_path(&sa.un, native_socket); if (r < 0) return log_error_errno(r, "Unable to use namespace path %s for AF_UNIX socket: %m", native_socket); + sa_len = r; s->native_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0); if (s->native_fd < 0) @@ -471,7 +471,7 @@ int server_open_native_socket(Server *s, const char *native_socket) { (void) sockaddr_un_unlink(&sa.un); - r = bind(s->native_fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)); + r = bind(s->native_fd, &sa.sa, sa_len); if (r < 0) return log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path); |