]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pidref: move comments that doesn't belong in pidref_copy() to pidref_dup()
authorMike Yuan <me@yhndnzj.com>
Fri, 12 Jul 2024 15:15:50 +0000 (17:15 +0200)
committerMike Yuan <me@yhndnzj.com>
Sun, 21 Jul 2024 20:48:53 +0000 (22:48 +0200)
Follow-up for 232e66217d64aeab51786b0d2794377874ab61ab

src/basic/pidref.c
src/basic/pidref.h

index d9380a84ab4fe263a7f2613b2c5c037ddc5c798e..8529236c5ec80ec303840b83485a9b301e1e7264 100644 (file)
@@ -221,7 +221,7 @@ void pidref_done(PidRef *pidref) {
         };
 }
 
-PidRef *pidref_free(PidRef *pidref) {
+PidRefpidref_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);
index 0581f1af1e5fbb9be8286ac988197326bc250730..4738c6eb5d50032f7c0cec57c090b1125e31e066 100644 (file)
@@ -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);
+PidRefpidref_free(PidRef *pidref);
 DEFINE_TRIVIAL_CLEANUP_FUNC(PidRef*, pidref_free);
 
 int pidref_copy(const PidRef *pidref, PidRef *dest);