diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-10-11 12:48:33 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-10-11 13:46:05 +0200 |
commit | 75193d4128c08291a17b0d7be11722d071650425 (patch) | |
tree | 6332a42542f59678bc2a6d3ff983354f5595be92 /src/core/slice.c | |
parent | c3784a7d78df9c8f50ce6d14642cf37d412edcc6 (diff) | |
download | systemd-75193d4128c08291a17b0d7be11722d071650425.tar.gz |
core: adjust load functions for other unit types to be more like service
No functional change, just adjusting code to follow the same pattern
everywhere. In particular, never call _verify() on an already loaded unit,
but return early from the caller instead. This makes the code a bit easier
to follow.
Diffstat (limited to 'src/core/slice.c')
-rw-r--r-- | src/core/slice.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/core/slice.c b/src/core/slice.c index 9ef12023ad..d97a262786 100644 --- a/src/core/slice.c +++ b/src/core/slice.c @@ -91,9 +91,7 @@ static int slice_verify(Slice *s) { int r; assert(s); - - if (UNIT(s)->load_state != UNIT_LOADED) - return 0; + assert(UNIT(s)->load_state == UNIT_LOADED); if (!slice_name_is_valid(UNIT(s)->id)) { log_unit_error(UNIT(s), "Slice name %s is not valid. Refusing.", UNIT(s)->id); @@ -174,21 +172,21 @@ static int slice_load(Unit *u) { if (r < 0) return r; - /* This is a new unit? Then let's add in some extras */ - if (u->load_state == UNIT_LOADED) { + if (u->load_state != UNIT_LOADED) + return 0; - r = unit_patch_contexts(u); - if (r < 0) - return r; + /* This is a new unit? Then let's add in some extras */ + r = unit_patch_contexts(u); + if (r < 0) + return r; - r = slice_add_parent_slice(s); - if (r < 0) - return r; + r = slice_add_parent_slice(s); + if (r < 0) + return r; - r = slice_add_default_dependencies(s); - if (r < 0) - return r; - } + r = slice_add_default_dependencies(s); + if (r < 0) + return r; return slice_verify(s); } |