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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2012-09-18 20:37:15 +02:00
parent d3b52baff9
commit 46eddbb597
1 changed files with 13 additions and 18 deletions

View File

@ -1452,10 +1452,14 @@ static void check_triggering_units(
int r; int r;
n = unit_name_mangle(unit_name); 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) { if (!unit_path) {
log_error("Could not allocate dbus path."); log_oom();
return; return;
} }
@ -1515,7 +1519,7 @@ static int start_unit_one(
DBusError *error, DBusError *error,
Set *s) { Set *s) {
DBusMessage *reply = NULL; DBusMessage _cleanup_dbus_msg_unref_ *reply = NULL;
const char *path; const char *path;
int r; int r;
_cleanup_free_ char *n, *p = NULL; _cleanup_free_ char *n, *p = NULL;
@ -1548,15 +1552,14 @@ static int start_unit_one(
else else
log_error("Failed to issue method call: %s", bus_error_message(error)); log_error("Failed to issue method call: %s", bus_error_message(error));
goto finish; return r;
} }
if (!dbus_message_get_args(reply, error, if (!dbus_message_get_args(reply, error,
DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_OBJECT_PATH, &path,
DBUS_TYPE_INVALID)) { DBUS_TYPE_INVALID)) {
log_error("Failed to parse reply: %s", bus_error_message(error)); log_error("Failed to parse reply: %s", bus_error_message(error));
r = -EIO; return -EIO;
goto finish;
} }
if (need_daemon_reload(bus, n)) if (need_daemon_reload(bus, n))
@ -1565,15 +1568,13 @@ static int start_unit_one(
if (s) { if (s) {
p = strdup(path); p = strdup(path);
if (!p) { if (!p)
r = log_oom(); return log_oom();
goto finish;
}
r = set_put(s, p); r = set_put(s, p);
if (r < 0) { if (r < 0) {
log_error("Failed to add path to set."); log_error("Failed to add path to set.");
goto finish; return r;
} }
p = NULL; p = NULL;
@ -1584,13 +1585,7 @@ static int start_unit_one(
if (!arg_quiet && streq(method, "StopUnit")) if (!arg_quiet && streq(method, "StopUnit"))
check_triggering_units(bus, name); check_triggering_units(bus, name);
r = 0; return 0;
finish:
if (reply)
dbus_message_unref(reply);
return r;
} }
static enum action verb_to_action(const char *verb) { static enum action verb_to_action(const char *verb) {