summaryrefslogtreecommitdiff
path: root/src/systemctl/systemctl.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-08-21 19:10:26 +0200
committerLennart Poettering <lennart@poettering.net>2014-08-21 19:10:29 +0200
commit4fe1be9ce2e0cca6354a4167f0a1a7e1f943c91c (patch)
treec3d44a8b5465016b1b7ca057c3094cce00078766 /src/systemctl/systemctl.c
parent59ccf93d97f0a37522e5f4fbf5cc0288dbedf495 (diff)
systemctl: in list-unit-files, always show legend, even if we know about no unit files
Diffstat (limited to 'src/systemctl/systemctl.c')
-rw-r--r--src/systemctl/systemctl.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 072f615ad5..d9b8bee28d 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -1351,11 +1351,8 @@ static int list_unit_files(sd_bus *bus, char **args) {
n_units = hashmap_size(h);
- if (n_units == 0)
- return 0;
-
units = new(UnitFileList, n_units);
- if (!units) {
+ if (!units && n_units > 0) {
unit_file_list_free(h);
return log_oom();
}
@@ -1411,14 +1408,13 @@ static int list_unit_files(sd_bus *bus, char **args) {
return bus_log_parse_error(r);
}
- if (c > 0) {
- qsort(units, c, sizeof(UnitFileList), compare_unit_file_list);
- output_unit_file_list(units, c);
- }
+ qsort_safe(units, c, sizeof(UnitFileList), compare_unit_file_list);
+ output_unit_file_list(units, c);
- if (avoid_bus())
+ if (avoid_bus()) {
for (unit = units; unit < units + c; unit++)
free(unit->path);
+ }
return 0;
}