From: Lennart Poettering Date: Tue, 19 Sep 2023 20:01:29 +0000 (+0200) Subject: scope: slightly simplify scope_enter_running() error handling X-Git-Tag: v255-rc1~488 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fsystemd.git;a=commitdiff_plain;h=648cb0248d14137f2eef5aa0cad2eea51ca25855 scope: slightly simplify scope_enter_running() error handling --- diff --git a/src/core/scope.c b/src/core/scope.c index 1bcd4ed84f2..1664d49c94b 100644 --- a/src/core/scope.c +++ b/src/core/scope.c @@ -449,13 +449,11 @@ static int scope_enter_running(Scope *s) { r = unit_attach_pids_to_cgroup(u, u->pids, NULL); if (r < 0) { log_unit_warning_errno(u, r, "Failed to add PIDs to scope's control group: %m"); - scope_enter_dead(s, SCOPE_FAILURE_RESOURCES); - return r; + goto fail; } if (r == 0) { - log_unit_warning(u, "No PIDs left to attach to the scope's control group, refusing."); - scope_enter_dead(s, SCOPE_FAILURE_RESOURCES); - return -ECHILD; + r = log_unit_warning_errno(u, SYNTHETIC_ERRNO(ECHILD), "No PIDs left to attach to the scope's control group, refusing."); + goto fail; } log_unit_debug(u, "%i %s added to scope's control group.", r, r == 1 ? "process" : "processes"); @@ -475,6 +473,10 @@ static int scope_enter_running(Scope *s) { /* Start watching the PIDs currently in the scope (legacy hierarchy only) */ (void) unit_enqueue_rewatch_pids(u); return 1; + +fail: + scope_enter_dead(s, SCOPE_FAILURE_RESOURCES); + return r; } static int scope_start(Unit *u) {