summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-05-07 18:40:57 +0200
committerLennart Poettering <lennart@poettering.net>2016-05-07 18:40:57 +0200
commite76f4732f186236429773ed89d3b71bbb0b64b2a (patch)
tree08bbbc5ca7dac5253e587c0383243eb179cffb97 /src
parent5ab42bc85a11a5250dcdf8e86291d3da90aa84bd (diff)
parent8951eaec50c3c7deecb2259f26ad6ac39573f229 (diff)
Merge pull request #3215 from keszybz/news-and-other-small-cleanups
News and other small cleanups
Diffstat (limited to 'src')
-rw-r--r--src/systemctl/systemctl.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 7d0d4966d5..639080bc66 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -1355,7 +1355,7 @@ static void output_unit_file_list(const UnitFileList *units, unsigned c) {
} else
id_cols = max_id_len;
- if (!arg_no_legend)
+ if (!arg_no_legend && c > 0)
printf("%-*s %-*s\n",
id_cols, "UNIT FILE",
state_cols, "STATE");
@@ -1422,8 +1422,8 @@ static int list_unit_files(int argc, char *argv[], void *userdata) {
n_units = hashmap_size(h);
- units = new(UnitFileList, n_units);
- if (!units && n_units > 0) {
+ units = new(UnitFileList, n_units ?: 1); /* avoid malloc(0) */
+ if (!units) {
unit_file_list_free(h);
return log_oom();
}
@@ -1519,10 +1519,9 @@ static int list_unit_files(int argc, char *argv[], void *userdata) {
qsort_safe(units, c, sizeof(UnitFileList), compare_unit_file_list);
output_unit_file_list(units, c);
- if (install_client_side()) {
+ if (install_client_side())
for (unit = units; unit < units + c; unit++)
free(unit->path);
- }
return 0;
}