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 b26ecf2..749a364 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. */
 
         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);
                 msghdr.msg_control = alloca(msghdr.msg_controllen);
 
                 cmsg = CMSG_FIRSTHDR(&msghdr);