From: Mike Yuan Date: Fri, 12 Jul 2024 15:15:50 +0000 (+0200) Subject: pidref: move comments that doesn't belong in pidref_copy() to pidref_dup() X-Git-Tag: v257-rc1~846^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=77f709ca84051f6955e87c2498386db915ddcd67;p=thirdparty%2Fsystemd.git pidref: move comments that doesn't belong in pidref_copy() to pidref_dup() Follow-up for 232e66217d64aeab51786b0d2794377874ab61ab --- diff --git a/src/basic/pidref.c b/src/basic/pidref.c index d9380a84ab4..8529236c5ec 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 0581f1af1e5..4738c6eb5d5 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);