diff options
author | Lukas Nykryn <lnykryn@redhat.com> | 2014-08-19 20:53:29 +0200 |
---|---|---|
committer | Lukas Nykryn <lnykryn@redhat.com> | 2014-08-20 10:45:18 +0200 |
commit | fdbdf6ec29bda40763d7d3e7bb2a63e2f5d60c4c (patch) | |
tree | 545c0ead1e513664b15c4b897aa7db6959da4f06 /src/systemctl/systemctl.c | |
parent | 5d0ae62c665262c4c55536457e84e278c252cc0b (diff) |
systemctl: fail in the case that no unit files were found
Previously systemctl died with message
-bash-4.2# systemctl --root /rawhi list-unit-files
(src/systemctl/systemctl.c:868) Out of memory.
in the case that no unit files were found in the --root
or the directory did not exist.
So lets return ENOENT in the case that --root does not exist
and empty list in the case that there are no unit files.
Diffstat (limited to 'src/systemctl/systemctl.c')
-rw-r--r-- | src/systemctl/systemctl.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 36db652316..072f615ad5 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -1350,6 +1350,10 @@ 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) { unit_file_list_free(h); |