From 77f709ca84051f6955e87c2498386db915ddcd67 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Fri, 12 Jul 2024 17:15:50 +0200 Subject: [PATCH] pidref: move comments that doesn't belong in pidref_copy() to pidref_dup() Follow-up for 232e66217d64aeab51786b0d2794377874ab61ab --- src/basic/pidref.c | 14 +++++++------- src/basic/pidref.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/basic/pidref.c b/src/basic/pidref.c index d9380a84ab..8529236c5e 100644 --- a/src/basic/pidref.c +++ b/src/basic/pidref.c @@ -221,7 +221,7 @@ void pidref_done(PidRef *pidref) { }; } -PidRef *pidref_free(PidRef *pidref) { +PidRef* pidref_free(PidRef *pidref) { /* Regularly, this is an embedded structure. But sometimes we want it on the heap too */ if (!pidref) return NULL; @@ -234,13 +234,10 @@ int pidref_copy(const PidRef *pidref, PidRef *dest) { _cleanup_close_ int dup_fd = -EBADF; pid_t dup_pid = 0; - assert(dest); + /* If NULL is passed we'll generate a PidRef that refers to no process. This makes it easy to + * copy pidref fields that might or might not reference a process yet. */ - /* Allocates a new PidRef on the heap, making it a copy of the specified pidref. This does not try to - * acquire a pidfd if we don't have one yet! - * - * If NULL is passed we'll generate a PidRef that refers to no process. This makes it easy to copy - * pidref fields that might or might not reference a process yet. */ + assert(dest); if (pidref) { if (pidref->fd >= 0) { @@ -269,6 +266,9 @@ int pidref_dup(const PidRef *pidref, PidRef **ret) { _cleanup_(pidref_freep) PidRef *dup_pidref = NULL; int r; + /* Allocates a new PidRef on the heap, making it a copy of the specified pidref. This does not try to + * acquire a pidfd if we don't have one yet! */ + assert(ret); dup_pidref = newdup(PidRef, &PIDREF_NULL, 1); diff --git a/src/basic/pidref.h b/src/basic/pidref.h index 0581f1af1e..4738c6eb5d 100644 --- a/src/basic/pidref.h +++ b/src/basic/pidref.h @@ -39,7 +39,7 @@ static inline int pidref_set_self(PidRef *pidref) { bool pidref_is_self(const PidRef *pidref); void pidref_done(PidRef *pidref); -PidRef *pidref_free(PidRef *pidref); +PidRef* pidref_free(PidRef *pidref); DEFINE_TRIVIAL_CLEANUP_FUNC(PidRef*, pidref_free); int pidref_copy(const PidRef *pidref, PidRef *dest);