diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-12-13 12:43:07 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-12-16 00:30:33 -0500 |
commit | 5b013a2f67a5914d6e86e3914f40cf44a03da091 (patch) | |
tree | a577a97c956bd066f808a086707366c8adfdc9d0 /src | |
parent | 1a7f1b385cd9de8a0da934fadc379860f914ef33 (diff) |
systemctl: do not use -1 for return code
Also make the error messages more specific to give a hint to the user
how to solve the problem.
Diffstat (limited to 'src')
-rw-r--r-- | src/systemctl/systemctl.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 8a1b481fdc..324d9b60c2 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -6106,19 +6106,15 @@ static int find_paths_to_edit(sd_bus *bus, char **names, char ***paths) { if (arg_scope == UNIT_FILE_USER) { r = user_config_home(&user_home); if (r < 0) - return log_oom(); - else if (r == 0) { - log_error("Cannot edit units for the user instance: home directory unknown"); - return -1; - } + return log_error_errno(r, "Failed to query XDG_CONFIG_HOME: %m"); + else if (r == 0) + return log_error_errno(ENOTDIR, "Cannot edit units: $XDG_CONFIG_HOME and $HOME are not set."); r = user_runtime_dir(&user_runtime); if (r < 0) - return log_oom(); - else if (r == 0) { - log_error("Cannot edit units for the user instance: runtime directory unknown"); - return -1; - } + return log_error_errno(r, "Failed to query XDG_CONFIG_HOME: %m"); + else if (r == 0) + return log_error_errno(ENOTDIR, "Cannot edit units: $XDG_RUNTIME_DIR is not set."); } r = lookup_paths_init(&lp, @@ -6126,10 +6122,8 @@ static int find_paths_to_edit(sd_bus *bus, char **names, char ***paths) { arg_scope == UNIT_FILE_USER, arg_root, NULL, NULL, NULL); - if (r < 0) { - log_error_errno(r, "Failed get lookup paths: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed get lookup paths: %m"); avoid_bus_cache = !bus || avoid_bus(); |