chiark / gitweb /
systemctl: do not use -1 for return code
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 13 Dec 2014 17:43:07 +0000 (12:43 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 16 Dec 2014 05:30:33 +0000 (00:30 -0500)
Also make the error messages more specific to give a hint to the user
how to solve the problem.

src/systemctl/systemctl.c

index 8a1b481fdc3b9d0a78749a935c4ace8a9d22cfcd..324d9b60c2a871b1dfe19fb069bae7fcdd0d67cc 100644 (file)
@@ -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();