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/socket-proxy | |
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/socket-proxy')
-rw-r--r-- | src/socket-proxy/socket-proxyd.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c index 2fb9c854fa..2ee6fc2f0a 100644 --- a/src/socket-proxy/socket-proxyd.c +++ b/src/socket-proxy/socket-proxyd.c @@ -373,20 +373,21 @@ static int resolve_remote(Connection *c) { .ai_flags = AI_ADDRCONFIG }; - union sockaddr_union sa = {}; const char *node, *service; int r; if (IN_SET(arg_remote_host[0], '/', '@')) { - int salen; + union sockaddr_union sa; + int sa_len; - salen = sockaddr_un_set_path(&sa.un, arg_remote_host); - if (salen < 0) { - log_error_errno(salen, "Specified address doesn't fit in an AF_UNIX address, refusing: %m"); + r = sockaddr_un_set_path(&sa.un, arg_remote_host); + if (r < 0) { + log_error_errno(r, "Specified address doesn't fit in an AF_UNIX address, refusing: %m"); goto fail; } + sa_len = r; - return connection_start(c, &sa.sa, salen); + return connection_start(c, &sa.sa, sa_len); } service = strrchr(arg_remote_host, ':'); |