From 535b7fcb44f0a862e1707d0cb788afbbd20ee31e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 17 Oct 2022 10:48:52 +0200 Subject: [PATCH] core: simplify the return convention in manager_load_unit() This function was returning 0 or 1 on success. It has many callers, and it wasn't clear if any of them care about the distinction. It turns out they don't and the return values were done for convenience because manager_load_unit_prepare() returns 0 or 1. Let's invert the code in the static function to follow the usual pattern where 0 means "no work was done" and 1 means "work was done", and make the non-static function always return 0 to make the code easier to read, and also add comments that explain what is happening. No functional change. --- src/core/manager.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/manager.c b/src/core/manager.c index 98387894350..a59afafb589 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -2161,7 +2161,7 @@ int manager_load_unit_prepare( unit->load_state = UNIT_STUB; else { *ret = unit; - return 1; + return 0; /* The unit was already loaded */ } } else { unit = cleanup_unit = unit_new(m, unit_vtable[t]->object_size); @@ -2186,7 +2186,7 @@ int manager_load_unit_prepare( *ret = unit; TAKE_PTR(cleanup_unit); - return 0; + return 1; /* The unit was added the load queue */ } int manager_load_unit( @@ -2203,11 +2203,11 @@ int manager_load_unit( /* This will load the unit config, but not actually start any services or anything. */ r = manager_load_unit_prepare(m, name, path, e, ret); - if (r != 0) + if (r <= 0) return r; + /* Unit was newly loaded */ manager_dispatch_load_queue(m); - *ret = unit_follow_merge(*ret); return 0; } -- 2.47.3