daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
4bff0a
From 9bf05059882a8bc80d33877a315e2bd66fe9e1b5 Mon Sep 17 00:00:00 2001
4bff0a
From: Yu Watanabe <watanabe.yu+github@gmail.com>
4bff0a
Date: Tue, 7 Aug 2018 10:14:30 +0900
4bff0a
Subject: [PATCH] tree-wide: shorten error logging a bit
4bff0a
4bff0a
Continuation of 4027f96aa08c73f109aa46b89842ca0e25c9c0e9.
4bff0a
4bff0a
(cherry picked from commit 4ae25393f37b96b2b753562a349d68947ab1ad3d)
4bff0a
4bff0a
Resolves: #1697893
4bff0a
---
4bff0a
 src/analyze/analyze.c                   | 30 ++++------
4bff0a
 src/core/dbus-manager.c                 |  4 +-
4bff0a
 src/core/transaction.c                  | 18 ++----
4bff0a
 src/hostname/hostnamectl.c              |  5 +-
4bff0a
 src/libsystemd/sd-bus/test-bus-server.c |  6 +-
4bff0a
 src/locale/localectl.c                  | 14 ++---
4bff0a
 src/locale/localed.c                    |  5 +-
4bff0a
 src/login/loginctl.c                    | 75 +++++++++---------------
4bff0a
 src/login/logind-action.c               |  6 +-
4bff0a
 src/login/logind-core.c                 |  4 +-
4bff0a
 src/machine/machinectl.c                | 78 +++++++++----------------
4bff0a
 src/nspawn/nspawn-register.c            | 16 ++---
4bff0a
 src/resolve/resolvectl.c                |  6 +-
4bff0a
 src/run/run.c                           | 18 ++----
4bff0a
 src/sulogin-shell/sulogin-shell.c       |  4 +-
4bff0a
 src/timedate/timedatectl.c              | 16 ++---
4bff0a
 16 files changed, 112 insertions(+), 193 deletions(-)
4bff0a
4bff0a
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
4bff0a
index de0fe6eba8..dc7d2ab0f6 100644
4bff0a
--- a/src/analyze/analyze.c
4bff0a
+++ b/src/analyze/analyze.c
4bff0a
@@ -156,10 +156,8 @@ static int bus_get_uint64_property(sd_bus *bus, const char *path, const char *in
4bff0a
                         &error,
4bff0a
                         't', val);
4bff0a
 
