summaryrefslogtreecommitdiff
path: root/src/core/unit.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-10-21 19:54:10 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-11-15 22:53:14 -0500
commite48614c4b268d9e7ecbd478d1d2410f9e92095e0 (patch)
treeda8b1d7fd759db5aa86d3f28f9b7ba065bdc5ce0 /src/core/unit.c
parent94192cdaf652c9717f15274504ed315126c07a93 (diff)
core: some more _cleanup_free_
Diffstat (limited to 'src/core/unit.c')
-rw-r--r--src/core/unit.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index 15e0a82020..84c43f721a 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -127,7 +127,8 @@ int unit_add_name(Unit *u, const char *text) {
goto fail;
}
- if ((r = unit_name_to_instance(s, &i)) < 0)
+ r = unit_name_to_instance(s, &i);
+ if (r < 0)
goto fail;
if (i && unit_vtable[t]->no_instances) {
@@ -154,13 +155,15 @@ int unit_add_name(Unit *u, const char *text) {
goto fail;
}
- if ((r = set_put(u->names, s)) < 0) {
+ r = set_put(u->names, s);
+ if (r < 0) {
if (r == -EEXIST)
r = 0;
goto fail;
}
- if ((r = hashmap_put(u->manager->units, s, u)) < 0) {
+ r = hashmap_put(u->manager->units, s, u);
+ if (r < 0) {
set_remove(u->names, s);
goto fail;
}
@@ -201,7 +204,8 @@ int unit_choose_id(Unit *u, const char *name) {
if (!u->instance)
return -EINVAL;
- if (!(t = unit_name_replace_instance(name, u->instance)))
+ t = unit_name_replace_instance(name, u->instance);
+ if (!t)
return -ENOMEM;
name = t;
@@ -213,7 +217,8 @@ int unit_choose_id(Unit *u, const char *name) {
if (!s)
return -ENOENT;
- if ((r = unit_name_to_instance(s, &i)) < 0)
+ r = unit_name_to_instance(s, &i);
+ if (r < 0)
return r;
u->id = s;
@@ -546,14 +551,13 @@ static void merge_dependencies(Unit *u, Unit *other, UnitDependency d) {
SET_FOREACH(back, other->dependencies[d], i) {
UnitDependency k;
- for (k = 0; k < _UNIT_DEPENDENCY_MAX; k++)
- if ((r = set_remove_and_put(back->dependencies[k], other, u)) < 0) {
-
- if (r == -EEXIST)
- set_remove(back->dependencies[k], other);
- else
- assert(r == -ENOENT);
- }
+ for (k = 0; k < _UNIT_DEPENDENCY_MAX; k++) {
+ r = set_remove_and_put(back->dependencies[k], other, u);
+ if (r == -EEXIST)
+ set_remove(back->dependencies[k], other);
+ else
+ assert(r >= 0 || r == -ENOENT);
+ }
}
complete_move(&u->dependencies[d], &other->dependencies[d]);
@@ -632,7 +636,8 @@ int unit_merge_by_name(Unit *u, const char *name) {
if (!u->instance)
return -EINVAL;
- if (!(s = unit_name_replace_instance(name, u->instance)))
+ s = unit_name_replace_instance(name, u->instance);
+ if (!s)
return -ENOMEM;
name = s;
@@ -843,7 +848,7 @@ int unit_load_fragment_and_dropin(Unit *u) {
assert(u);
- /* Load a .service file */
+ /* Load a .{service,socket,...} file */
r = unit_load_fragment(u);
if (r < 0)
return r;
@@ -1280,7 +1285,8 @@ int unit_reload(Unit *u) {
if (state != UNIT_ACTIVE)
return -ENOEXEC;
- if ((following = unit_following(u))) {
+ following = unit_following(u);
+ if (following) {
log_debug_unit(u->id, "Redirecting reload request from %s to %s.",
u->id, following->id);
return unit_reload(following);