From bc2fcf7f7a7388f7c5656b8c3f82c8816bf0590f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 11 Jan 2018 16:02:13 +0100 Subject: [PATCH] process-util: replace PTR_TO_PID() and PID_TO_PTR macro by inline functions This way we gain some typesafety at no cost. --- src/basic/process-util.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/basic/process-util.h b/src/basic/process-util.h index 267888a..f904d12 100644 --- a/src/basic/process-util.h +++ b/src/basic/process-util.h @@ -116,8 +116,13 @@ int sigchld_code_from_string(const char *s) _pure_; int sched_policy_to_string_alloc(int i, char **s); int sched_policy_from_string(const char *s); -#define PTR_TO_PID(p) ((pid_t) ((uintptr_t) p)) -#define PID_TO_PTR(p) ((void*) ((uintptr_t) p)) +static inline pid_t PTR_TO_PID(const void *p) { + return (pid_t) ((uintptr_t) p); +} + +static inline void* PID_TO_PTR(pid_t pid) { + return (void*) ((uintptr_t) pid); +} void valgrind_summary_hack(void); -- 2.7.4