summaryrefslogtreecommitdiff
path: root/src/systemctl
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2012-09-18 20:37:15 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2012-09-19 08:25:51 +0200
commit46eddbb597a379ef64a3ee76029ce625902e8107 (patch)
tree79b9cf9126d8cda80a07b0991efcca7e9c6240b7 /src/systemctl
parentd3b52baff90876a648e321f3658a74bc58a8647c (diff)
systemctl: use automatic cleanup once more
Semantics are slightly different, because before unit_name_mangle returning NULL was ignored, and now it is reported as oom. But unit_name_mangle only returns NULL on oom.
Diffstat (limited to 'src/systemctl')
-rw-r--r--src/systemctl/systemctl.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 367dd8060a..15c08668c8 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -1452,10 +1452,14 @@ static void check_triggering_units(
int r;
n = unit_name_mangle(unit_name);
- unit_path = unit_dbus_path_from_name(n ? n : unit_name);
+ if (!n) {
+ log_oom();
+ return;
+ }
+ unit_path = unit_dbus_path_from_name(n);
if (!unit_path) {
- log_error("Could not allocate dbus path.");
+ log_oom();
return;
}
@@ -1515,7 +1519,7 @@ static int start_unit_one(
DBusError *error,
Set *s) {
- DBusMessage *reply = NULL;
+ DBusMessage _cleanup_dbus_msg_unref_ *reply = NULL;
const char *path;
int r;
_cleanup_free_ char *n, *p = NULL;
@@ -1548,15 +1552,14 @@ static int start_unit_one(
else
log_error("Failed to issue method call: %s", bus_error_message(error));
- goto finish;
+ return r;
}
if (!dbus_message_get_args(reply, error,
DBUS_TYPE_OBJECT_PATH, &path,
DBUS_TYPE_INVALID)) {
log_error("Failed to parse reply: %s", bus_error_message(error));
- r = -EIO;
- goto finish;
+ return -EIO;
}
if (need_daemon_reload(bus, n))
@@ -1565,15 +1568,13 @@ static int start_unit_one(
if (s) {
p = strdup(path);
- if (!p) {
- r = log_oom();
- goto finish;
- }
+ if (!p)
+ return log_oom();
r = set_put(s, p);
if (r < 0) {
log_error("Failed to add path to set.");
- goto finish;
+ return r;
}
p = NULL;
@@ -1584,13 +1585,7 @@ static int start_unit_one(
if (!arg_quiet && streq(method, "StopUnit"))
check_triggering_units(bus, name);
- r = 0;
-
-finish:
- if (reply)
- dbus_message_unref(reply);
-
- return r;
+ return 0;
}
static enum action verb_to_action(const char *verb) {