summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-10-09 17:17:28 +0200
committerSven Eden <yamakuzure@gmx.net>2017-04-26 12:58:55 +0200
commitc221e39a6dce308a639185833310b995aad1fc56 (patch)
treed03a02670741a313fe7abbb0c27d580c32ea9642
parentbe70ef286ad74a5d9db1716d1b097ff0dbd3e713 (diff)
sd-daemon: simply code simplification
No change in behaviour, just make the code more obvious.
-rw-r--r--src/libelogind/sd-daemon/sd-daemon.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libelogind/sd-daemon/sd-daemon.c b/src/libelogind/sd-daemon/sd-daemon.c
index b26ecf26d..749a3646d 100644
--- a/src/libelogind/sd-daemon/sd-daemon.c
+++ b/src/libelogind/sd-daemon/sd-daemon.c
@@ -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);