}
/* Keep track of failed units */
- if (ns == UNIT_FAILED && os != UNIT_FAILED)
+ if (ns == UNIT_FAILED)
set_put(u->manager->failed_units, u);
- else if (os == UNIT_FAILED && ns != UNIT_FAILED)
+ else
set_remove(u->manager->failed_units, u);
/* Make sure the cgroup is always removed when we become inactive */
}
static int maybe_warn_about_dependency(const char *id, const char *other, UnitDependency dependency) {
+ assert(id);
+
switch (dependency) {
case UNIT_REQUIRES:
case UNIT_REQUIRES_OVERRIDABLE:
case _UNIT_DEPENDENCY_INVALID:
break;
}
+
assert_not_reached("Invalid dependency type");
}
assert(u);
- if ((r = unit_add_dependency(u, d, other, add_reference)) < 0)
+ r = unit_add_dependency(u, d, other, add_reference);
+ if (r < 0)
return r;
- if ((r = unit_add_dependency(u, e, other, add_reference)) < 0)
+ r = unit_add_dependency(u, e, other, add_reference);
+ if (r < 0)
return r;
return 0;
}
int unit_add_two_dependencies_by_name(Unit *u, UnitDependency d, UnitDependency e, const char *name, const char *path, bool add_reference) {
+ _cleanup_free_ char *s = NULL;
Unit *other;
int r;
- _cleanup_free_ char *s = NULL;
assert(u);
assert(name || path);
- if (!(name = resolve_template(u, name, path, &s)))
+ name = resolve_template(u, name, path, &s);
+ if (!name)
return -ENOMEM;
- if ((r = manager_load_unit(u->manager, name, path, NULL, &other)) < 0)
+ r = manager_load_unit(u->manager, name, path, NULL, &other);
+ if (r < 0)
return r;
- r = unit_add_two_dependencies(u, d, e, other, add_reference);
-
- return r;
+ return unit_add_two_dependencies(u, d, e, other, add_reference);
}
int unit_add_dependency_by_name_inverse(Unit *u, UnitDependency d, const char *name, const char *path, bool add_reference) {
assert(u);
assert(name || path);
- if (!(name = resolve_template(u, name, path, &s)))
+ name = resolve_template(u, name, path, &s);
+ if (!name)
return -ENOMEM;
- if ((r = manager_load_unit(u->manager, name, path, NULL, &other)) < 0)
+ r = manager_load_unit(u->manager, name, path, NULL, &other);
+ if (r < 0)
return r;
- r = unit_add_dependency(other, d, u, add_reference);
-
- return r;
+ return unit_add_dependency(other, d, u, add_reference);
}
int unit_add_two_dependencies_by_name_inverse(Unit *u, UnitDependency d, UnitDependency e, const char *name, const char *path, bool add_reference) {
assert(u);
assert(name || path);
- if (!(name = resolve_template(u, name, path, &s)))
+ name = resolve_template(u, name, path, &s);
+ if (!name)
return -ENOMEM;
- if ((r = manager_load_unit(u->manager, name, path, NULL, &other)) < 0)
+ r = manager_load_unit(u->manager, name, path, NULL, &other);
+ if (r < 0)
return r;
- if ((r = unit_add_two_dependencies(other, d, e, u, add_reference)) < 0)
+ r = unit_add_two_dependencies(other, d, e, u, add_reference);
+ if (r < 0)
return r;
return r;