]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
process-util: rework TAKE_PID() to be side-effect free
authorLennart Poettering <lennart@poettering.net>
Wed, 3 Nov 2021 14:55:14 +0000 (15:55 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 3 Nov 2021 14:57:02 +0000 (15:57 +0100)
src/basic/process-util.h

index c7622c98df5d39c2b752445166fc368d44807d5f..25dea35ce6cd0293ea35f056922cd7453f6804be 100644 (file)
@@ -192,8 +192,9 @@ assert_cc(TASKS_MAX <= (unsigned long) PID_T_MAX);
 /* Like TAKE_PTR() but for child PIDs, resetting them to 0 */
 #define TAKE_PID(pid)                           \
         ({                                      \
-                pid_t _pid_ = (pid);            \
-                (pid) = 0;                      \
+                pid_t *_ppid_ = &(pid);         \
+                pid_t _pid_ = *_ppid_;          \
+                *_ppid_ = 0;                    \
                 _pid_;                          \
         })