chiark / gitweb /
sd-daemon: simply code simplification
authorLennart Poettering <lennart@poettering.net>
Fri, 9 Oct 2015 15:17:28 +0000 (17:17 +0200)
committerSven Eden <yamakuzure@gmx.net>
Wed, 26 Apr 2017 10:58:55 +0000 (12:58 +0200)
No change in behaviour, just make the code more obvious.

src/libelogind/sd-daemon/sd-daemon.c

index b26ecf26d5fff5d0c6041aeae6b26639df21fc3d..749a3646d709193058ce42f791c568c1d124f4aa 100644 (file)
@@ -456,8 +456,10 @@ _public_ int sd_pid_notify_with_fds(pid_t pid, int unset_environment, const char
 
         if (n_fds > 0 || have_pid) {
                 /* CMSG_SPACE(0) may return value different then zero, which results in miscalculated controllen. */
-                msghdr.msg_controllen = (n_fds ? CMSG_SPACE(sizeof(int) * n_fds) : 0) +
-                                        CMSG_SPACE(sizeof(struct ucred)) * have_pid;
+                msghdr.msg_controllen =
+                        (n_fds > 0 ? CMSG_SPACE(sizeof(int) * n_fds) : 0) +
+                        (have_pid ? CMSG_SPACE(sizeof(struct ucred)) : 0);
+
                 msghdr.msg_control = alloca(msghdr.msg_controllen);
 
                 cmsg = CMSG_FIRSTHDR(&msghdr);