4bff0a
-        if (r < 0) {
4bff0a
-                log_error("Failed to parse reply: %s", bus_error_message(&error, -r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                return log_error_errno(r, "Failed to parse reply: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
         return 0;
4bff0a
 }
4bff0a
@@ -181,10 +179,8 @@ static int bus_get_unit_property_strv(sd_bus *bus, const char *path, const char
4bff0a
                         property,
4bff0a
                         &error,
4bff0a
                         strv);
4bff0a
-        if (r < 0) {
4bff0a
-                log_error("Failed to get unit property %s: %s", property, bus_error_message(&error, -r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                return log_error_errno(r, "Failed to get unit property %s: %s", property, bus_error_message(&error, -r));
4bff0a
 
4bff0a
         return 0;
4bff0a
 }
4bff0a
@@ -368,10 +364,8 @@ static int acquire_time_data(sd_bus *bus, struct unit_times **out) {
4bff0a
                         "ListUnits",
4bff0a
                         &error, &reply,
4bff0a
                         NULL);
4bff0a
-        if (r < 0) {
4bff0a
-                log_error("Failed to list units: %s", bus_error_message(&error, -r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                return log_error_errno(r, "Failed to list units: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
         r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "(ssssssouso)");
4bff0a
         if (r < 0)
4bff0a
@@ -967,10 +961,8 @@ static int list_dependencies(sd_bus *bus, const char *name) {
4bff0a
                         &error,
4bff0a
                         &reply,
4bff0a
                         "s");
4bff0a
-        if (r < 0) {
4bff0a
-                log_error("Failed to get ID: %s", bus_error_message(&error, -r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                return log_error_errno(r, "Failed to get ID: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
         r = sd_bus_message_read(reply, "s", &id;;
4bff0a
         if (r < 0)
4bff0a
@@ -1229,10 +1221,8 @@ static int dot(int argc, char *argv[], void *userdata) {
4bff0a
                        &error,
4bff0a
                        &reply,
4bff0a
                        "");
4bff0a
-        if (r < 0) {
4bff0a
-                log_error("Failed to list units: %s", bus_error_message(&error, -r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                log_error_errno(r, "Failed to list units: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
         r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "(ssssssouso)");
4bff0a
         if (r < 0)
4bff0a
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
4bff0a
index d39c9b28c4..b3c011b0df 100644
4bff0a
--- a/src/core/dbus-manager.c
4bff0a
+++ b/src/core/dbus-manager.c
4bff0a
@@ -1298,9 +1298,9 @@ int verify_run_space_and_log(const char *message) {
4bff0a
 
4bff0a
         r = verify_run_space(message, &error);
4bff0a
         if (r < 0)
4bff0a
-                log_error_errno(r, "%s", bus_error_message(&error, r));
4bff0a
+                return log_error_errno(r, "%s", bus_error_message(&error, r));
4bff0a
 
4bff0a
-        return r;
4bff0a
+        return 0;
4bff0a
 }
4bff0a
 
4bff0a
 static int method_reload(sd_bus_message *message, void *userdata, sd_bus_error *error) {
4bff0a
diff --git a/src/core/transaction.c b/src/core/transaction.c
4bff0a
index 1c7efb207a..045930838b 100644
4bff0a
--- a/src/core/transaction.c
4bff0a
+++ b/src/core/transaction.c
4bff0a
@@ -695,10 +695,8 @@ int transaction_activate(Transaction *tr, Manager *m, JobMode mode, sd_bus_error
4bff0a
                 if (r >= 0)
4bff0a
                         break;
4bff0a
 
4bff0a
-                if (r != -EAGAIN) {
4bff0a
-                        log_warning("Requested transaction contains an unfixable cyclic ordering dependency: %s", bus_error_message(e, r));
4bff0a
-                        return r;
4bff0a
-                }
4bff0a
+                if (r != -EAGAIN)
4bff0a
+                        return log_warning_errno(r, "Requested transaction contains an unfixable cyclic ordering dependency: %s", bus_error_message(e, r));
4bff0a
 
4bff0a
                 /* Let's see if the resulting transaction ordering
4bff0a
                  * graph is still cyclic... */
4bff0a
@@ -712,10 +710,8 @@ int transaction_activate(Transaction *tr, Manager *m, JobMode mode, sd_bus_error
4bff0a
                 if (r >= 0)
4bff0a
                         break;
4bff0a
 
4bff0a
-                if (r != -EAGAIN) {
4bff0a
-                        log_warning("Requested transaction contains unmergeable jobs: %s", bus_error_message(e, r));
4bff0a
-                        return r;
4bff0a
-                }
4bff0a
+                if (r != -EAGAIN)
4bff0a
+                        return log_warning_errno(r, "Requested transaction contains unmergeable jobs: %s", bus_error_message(e, r));
4bff0a
 
4bff0a
                 /* Seventh step: an entry got dropped, let's garbage
4bff0a
                  * collect its dependencies. */
4bff0a
@@ -731,10 +727,8 @@ int transaction_activate(Transaction *tr, Manager *m, JobMode mode, sd_bus_error
4bff0a
 
4bff0a
         /* Ninth step: check whether we can actually apply this */
4bff0a
         r = transaction_is_destructive(tr, mode, e);
4bff0a
-        if (r < 0) {
4bff0a
-                log_notice("Requested transaction contradicts existing jobs: %s", bus_error_message(e, r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                return log_notice_errno(r, "Requested transaction contradicts existing jobs: %s", bus_error_message(e, r));
4bff0a
 
4bff0a
         /* Tenth step: apply changes */
4bff0a
         r = transaction_apply(tr, m, mode);
4bff0a
diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c
4bff0a
index 8587f5c59f..fa4292c1fc 100644
4bff0a
--- a/src/hostname/hostnamectl.c
4bff0a
+++ b/src/hostname/hostnamectl.c
4bff0a
@@ -227,8 +227,9 @@ static int set_simple_string(sd_bus *bus, const char *method, const char *value)
4bff0a
                         &error, NULL,
4bff0a
                         "sb", value, arg_ask_password);
4bff0a
         if (r < 0)
4bff0a
-                log_error("Could not set property: %s", bus_error_message(&error, -r));
4bff0a
-        return r;
4bff0a
+                return log_error_errno(r, "Could not set property: %s", bus_error_message(&error, -r));
4bff0a
+
4bff0a
+        return 0;
4bff0a
 }
4bff0a
 
4bff0a
 static int set_hostname(int argc, char **argv, void *userdata) {
4bff0a
diff --git a/src/libsystemd/sd-bus/test-bus-server.c b/src/libsystemd/sd-bus/test-bus-server.c
4bff0a
index 31b54e252c..f33acda338 100644
4bff0a
--- a/src/libsystemd/sd-bus/test-bus-server.c
4bff0a
+++ b/src/libsystemd/sd-bus/test-bus-server.c
4bff0a
@@ -130,10 +130,8 @@ static int client(struct context *c) {
4bff0a
                 return log_error_errno(r, "Failed to allocate method call: %m");
4bff0a
 
4bff0a
         r = sd_bus_call(bus, m, 0, &error, &reply);
4bff0a
-        if (r < 0) {
4bff0a
-                log_error("Failed to issue method call: %s", bus_error_message(&error, -r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
         return 0;
4bff0a
 }
4bff0a
diff --git a/src/locale/localectl.c b/src/locale/localectl.c
4bff0a
index b3ad2820d9..ebc6a8ca8a 100644
4bff0a
--- a/src/locale/localectl.c
4bff0a
+++ b/src/locale/localectl.c
4bff0a
@@ -184,10 +184,8 @@ static int set_locale(int argc, char **argv, void *userdata) {
4bff0a
                 return bus_log_create_error(r);
4bff0a
 
4bff0a
         r = sd_bus_call(bus, m, 0, &error, NULL);
4bff0a
-        if (r < 0) {
4bff0a
-                log_error("Failed to issue method call: %s", bus_error_message(&error, -r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
         return 0;
4bff0a
 }
4bff0a
@@ -229,9 +227,9 @@ static int set_vconsole_keymap(int argc, char **argv, void *userdata) {
4bff0a
                         NULL,
4bff0a
                         "ssbb", map, toggle_map, arg_convert, arg_ask_password);
4bff0a
         if (r < 0)
4bff0a
-                log_error("Failed to set keymap: %s", bus_error_message(&error, -r));
4bff0a
+                return log_error_errno(r, "Failed to set keymap: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
-        return r;
4bff0a
+        return 0;
4bff0a
 }
4bff0a
 
4bff0a
 static int list_vconsole_keymaps(int argc, char **argv, void *userdata) {
4bff0a
@@ -273,9 +271,9 @@ static int set_x11_keymap(int argc, char **argv, void *userdata) {
4bff0a
                         "ssssbb", layout, model, variant, options,
4bff0a
                                   arg_convert, arg_ask_password);
4bff0a
         if (r < 0)
4bff0a
-                log_error("Failed to set keymap: %s", bus_error_message(&error, -r));
4bff0a
+                return log_error_errno(r, "Failed to set keymap: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
-        return r;
4bff0a
+        return 0;
4bff0a
 }
4bff0a
 
4bff0a
 static int list_x11_keymaps(int argc, char **argv, void *userdata) {
4bff0a
diff --git a/src/locale/localed.c b/src/locale/localed.c
4bff0a
index b8f95b69a6..253973fd49 100644
4bff0a
--- a/src/locale/localed.c
4bff0a
+++ b/src/locale/localed.c
4bff0a
@@ -103,8 +103,9 @@ static int vconsole_reload(sd_bus *bus) {
4bff0a
                         "ss", "systemd-vconsole-setup.service", "replace");
4bff0a
 
4bff0a
         if (r < 0)
4bff0a
-                log_error("Failed to issue method call: %s", bus_error_message(&error, -r));
4bff0a
-        return r;
4bff0a
+                return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, -r));
4bff0a
+
4bff0a
+        return 0;
4bff0a
 }
4bff0a
 
4bff0a
 static int vconsole_convert_to_x11_and_emit(Context *c, sd_bus_message *m) {
4bff0a
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
4bff0a
index be55fdbfd8..9b3fed928b 100644
4bff0a
--- a/src/login/loginctl.c
4bff0a
+++ b/src/login/loginctl.c
4bff0a
@@ -856,10 +856,9 @@ static int show_session(int argc, char *argv[], void *userdata) {
4bff0a
                 session = getenv("XDG_SESSION_ID");
4bff0a
                 if (session) {
4bff0a
                         r = get_session_path(bus, session, &error, &path);
4bff0a
-                        if (r < 0) {
4bff0a
-                                log_error("Failed to get session path: %s", bus_error_message(&error, r));
4bff0a
-                                return r;
4bff0a
-                        }
4bff0a
+                        if (r < 0)
4bff0a
+                                return log_error_errno(r, "Failed to get session path: %s", bus_error_message(&error, r));
4bff0a
+
4bff0a
                         p = path;
4bff0a
                 }
4bff0a
 
4bff0a
@@ -868,10 +867,8 @@ static int show_session(int argc, char *argv[], void *userdata) {
4bff0a
 
4bff0a
         for (i = 1; i < argc; i++) {
4bff0a
                 r = get_session_path(bus, argv[i], &error, &path);
4bff0a
-                if (r < 0) {
4bff0a
-                        log_error("Failed to get session path: %s", bus_error_message(&error, r));
4bff0a
-                        return r;
4bff0a
-                }
4bff0a
+                if (r < 0)
4bff0a
+                        return log_error_errno(r, "Failed to get session path: %s", bus_error_message(&error, r));
4bff0a
 
4bff0a
                 if (properties)
4bff0a
                         r = show_properties(bus, path, &new_line);
4bff0a
@@ -924,10 +921,8 @@ static int show_user(int argc, char *argv[], void *userdata) {
4bff0a
                                 "GetUser",
4bff0a
                                 &error, &reply,
4bff0a
                                 "u", (uint32_t) uid);
4bff0a
-                if (r < 0) {
4bff0a
-                        log_error("Failed to get user: %s", bus_error_message(&error, r));
4bff0a
-                        return r;
4bff0a
-                }
4bff0a
+                if (r < 0)
4bff0a
+                        return log_error_errno(r, "Failed to get user: %s", bus_error_message(&error, r));
4bff0a
 
4bff0a
                 r = sd_bus_message_read(reply, "o", &path);
4bff0a
                 if (r < 0)
4bff0a
@@ -979,10 +974,8 @@ static int show_seat(int argc, char *argv[], void *userdata) {
4bff0a
                                 "GetSeat",
4bff0a
                                 &error, &reply,
4bff0a
                                 "s", argv[i]);
4bff0a
-                if (r < 0) {
4bff0a
-                        log_error("Failed to get seat: %s", bus_error_message(&error, r));
4bff0a
-                        return r;
4bff0a
-                }
4bff0a
+                if (r < 0)
4bff0a
+                        return log_error_errno(r, "Failed to get seat: %s", bus_error_message(&error, r));
4bff0a
 
4bff0a
                 r = sd_bus_message_read(reply, "o", &path);
4bff0a
                 if (r < 0)
4bff0a
@@ -1036,10 +1029,8 @@ static int activate(int argc, char *argv[], void *userdata) {
4bff0a
                                                                       "ActivateSession",
4bff0a
                                 &error, NULL,
4bff0a
                                 "s", argv[i]);
4bff0a
-                if (r < 0) {
4bff0a
-                        log_error("Failed to issue method call: %s", bus_error_message(&error, -r));
4bff0a
-                        return r;
4bff0a
-                }
4bff0a
+                if (r < 0)
4bff0a
+                        return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, -r));
4bff0a
         }
4bff0a
 
4bff0a
         return 0;
4bff0a
@@ -1068,10 +1059,8 @@ static int kill_session(int argc, char *argv[], void *userdata) {
4bff0a
                         "KillSession",
4bff0a
                         &error, NULL,
4bff0a
                         "ssi", argv[i], arg_kill_who, arg_signal);
4bff0a
-                if (r < 0) {
4bff0a
-                        log_error("Could not kill session: %s", bus_error_message(&error, -r));
4bff0a
-                        return r;
4bff0a
-                }
4bff0a
+                if (r < 0)
4bff0a
+                        return log_error_errno(r, "Could not kill session: %s", bus_error_message(&error, -r));
4bff0a
         }
4bff0a
 
4bff0a
         return 0;
4bff0a
@@ -1121,10 +1110,8 @@ static int enable_linger(int argc, char *argv[], void *userdata) {
4bff0a
                         "SetUserLinger",
4bff0a
                         &error, NULL,
4bff0a
                         "ubb", (uint32_t) uid, b, true);
4bff0a
-                if (r < 0) {
4bff0a
-                        log_error("Could not enable linger: %s", bus_error_message(&error, -r));
4bff0a
-                        return r;
4bff0a
-                }
4bff0a
+                if (r < 0)
4bff0a
+                        return log_error_errno(r, "Could not enable linger: %s", bus_error_message(&error, -r));
4bff0a
         }
4bff0a
 
4bff0a
         return 0;
4bff0a
@@ -1155,10 +1142,8 @@ static int terminate_user(int argc, char *argv[], void *userdata) {
4bff0a
                         "TerminateUser",
4bff0a
                         &error, NULL,
4bff0a
                         "u", (uint32_t) uid);
4bff0a
-                if (r < 0) {
4bff0a
-                        log_error("Could not terminate user: %s", bus_error_message(&error, -r));
4bff0a
-                        return r;
4bff0a
-                }
4bff0a
+                if (r < 0)
4bff0a
+                        return log_error_errno(r, "Could not terminate user: %s", bus_error_message(&error, -r));
4bff0a
         }
4bff0a
 
4bff0a
         return 0;
4bff0a
@@ -1192,10 +1177,8 @@ static int kill_user(int argc, char *argv[], void *userdata) {
4bff0a
                         "KillUser",
4bff0a
                         &error, NULL,
4bff0a
                         "ui", (uint32_t) uid, arg_signal);
4bff0a
-                if (r < 0) {
4bff0a
-                        log_error("Could not kill user: %s", bus_error_message(&error, -r));
4bff0a
-                        return r;
4bff0a
-                }
4bff0a
+                if (r < 0)
4bff0a
+                        return log_error_errno(r, "Could not kill user: %s", bus_error_message(&error, -r));
4bff0a
         }
4bff0a
 
4bff0a
         return 0;
4bff0a
@@ -1222,10 +1205,8 @@ static int attach(int argc, char *argv[], void *userdata) {
4bff0a
                         &error, NULL,
4bff0a
                         "ssb", argv[1], argv[i], true);
4bff0a
 
4bff0a
-                if (r < 0) {
4bff0a
-                        log_error("Could not attach device: %s", bus_error_message(&error, -r));
4bff0a
-                        return r;
4bff0a
-                }
4bff0a
+                if (r < 0)
4bff0a
+                        return log_error_errno(r, "Could not attach device: %s", bus_error_message(&error, -r));
4bff0a
         }
4bff0a
 
4bff0a
         return 0;
4bff0a
@@ -1250,9 +1231,9 @@ static int flush_devices(int argc, char *argv[], void *userdata) {
4bff0a
                         &error, NULL,
4bff0a
                         "b", true);
4bff0a
         if (r < 0)
4bff0a
-                log_error("Could not flush devices: %s", bus_error_message(&error, -r));
4bff0a
+                return log_error_errno(r, "Could not flush devices: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
-        return r;
4bff0a
+        return 0;
4bff0a
 }
4bff0a
 
4bff0a
 static int lock_sessions(int argc, char *argv[], void *userdata) {
4bff0a
@@ -1274,9 +1255,9 @@ static int lock_sessions(int argc, char *argv[], void *userdata) {
4bff0a
                         &error, NULL,
4bff0a
                         NULL);
4bff0a
         if (r < 0)
4bff0a
-                log_error("Could not lock sessions: %s", bus_error_message(&error, -r));
4bff0a
+                return log_error_errno(r, "Could not lock sessions: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
-        return r;
4bff0a
+        return 0;
4bff0a
 }
4bff0a
 
4bff0a
 static int terminate_seat(int argc, char *argv[], void *userdata) {
4bff0a
@@ -1299,10 +1280,8 @@ static int terminate_seat(int argc, char *argv[], void *userdata) {
4bff0a
                         "TerminateSeat",
4bff0a
                         &error, NULL,
4bff0a
                         "s", argv[i]);
4bff0a
-                if (r < 0) {
4bff0a
-                        log_error("Could not terminate seat: %s", bus_error_message(&error, -r));
4bff0a
-                        return r;
4bff0a
-                }
4bff0a
+                if (r < 0)
4bff0a
+                        return log_error_errno(r, "Could not terminate seat: %s", bus_error_message(&error, -r));
4bff0a
         }
4bff0a
 
4bff0a
         return 0;
4bff0a
diff --git a/src/login/logind-action.c b/src/login/logind-action.c
4bff0a
index 08e41af81a..317e9ef384 100644
4bff0a
--- a/src/login/logind-action.c
4bff0a
+++ b/src/login/logind-action.c
4bff0a
@@ -152,10 +152,8 @@ int manager_handle_action(
4bff0a
         log_info("%s", message_table[handle]);
4bff0a
 
4bff0a
         r = bus_manager_shutdown_or_sleep_now_or_later(m, target, inhibit_operation, &error);
4bff0a
-        if (r < 0) {
4bff0a
-                log_error("Failed to execute operation: %s", bus_error_message(&error, r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                return log_error_errno(r, "Failed to execute operation: %s", bus_error_message(&error, r));
4bff0a
 
4bff0a
         return 1;
4bff0a
 }
4bff0a
diff --git a/src/login/logind-core.c b/src/login/logind-core.c
4bff0a
index 511e3acf8f..cff5536ac0 100644
4bff0a
--- a/src/login/logind-core.c
4bff0a
+++ b/src/login/logind-core.c
4bff0a
@@ -522,9 +522,9 @@ int manager_spawn_autovt(Manager *m, unsigned int vtnr) {
4bff0a
                         NULL,
4bff0a
                         "ss", name, "fail");
4bff0a
         if (r < 0)
4bff0a
-                log_error("Failed to start %s: %s", name, bus_error_message(&error, r));
4bff0a
+                return log_error_errno(r, "Failed to start %s: %s", name, bus_error_message(&error, r));
4bff0a
 
4bff0a
-        return r;
4bff0a
+        return 0;
4bff0a
 }
4bff0a
 
4bff0a
 static bool manager_is_docked(Manager *m) {
4bff0a
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
4bff0a
index d656681daf..e177841c88 100644
4bff0a
--- a/src/machine/machinectl.c
4bff0a
+++ b/src/machine/machinectl.c
4bff0a
@@ -773,10 +773,8 @@ static int show_machine(int argc, char *argv[], void *userdata) {
4bff0a
                                        &error,
4bff0a
                                        &reply,
4bff0a
                                        "s", argv[i]);
4bff0a
-                if (r < 0) {
4bff0a
-                        log_error("Could not get path to machine: %s", bus_error_message(&error, -r));
4bff0a
-                        return r;
4bff0a
-                }
4bff0a
+                if (r < 0)
4bff0a
+                        return log_error_errno(r, "Could not get path to machine: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
                 r = sd_bus_message_read(reply, "o", &path);
4bff0a
                 if (r < 0)
4bff0a
@@ -1118,10 +1116,8 @@ static int show_image(int argc, char *argv[], void *userdata) {
4bff0a
                                 &error,
4bff0a
                                 &reply,
4bff0a
                                 "s", argv[i]);
4bff0a
-                if (r < 0) {
4bff0a
-                        log_error("Could not get path to image: %s", bus_error_message(&error, -r));
4bff0a
-                        return r;
4bff0a
-                }
4bff0a
+                if (r < 0)
4bff0a
+                        return log_error_errno(r, "Could not get path to image: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
                 r = sd_bus_message_read(reply, "o", &path);
4bff0a
                 if (r < 0)
4bff0a
@@ -1158,10 +1154,8 @@ static int kill_machine(int argc, char *argv[], void *userdata) {
4bff0a
                                 &error,
4bff0a
                                 NULL,
4bff0a
                                 "ssi", argv[i], arg_kill_who, arg_signal);
4bff0a
-                if (r < 0) {
4bff0a
-                        log_error("Could not kill machine: %s", bus_error_message(&error, -r));
4bff0a
-                        return r;
4bff0a
-                }
4bff0a
+                if (r < 0)
4bff0a
+                        return log_error_errno(r, "Could not kill machine: %s", bus_error_message(&error, -r));
4bff0a
         }
4bff0a
 
4bff0a
         return 0;
4bff0a
@@ -1200,10 +1194,8 @@ static int terminate_machine(int argc, char *argv[], void *userdata) {
4bff0a
                                 &error,
4bff0a
                                 NULL,
4bff0a
                                 "s", argv[i]);
4bff0a
-                if (r < 0) {
4bff0a
-                        log_error("Could not terminate machine: %s", bus_error_message(&error, -r));
4bff0a
-                        return r;
4bff0a
-                }
4bff0a
+                if (r < 0)
4bff0a
+                        return log_error_errno(r, "Could not terminate machine: %s", bus_error_message(&error, -r));
4bff0a
         }
4bff0a
 
4bff0a
         return 0;
4bff0a
@@ -1285,10 +1277,8 @@ static int bind_mount(int argc, char *argv[], void *userdata) {
4bff0a
                         argv[3],
4bff0a
                         arg_read_only,
4bff0a
                         arg_mkdir);
4bff0a
-        if (r < 0) {
4bff0a
-                log_error("Failed to bind mount: %s", bus_error_message(&error, -r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                return log_error_errno(r, "Failed to bind mount: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
         return 0;
4bff0a
 }
4bff0a
@@ -1459,10 +1449,8 @@ static int login_machine(int argc, char *argv[], void *userdata) {
4bff0a
                         &error,
4bff0a
                         &reply,
4bff0a
                         "s", machine);
4bff0a
-        if (r < 0) {
4bff0a
-                log_error("Failed to get login PTY: %s", bus_error_message(&error, -r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                return log_error_errno(r, "Failed to get login PTY: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
         r = sd_bus_message_read(reply, "hs", &master, NULL);
4bff0a
         if (r < 0)
4bff0a
@@ -1615,10 +1603,8 @@ static int rename_image(int argc, char *argv[], void *userdata) {
4bff0a
                         &error,
4bff0a
                         NULL,
4bff0a
                         "ss", argv[1], argv[2]);
4bff0a
-        if (r < 0) {
4bff0a
-                log_error("Could not rename image: %s", bus_error_message(&error, -r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                return log_error_errno(r, "Could not rename image: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
         return 0;
4bff0a
 }
4bff0a
@@ -1681,10 +1667,8 @@ static int read_only_image(int argc, char *argv[], void *userdata) {
4bff0a
                         &error,
4bff0a
                         NULL,
4bff0a
                         "sb", argv[1], b);
4bff0a
-        if (r < 0) {
4bff0a
-                log_error("Could not mark image read-only: %s", bus_error_message(&error, -r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                return log_error_errno(r, "Could not mark image read-only: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
         return 0;
4bff0a
 }
4bff0a
@@ -1773,10 +1757,8 @@ static int start_machine(int argc, char *argv[], void *userdata) {
4bff0a
                                 &error,
4bff0a
                                 &reply,
4bff0a
                                 "ss", unit, "fail");
4bff0a
-                if (r < 0) {
4bff0a
-                        log_error("Failed to start unit: %s", bus_error_message(&error, -r));
4bff0a
-                        return r;
4bff0a
-                }
4bff0a
+                if (r < 0)
4bff0a
+                        return log_error_errno(r, "Failed to start unit: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
                 r = sd_bus_message_read(reply, "o", &object);
4bff0a
                 if (r < 0)
4bff0a
@@ -1855,10 +1837,8 @@ static int enable_machine(int argc, char *argv[], void *userdata) {
4bff0a
                 return bus_log_create_error(r);
4bff0a
 
4bff0a
         r = sd_bus_call(bus, m, 0, &error, &reply);
4bff0a
-        if (r < 0) {
4bff0a
-                log_error("Failed to enable or disable unit: %s", bus_error_message(&error, -r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                return log_error_errno(r, "Failed to enable or disable unit: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
         if (streq(argv[0], "enable")) {
4bff0a
                 r = sd_bus_message_read(reply, "b", NULL);
4bff0a
@@ -1993,10 +1973,8 @@ static int transfer_image_common(sd_bus *bus, sd_bus_message *m) {
4bff0a
                 return log_error_errno(r, "Failed to request match: %m");
4bff0a
 
4bff0a
         r = sd_bus_call(bus, m, 0, &error, &reply);
4bff0a
-        if (r < 0) {
4bff0a
-                log_error("Failed to transfer image: %s", bus_error_message(&error, -r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                return log_error_errno(r, "Failed to transfer image: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
         r = sd_bus_message_read(reply, "uo", &id, NULL);
4bff0a
         if (r < 0)
4bff0a
@@ -2430,10 +2408,8 @@ static int list_transfers(int argc, char *argv[], void *userdata) {
4bff0a
                                &error,
4bff0a
                                &reply,
4bff0a
                                NULL);
4bff0a
-        if (r < 0) {
4bff0a
-                log_error("Could not get transfers: %s", bus_error_message(&error, -r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                return log_error_errno(r, "Could not get transfers: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
         r = sd_bus_message_enter_container(reply, 'a', "(usssdo)");
4bff0a
         if (r < 0)
4bff0a
@@ -2528,10 +2504,8 @@ static int cancel_transfer(int argc, char *argv[], void *userdata) {
4bff0a
                                 &error,
4bff0a
                                 NULL,
4bff0a
                                 "u", id);
4bff0a
-                if (r < 0) {
4bff0a
-                        log_error("Could not cancel transfer: %s", bus_error_message(&error, -r));
4bff0a
-                        return r;
4bff0a
-                }
4bff0a
+                if (r < 0)
4bff0a
+                        return log_error_errno(r, "Could not cancel transfer: %s", bus_error_message(&error, -r));
4bff0a
         }
4bff0a
 
4bff0a
         return 0;
4bff0a
diff --git a/src/nspawn/nspawn-register.c b/src/nspawn/nspawn-register.c
4bff0a
index 93185ecaaa..85f3cf1c01 100644
4bff0a
--- a/src/nspawn/nspawn-register.c
4bff0a
+++ b/src/nspawn/nspawn-register.c
4bff0a
@@ -195,10 +195,8 @@ int register_machine(
4bff0a
                 r = sd_bus_call(bus, m, 0, &error, NULL);
4bff0a
         }
4bff0a
 
4bff0a
-        if (r < 0) {
4bff0a
-                log_error("Failed to register machine: %s", bus_error_message(&error, r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                return log_error_errno(r, "Failed to register machine: %s", bus_error_message(&error, r));
4bff0a
 
4bff0a
         return 0;
4bff0a
 }
4bff0a
@@ -242,10 +240,8 @@ int terminate_machine(sd_bus *bus, pid_t pid) {
4bff0a
                         &error,
4bff0a
                         NULL,
4bff0a
                         NULL);
4bff0a
-        if (r < 0) {
4bff0a
+        if (r < 0)
4bff0a
                 log_debug("Failed to terminate machine: %s", bus_error_message(&error, r));
4bff0a
-                return 0;
4bff0a
-        }
4bff0a
 
4bff0a
         return 0;
4bff0a
 }
4bff0a
@@ -336,10 +332,8 @@ int allocate_scope(
4bff0a
                 return bus_log_create_error(r);
4bff0a
 
4bff0a
         r = sd_bus_call(bus, m, 0, &error, &reply);
4bff0a
-        if (r < 0) {
4bff0a
-                log_error("Failed to allocate scope: %s", bus_error_message(&error, r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                return log_error_errno(r, "Failed to allocate scope: %s", bus_error_message(&error, r));
4bff0a
 
4bff0a
         r = sd_bus_message_read(reply, "o", &object);
4bff0a
         if (r < 0)
4bff0a
diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c
4bff0a
index e96c13fea6..cf1ec323a4 100644
4bff0a
--- a/src/resolve/resolvectl.c
4bff0a
+++ b/src/resolve/resolvectl.c
4bff0a
@@ -274,10 +274,8 @@ static int resolve_address(sd_bus *bus, int family, const union in_addr_union *a
4bff0a
         ts = now(CLOCK_MONOTONIC);
4bff0a
 
4bff0a
         r = sd_bus_call(bus, req, SD_RESOLVED_QUERY_TIMEOUT_USEC, &error, &reply);
4bff0a
-        if (r < 0) {
4bff0a
-                log_error("%s: resolve call failed: %s", pretty, bus_error_message(&error, r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                return log_error_errno(r, "%s: resolve call failed: %s", pretty, bus_error_message(&error, r));
4bff0a
 
4bff0a
         ts = now(CLOCK_MONOTONIC) - ts;
4bff0a
 
4bff0a
diff --git a/src/run/run.c b/src/run/run.c
4bff0a
index 2910fcb272..9ad44e7b57 100644
4bff0a
--- a/src/run/run.c
4bff0a
+++ b/src/run/run.c
4bff0a
@@ -940,10 +940,8 @@ static int start_transient_service(
4bff0a
                                                &error,
4bff0a
                                                &pty_reply,
4bff0a
                                                "s", arg_host);
4bff0a
-                        if (r < 0) {
4bff0a
-                                log_error("Failed to get machine PTY: %s", bus_error_message(&error, -r));
4bff0a
-                                return r;
4bff0a
-                        }
4bff0a
+                        if (r < 0)
4bff0a
+                                return log_error_errno(r, "Failed to get machine PTY: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
                         r = sd_bus_message_read(pty_reply, "hs", &master, &s);
4bff0a
                         if (r < 0)
4bff0a
@@ -1219,10 +1217,8 @@ static int start_transient_scope(
4bff0a
         polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
4bff0a
 
4bff0a
         r = sd_bus_call(bus, m, 0, &error, &reply);
4bff0a
-        if (r < 0) {
4bff0a
-                log_error("Failed to start transient scope unit: %s", bus_error_message(&error, -r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                return log_error_errno(r, "Failed to start transient scope unit: %s", bus_error_message(&error, -r));
4bff0a
 
4bff0a
         if (arg_nice_set) {
4bff0a
                 if (setpriority(PRIO_PROCESS, 0, arg_nice) < 0)
4bff0a
@@ -1437,10 +1433,8 @@ static int start_transient_trigger(
4bff0a
         polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
4bff0a
 
4bff0a
         r = sd_bus_call(bus, m, 0, &error, &reply);
4bff0a
-        if (r < 0) {
4bff0a
-                log_error("Failed to start transient %s unit: %s", suffix + 1, bus_error_message(&error, -r));
4bff0a
-                return r;
4bff0a
-        }
4bff0a
+        if (r < 0)
4bff0a
+                return log_error_errno(r, "Failed to start transient %s unit: %s", suffix + 1, bus_error_message(&error, -r));
4bff0a
 
4bff0a
         r = sd_bus_message_read(reply, "o", &object);
4bff0a
         if (r < 0)
4bff0a
diff --git a/src/sulogin-shell/sulogin-shell.c b/src/sulogin-shell/sulogin-shell.c
4bff0a
index d0e5a89f1f..5db3592d6f 100644
4bff0a
--- a/src/sulogin-shell/sulogin-shell.c
4bff0a
+++ b/src/sulogin-shell/sulogin-shell.c
4bff0a
@@ -59,9 +59,9 @@ static int start_default_target(sd_bus *bus) {
4bff0a
                                "ss", "default.target", "isolate");
4bff0a
 
4bff0a
         if (r < 0)
4bff0a
-                log_error("Failed to start default target: %s", bus_error_message(&error, r));
4bff0a
+                return log_error_errno(r, "Failed to start default target: %s", bus_error_message(&error, r));
4bff0a
 
4bff0a
-        return r;
4bff0a
+        return 0;
4bff0a
 }
4bff0a
 
4bff0a
 static int fork_wait(const char* const cmdline[]) {
4bff0a
diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c
4bff0a
index befc8cb723..a541b01920 100644
4bff0a
--- a/src/timedate/timedatectl.c
4bff0a
+++ b/src/timedate/timedatectl.c
4bff0a
@@ -204,9 +204,9 @@ static int set_time(int argc, char **argv, void *userdata) {
4bff0a
                                NULL,
4bff0a
                                "xbb", (int64_t) t, relative, interactive);
4bff0a
         if (r < 0)
4bff0a
-                log_error("Failed to set time: %s", bus_error_message(&error, r));
4bff0a
+                return log_error_errno(r, "Failed to set time: %s", bus_error_message(&error, r));
4bff0a
 
4bff0a
-        return r;
4bff0a
+        return 0;
4bff0a
 }
4bff0a
 
4bff0a
 static int set_timezone(int argc, char **argv, void *userdata) {
4bff0a
@@ -225,9 +225,9 @@ static int set_timezone(int argc, char **argv, void *userdata) {
4bff0a
                                NULL,
4bff0a
                                "sb", argv[1], arg_ask_password);
4bff0a
         if (r < 0)
4bff0a
-                log_error("Failed to set time zone: %s", bus_error_message(&error, r));
4bff0a
+                return log_error_errno(r, "Failed to set time zone: %s", bus_error_message(&error, r));
4bff0a
 
4bff0a
-        return r;
4bff0a
+        return 0;
4bff0a
 }
4bff0a
 
4bff0a
 static int set_local_rtc(int argc, char **argv, void *userdata) {
4bff0a
@@ -250,9 +250,9 @@ static int set_local_rtc(int argc, char **argv, void *userdata) {
4bff0a
                                NULL,
4bff0a
                                "bbb", b, arg_adjust_system_clock, arg_ask_password);
4bff0a
         if (r < 0)
4bff0a
-                log_error("Failed to set local RTC: %s", bus_error_message(&error, r));
4bff0a
+                return log_error_errno(r, "Failed to set local RTC: %s", bus_error_message(&error, r));
4bff0a
 
4bff0a
-        return r;
4bff0a
+        return 0;
4bff0a
 }
4bff0a
 
4bff0a
 static int set_ntp(int argc, char **argv, void *userdata) {
4bff0a
@@ -275,9 +275,9 @@ static int set_ntp(int argc, char **argv, void *userdata) {
4bff0a
                                NULL,
4bff0a
                                "bb", b, arg_ask_password);
4bff0a
         if (r < 0)
4bff0a
-                log_error("Failed to set ntp: %s", bus_error_message(&error, r));
4bff0a
+                return log_error_errno(r, "Failed to set ntp: %s", bus_error_message(&error, r));
4bff0a
 
4bff0a
-        return r;
4bff0a
+        return 0;
4bff0a
 }
4bff0a
 
4bff0a
 static int list_timezones(int argc, char **argv, void *userdata) {