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/automount.c | |
parent | core: simplify unit_load() a bit (diff) | |
download | systemd-75193d4128c08291a17b0d7be11722d071650425.tar.xz systemd-75193d4128c08291a17b0d7be11722d071650425.zip |
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/automount.c')
-rw-r--r-- | src/core/automount.c | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/src/core/automount.c b/src/core/automount.c index c15520c1e5..0ecacc12c8 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -164,9 +164,7 @@ static int automount_verify(Automount *a) { int r; assert(a); - - if (UNIT(a)->load_state != UNIT_LOADED) - return 0; + assert(UNIT(a)->load_state == UNIT_LOADED); if (path_equal(a->where, "/")) { log_unit_error(UNIT(a), "Cannot have an automount unit for the root directory. Refusing."); @@ -201,6 +199,24 @@ static int automount_set_where(Automount *a) { return 1; } +static int automount_add_extras(Automount *a) { + int r; + + r = automount_set_where(a); + if (r < 0) + return r; + + r = automount_add_trigger_dependencies(a); + if (r < 0) + return r; + + r = automount_add_mount_dependencies(a); + if (r < 0) + return r; + + return automount_add_default_dependencies(a); +} + static int automount_load(Unit *u) { Automount *a = AUTOMOUNT(u); int r; @@ -213,23 +229,12 @@ static int automount_load(Unit *u) { if (r < 0) return r; - if (u->load_state == UNIT_LOADED) { - r = automount_set_where(a); - if (r < 0) - return r; - - r = automount_add_trigger_dependencies(a); - if (r < 0) - return r; - - r = automount_add_mount_dependencies(a); - if (r < 0) - return r; + if (u->load_state != UNIT_LOADED) + return 0; - r = automount_add_default_dependencies(a); - if (r < 0) - return r; - } + r = automount_add_extras(a); + if (r < 0) + return r; return automount_verify(a); } |