From 95f7492875f00feb46ff32cda690e945453f92c7 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Thu, 28 Sep 2023 03:00:13 +0800 Subject: [PATCH] core/unit: use RET_GATHER in one more function --- src/core/unit.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/core/unit.c b/src/core/unit.c index 09fe023ae2e..ba3af56303d 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -3786,7 +3786,7 @@ int unit_add_blockdev_dependency(Unit *u, const char *what, UnitDependencyMask m } int unit_coldplug(Unit *u) { - int r = 0, q; + int r = 0; assert(u); @@ -3796,29 +3796,18 @@ int unit_coldplug(Unit *u) { u->coldplugged = true; - STRV_FOREACH(i, u->deserialized_refs) { - q = bus_unit_track_add_name(u, *i); - if (q < 0 && r >= 0) - r = q; - } + STRV_FOREACH(i, u->deserialized_refs) + RET_GATHER(r, bus_unit_track_add_name(u, *i)); + u->deserialized_refs = strv_free(u->deserialized_refs); - if (UNIT_VTABLE(u)->coldplug) { - q = UNIT_VTABLE(u)->coldplug(u); - if (q < 0 && r >= 0) - r = q; - } + if (UNIT_VTABLE(u)->coldplug) + RET_GATHER(r, UNIT_VTABLE(u)->coldplug(u)); - if (u->job) { - q = job_coldplug(u->job); - if (q < 0 && r >= 0) - r = q; - } - if (u->nop_job) { - q = job_coldplug(u->nop_job); - if (q < 0 && r >= 0) - r = q; - } + if (u->job) + RET_GATHER(r, job_coldplug(u->job)); + if (u->nop_job) + RET_GATHER(r, job_coldplug(u->nop_job)); CGroupContext *c = unit_get_cgroup_context(u); if (c) -- 2.47.3