summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/analyze/analyze.c24
-rw-r--r--src/cgls/cgls.c2
-rw-r--r--src/hostname/hostnamectl.c2
-rw-r--r--src/locale/localectl.c2
-rw-r--r--src/login/loginctl.c2
-rw-r--r--src/machine/machinectl.c2
-rw-r--r--src/mount/mount-tool.c2
-rw-r--r--src/run/run.c2
-rw-r--r--src/shared/bus-util.h3
-rw-r--r--src/shared/cgroup-show.c2
-rw-r--r--src/timedate/timedatectl.c2
11 files changed, 24 insertions, 21 deletions
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
index e42f7ff935..9d64e3c76c 100644
--- a/src/analyze/analyze.c
+++ b/src/analyze/analyze.c
@@ -627,7 +627,7 @@ static int analyze_plot(int argc, char *argv[], void *userdata) {
r = acquire_bus(&bus, &use_full_bus);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
n = acquire_boot_times(bus, &boot);
if (n < 0)
@@ -1026,7 +1026,7 @@ static int analyze_critical_chain(int argc, char *argv[], void *userdata) {
r = acquire_bus(&bus, NULL);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
n = acquire_time_data(bus, &times);
if (n <= 0)
@@ -1069,7 +1069,7 @@ static int analyze_blame(int argc, char *argv[], void *userdata) {
r = acquire_bus(&bus, NULL);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
n = acquire_time_data(bus, &times);
if (n <= 0)
@@ -1126,7 +1126,7 @@ static int analyze_time(int argc, char *argv[], void *userdata) {
r = acquire_bus(&bus, NULL);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
r = pretty_boot_time(bus, &buf);
if (r < 0)
@@ -1264,7 +1264,7 @@ static int dot(int argc, char *argv[], void *userdata) {
r = acquire_bus(&bus, NULL);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
r = expand_patterns(bus, strv_skip(argv, 1), &expanded_patterns);
if (r < 0)
@@ -1341,7 +1341,7 @@ static int dump(int argc, char *argv[], void *userdata) {
r = acquire_bus(&bus, NULL);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
(void) pager_open(arg_pager_flags);
@@ -1412,7 +1412,7 @@ static int set_log_level(int argc, char *argv[], void *userdata) {
r = acquire_bus(&bus, NULL);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
r = bus_set_property(bus, bus_systemd_mgr, "LogLevel", &error, "s", argv[1]);
if (r < 0)
@@ -1429,7 +1429,7 @@ static int get_log_level(int argc, char *argv[], void *userdata) {
r = acquire_bus(&bus, NULL);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
r = bus_get_property_string(bus, bus_systemd_mgr, "LogLevel", &error, &level);
if (r < 0)
@@ -1453,7 +1453,7 @@ static int set_log_target(int argc, char *argv[], void *userdata) {
r = acquire_bus(&bus, NULL);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
r = bus_set_property(bus, bus_systemd_mgr, "LogTarget", &error, "s", argv[1]);
if (r < 0)
@@ -1470,7 +1470,7 @@ static int get_log_target(int argc, char *argv[], void *userdata) {
r = acquire_bus(&bus, NULL);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
r = bus_get_property_string(bus, bus_systemd_mgr, "LogTarget", &error, &target);
if (r < 0)
@@ -2053,7 +2053,7 @@ static int service_watchdogs(int argc, char *argv[], void *userdata) {
r = acquire_bus(&bus, NULL);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
if (argc == 1) {
/* get ServiceWatchdogs */
@@ -2091,7 +2091,7 @@ static int do_security(int argc, char *argv[], void *userdata) {
r = acquire_bus(&bus, NULL);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
(void) pager_open(arg_pager_flags);
diff --git a/src/cgls/cgls.c b/src/cgls/cgls.c
index 939a391e21..e09adb8b5b 100644
--- a/src/cgls/cgls.c
+++ b/src/cgls/cgls.c
@@ -197,7 +197,7 @@ static int run(int argc, char *argv[]) {
arg_show_unit == SHOW_UNIT_USER,
&bus);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
}
q = show_cgroup_get_unit_path_and_warn(bus, *name, &cgroup);
diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c
index 348d2b0429..2d6b2da125 100644
--- a/src/hostname/hostnamectl.c
+++ b/src/hostname/hostnamectl.c
@@ -444,7 +444,7 @@ static int run(int argc, char *argv[]) {
r = bus_connect_transport(arg_transport, arg_host, false, &bus);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
return hostnamectl_main(bus, argc, argv);
}
diff --git a/src/locale/localectl.c b/src/locale/localectl.c
index 251901c391..e0664de826 100644
--- a/src/locale/localectl.c
+++ b/src/locale/localectl.c
@@ -511,7 +511,7 @@ static int run(int argc, char *argv[]) {
r = bus_connect_transport(arg_transport, arg_host, false, &bus);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
return localectl_main(bus, argc, argv);
}
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index 2b48a9acb7..4297a51008 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -1475,7 +1475,7 @@ static int run(int argc, char *argv[]) {
r = bus_connect_transport(arg_transport, arg_host, false, &bus);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
(void) sd_bus_set_allow_interactive_authorization(bus, arg_ask_password);
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index 26fa48d870..841eeae882 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -2897,7 +2897,7 @@ static int run(int argc, char *argv[]) {
r = bus_connect_transport(arg_transport, arg_host, false, &bus);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
(void) sd_bus_set_allow_interactive_authorization(bus, arg_ask_password);
diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c
index f5873d1c06..22da189684 100644
--- a/src/mount/mount-tool.c
+++ b/src/mount/mount-tool.c
@@ -1456,7 +1456,7 @@ static int run(int argc, char* argv[]) {
r = bus_connect_transport_systemd(arg_transport, arg_host, arg_user, &bus);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
if (arg_action == ACTION_UMOUNT)
return action_umount(bus, argc, argv);
diff --git a/src/run/run.c b/src/run/run.c
index 6b996015e3..d4ce3966e7 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -1753,7 +1753,7 @@ static int run(int argc, char* argv[]) {
else
r = bus_connect_transport_systemd(arg_transport, arg_host, arg_user, &bus);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
if (arg_scope)
r = start_transient_scope(bus);
diff --git a/src/shared/bus-util.h b/src/shared/bus-util.h
index fd88314c1f..d98e0040f3 100644
--- a/src/shared/bus-util.h
+++ b/src/shared/bus-util.h
@@ -37,6 +37,9 @@ int bus_connect_user_systemd(sd_bus **_bus);
int bus_connect_transport(BusTransport transport, const char *host, bool user, sd_bus **bus);
int bus_connect_transport_systemd(BusTransport transport, const char *host, bool user, sd_bus **bus);
+#define bus_log_connect_error(r) \
+ log_error_errno(r, "Failed to create bus connection: %m")
+
#define bus_log_parse_error(r) \
log_error_errno(r, "Failed to parse bus message: %m")
diff --git a/src/shared/cgroup-show.c b/src/shared/cgroup-show.c
index 208d27df1a..b8bf3c2726 100644
--- a/src/shared/cgroup-show.c
+++ b/src/shared/cgroup-show.c
@@ -371,7 +371,7 @@ int show_cgroup_get_path_and_warn(
r = bus_connect_transport_systemd(BUS_TRANSPORT_LOCAL, NULL, false, &bus);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
r = show_cgroup_get_unit_path_and_warn(bus, unit, &root);
if (r < 0)
diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c
index 49d68d2533..26d3e20353 100644
--- a/src/timedate/timedatectl.c
+++ b/src/timedate/timedatectl.c
@@ -1062,7 +1062,7 @@ static int run(int argc, char *argv[]) {
r = bus_connect_transport(arg_transport, arg_host, false, &bus);
if (r < 0)
- return log_error_errno(r, "Failed to create bus connection: %m");
+ return bus_log_connect_error(r);
return timedatectl_main(bus, argc, argv);
}