systemctl: a number of cleanups regarding error handling in systemctl
This commit is contained in:
+13
-14
@@ -535,10 +535,8 @@ static int get_unit_list(
|
||||
return bus_log_create_error(r);
|
||||
|
||||
r = sd_bus_call(bus, m, 0, &error, &reply);
|
||||
if (r < 0) {
|
||||
log_error("Failed to list units: %s", bus_error_message(&error, r));
|
||||
return r;
|
||||
}
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to list units: %s", bus_error_message(&error, r));
|
||||
|
||||
r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "(ssssssouso)");
|
||||
if (r < 0)
|
||||
@@ -605,7 +603,7 @@ static int get_unit_list_recursive(
|
||||
r = set_put(replies, reply);
|
||||
if (r < 0) {
|
||||
sd_bus_message_unref(reply);
|
||||
return r;
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
if (arg_recursive) {
|
||||
@@ -614,7 +612,7 @@ static int get_unit_list_recursive(
|
||||
|
||||
r = sd_get_machine_names(&machines);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return log_error_errno(r, "Failed to get machine names: %m");
|
||||
|
||||
STRV_FOREACH(i, machines) {
|
||||
_cleanup_bus_flush_close_unref_ sd_bus *container = NULL;
|
||||
@@ -622,7 +620,7 @@ static int get_unit_list_recursive(
|
||||
|
||||
r = sd_bus_open_system_machine(&container, *i);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to connect to container %s: %m", *i);
|
||||
log_warning_errno(r, "Failed to connect to container %s, ignoring: %m", *i);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -635,7 +633,7 @@ static int get_unit_list_recursive(
|
||||
r = set_put(replies, reply);
|
||||
if (r < 0) {
|
||||
sd_bus_message_unref(reply);
|
||||
return r;
|
||||
return log_oom();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1743,7 +1741,7 @@ static int get_machine_list(
|
||||
_cleanup_free_ char *hn = NULL;
|
||||
size_t sz = 0;
|
||||
char **i;
|
||||
int c = 0;
|
||||
int c = 0, r;
|
||||
|
||||
hn = gethostname_malloc();
|
||||
if (!hn)
|
||||
@@ -1761,7 +1759,10 @@ static int get_machine_list(
|
||||
c++;
|
||||
}
|
||||
|
||||
sd_get_machine_names(&m);
|
||||
r = sd_get_machine_names(&m);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to get machine list: %m");
|
||||
|
||||
STRV_FOREACH(i, m) {
|
||||
_cleanup_free_ char *class = NULL;
|
||||
|
||||
@@ -4267,10 +4268,8 @@ static int show_one(
|
||||
&error,
|
||||
&reply,
|
||||
"s", "");
|
||||
if (r < 0) {
|
||||
log_error("Failed to get properties: %s", bus_error_message(&error, r));
|
||||
return r;
|
||||
}
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to get properties: %s", bus_error_message(&error, r));
|
||||
|
||||
r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "{sv}");
|
||||
if (r < 0)
|
||||
|
||||
Reference in New Issue
Block a user