summaryrefslogtreecommitdiffstats
path: root/src/core/path.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-10-11 12:48:33 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-10-11 13:46:05 +0200
commit75193d4128c08291a17b0d7be11722d071650425 (patch)
tree6332a42542f59678bc2a6d3ff983354f5595be92 /src/core/path.c
parentcore: simplify unit_load() a bit (diff)
downloadsystemd-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/path.c')
-rw-r--r--src/core/path.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/core/path.c b/src/core/path.c
index e7071ccb4f..dff551f377 100644
--- a/src/core/path.c
+++ b/src/core/path.c
@@ -284,9 +284,7 @@ static int path_add_mount_dependencies(Path *p) {
static int path_verify(Path *p) {
assert(p);
-
- if (UNIT(p)->load_state != UNIT_LOADED)
- return 0;
+ assert(UNIT(p)->load_state == UNIT_LOADED);
if (!p->specs) {
log_unit_error(UNIT(p), "Path unit lacks path setting. Refusing.");
@@ -333,6 +331,20 @@ static int path_add_trigger_dependencies(Path *p) {
return unit_add_two_dependencies(UNIT(p), UNIT_BEFORE, UNIT_TRIGGERS, x, true, UNIT_DEPENDENCY_IMPLICIT);
}
+static int path_add_extras(Path *p) {
+ int r;
+
+ r = path_add_trigger_dependencies(p);
+ if (r < 0)
+ return r;
+
+ r = path_add_mount_dependencies(p);
+ if (r < 0)
+ return r;
+
+ return path_add_default_dependencies(p);
+}
+
static int path_load(Unit *u) {
Path *p = PATH(u);
int r;
@@ -344,20 +356,12 @@ static int path_load(Unit *u) {
if (r < 0)
return r;
- if (u->load_state == UNIT_LOADED) {
-
- r = path_add_trigger_dependencies(p);
- if (r < 0)
- return r;
-
- r = path_add_mount_dependencies(p);
- if (r < 0)
- return r;
+ if (u->load_state != UNIT_LOADED)
+ return 0;
- r = path_add_default_dependencies(p);
- if (r < 0)
- return r;
- }
+ r = path_add_extras(p);
+ if (r < 0)
+ return r;
return path_verify(p);
}