chiark / gitweb /
bus-creds: always set SD_BUS_CREDS_PID when we set pid in the mask
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 25 May 2015 00:20:06 +0000 (20:20 -0400)
committerSven Eden <yamakuzure@gmx.net>
Tue, 14 Mar 2017 09:00:33 +0000 (10:00 +0100)
Also reorder the code a bit to be easier to parse.

src/libelogind/sd-bus/bus-creds.c

index 1ae5a12ebbcede1fbe9344f240baa925c0d9990f..1634efb45b856ca2a04c4e9da8bf490d41491bc4 100644 (file)
@@ -740,11 +740,13 @@ int bus_creds_add_more(sd_bus_creds *c, uint64_t mask, pid_t pid, pid_t tid) {
                 return 0;
 
         /* Try to retrieve PID from creds if it wasn't passed to us */
-        if (pid <= 0 && (c->mask & SD_BUS_CREDS_PID))
+        if (pid > 0) {
+                c->pid = pid;
+                c->mask |= SD_BUS_CREDS_PID;
+        } else if (c->mask & SD_BUS_CREDS_PID)
                 pid = c->pid;
-
-        /* Without pid we cannot do much... */
-        if (pid <= 0)
+        else
+                /* Without pid we cannot do much... */
                 return 0;
 
         /* Try to retrieve TID from creds if it wasn't passed to us */
@@ -756,9 +758,6 @@ int bus_creds_add_more(sd_bus_creds *c, uint64_t mask, pid_t pid, pid_t tid) {
         if (missing == 0)
                 return 0;
 
-        c->pid = pid;
-        c->mask |= SD_BUS_CREDS_PID;
-
         if (tid > 0) {
                 c->tid = tid;
                 c->mask |= SD_BUS_CREDS_TID;