]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/libsystemd/sd-daemon/sd-daemon.c
tree-wide: use the return value from sockaddr_un_set_path()
[thirdparty/systemd.git] / src / libsystemd / sd-daemon / sd-daemon.c
index ff71194331b08fa43497da23db9300ff64f9bed7..4cd71cb2d3a022e6534fce90e6f0a89b589d5dfa 100644 (file)
@@ -443,7 +443,7 @@ _public_ int sd_pid_notify_with_fds(
                 const int *fds,
                 unsigned n_fds) {
 
-        union sockaddr_union sockaddr = {};
+        union sockaddr_union sockaddr;
         struct iovec iovec;
         struct msghdr msghdr = {
                 .msg_iov = &iovec,
@@ -454,7 +454,7 @@ _public_ int sd_pid_notify_with_fds(
         struct cmsghdr *cmsg = NULL;
         const char *e;
         bool send_ucred;
-        int r, salen;
+        int r;
 
         if (!state) {
                 r = -EINVAL;
@@ -470,11 +470,10 @@ _public_ int sd_pid_notify_with_fds(
         if (!e)
                 return 0;
 
-        salen = sockaddr_un_set_path(&sockaddr.un, e);
-        if (salen < 0) {
-                r = salen;
+        r = sockaddr_un_set_path(&sockaddr.un, e);
+        if (r < 0)
                 goto finish;
-        }
+        msghdr.msg_namelen = r;
 
         fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0);
         if (fd < 0) {
@@ -485,7 +484,6 @@ _public_ int sd_pid_notify_with_fds(
         (void) fd_inc_sndbuf(fd, SNDBUF_SIZE);
 
         iovec = IOVEC_MAKE_STRING(state);
-        msghdr.msg_namelen = salen;
 
         send_ucred =
                 (pid != 0 && pid != getpid_cached()) ||