pidref: move comments that doesn't belong in pidref_copy() to pidref_dup()

Follow-up for 232e66217d
This commit is contained in:
Mike Yuan
2024-07-21 22:48:53 +02:00
parent 93df5cf8d9
commit 77f709ca84
2 changed files with 8 additions and 8 deletions
+7 -7
View File
@@ -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);
+1 -1
View 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);
PidRef* pidref_free(PidRef *pidref);
DEFINE_TRIVIAL_CLEANUP_FUNC(PidRef*, pidref_free);
int pidref_copy(const PidRef *pidref, PidRef *dest);