From: Vito Caputo Date: Sun, 3 May 2020 05:41:12 +0000 (-0700) Subject: analyze: switch to BusLocator-oriented helpers X-Git-Tag: v246-rc1~417^2~13 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=de770b6042ffd0ecc80237e80e4f7d50274daf3b;p=thirdparty%2Fsystemd.git analyze: switch to BusLocator-oriented helpers Mechanical substitution reducing some verbosity --- diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index 3ea9041c188..4510b2e1df5 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -349,14 +349,7 @@ static int acquire_time_data(sd_bus *bus, struct unit_times **out) { if (r < 0) return r; - r = sd_bus_call_method( - bus, - "org.freedesktop.systemd1", - "/org/freedesktop/systemd1", - "org.freedesktop.systemd1.Manager", - "ListUnits", - &error, &reply, - NULL); + r = bus_call_method(bus, bus_systemd_mgr, "ListUnits", &error, &reply, NULL); if (r < 0) return log_error_errno(r, "Failed to list units: %s", bus_error_message(&error, r)); @@ -1284,15 +1277,7 @@ static int dot(int argc, char *argv[], void *userdata) { if (r < 0) return r; - r = sd_bus_call_method( - bus, - "org.freedesktop.systemd1", - "/org/freedesktop/systemd1", - "org.freedesktop.systemd1.Manager", - "ListUnits", - &error, - &reply, - ""); + r = bus_call_method(bus, bus_systemd_mgr, "ListUnits", &error, &reply, ""); if (r < 0) log_error_errno(r, "Failed to list units: %s", bus_error_message(&error, r)); @@ -1334,15 +1319,7 @@ static int dump_fallback(sd_bus *bus) { assert(bus); - r = sd_bus_call_method( - bus, - "org.freedesktop.systemd1", - "/org/freedesktop/systemd1", - "org.freedesktop.systemd1.Manager", - "Dump", - &error, - &reply, - NULL); + r = bus_call_method(bus, bus_systemd_mgr, "Dump", &error, &reply, NULL); if (r < 0) return log_error_errno(r, "Failed to issue method call Dump: %s", bus_error_message(&error, r)); @@ -1370,15 +1347,7 @@ static int dump(int argc, char *argv[], void *userdata) { if (!sd_bus_can_send(bus, SD_BUS_TYPE_UNIX_FD)) return dump_fallback(bus); - r = sd_bus_call_method( - bus, - "org.freedesktop.systemd1", - "/org/freedesktop/systemd1", - "org.freedesktop.systemd1.Manager", - "DumpByFileDescriptor", - &error, - &reply, - NULL); + r = bus_call_method(bus, bus_systemd_mgr, "DumpByFileDescriptor", &error, &reply, NULL); if (r < 0) { /* fall back to Dump if DumpByFileDescriptor is not supported */ if (!IN_SET(r, -EACCES, -EBADR)) @@ -1444,15 +1413,7 @@ static int set_log_level(int argc, char *argv[], void *userdata) { if (r < 0) return log_error_errno(r, "Failed to create bus connection: %m"); - r = sd_bus_set_property( - bus, - "org.freedesktop.systemd1", - "/org/freedesktop/systemd1", - "org.freedesktop.systemd1.Manager", - "LogLevel", - &error, - "s", - argv[1]); + r = bus_set_property(bus, bus_systemd_mgr, "LogLevel", &error, "s", argv[1]); if (r < 0) return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, r)); @@ -1469,14 +1430,7 @@ static int get_log_level(int argc, char *argv[], void *userdata) { if (r < 0) return log_error_errno(r, "Failed to create bus connection: %m"); - r = sd_bus_get_property_string( - bus, - "org.freedesktop.systemd1", - "/org/freedesktop/systemd1", - "org.freedesktop.systemd1.Manager", - "LogLevel", - &error, - &level); + r = bus_get_property_string(bus, bus_systemd_mgr, "LogLevel", &error, &level); if (r < 0) return log_error_errno(r, "Failed to get log level: %s", bus_error_message(&error, r)); @@ -1500,15 +1454,7 @@ static int set_log_target(int argc, char *argv[], void *userdata) { if (r < 0) return log_error_errno(r, "Failed to create bus connection: %m"); - r = sd_bus_set_property( - bus, - "org.freedesktop.systemd1", - "/org/freedesktop/systemd1", - "org.freedesktop.systemd1.Manager", - "LogTarget", - &error, - "s", - argv[1]); + r = bus_set_property(bus, bus_systemd_mgr, "LogTarget", &error, "s", argv[1]); if (r < 0) return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, r)); @@ -1525,14 +1471,7 @@ static int get_log_target(int argc, char *argv[], void *userdata) { if (r < 0) return log_error_errno(r, "Failed to create bus connection: %m"); - r = sd_bus_get_property_string( - bus, - "org.freedesktop.systemd1", - "/org/freedesktop/systemd1", - "org.freedesktop.systemd1.Manager", - "LogTarget", - &error, - &target); + r = bus_get_property_string(bus, bus_systemd_mgr, "LogTarget", &error, &target); if (r < 0) return log_error_errno(r, "Failed to get log target: %s", bus_error_message(&error, r)); @@ -2121,15 +2060,7 @@ static int service_watchdogs(int argc, char *argv[], void *userdata) { if (argc == 1) { /* get ServiceWatchdogs */ - r = sd_bus_get_property_trivial( - bus, - "org.freedesktop.systemd1", - "/org/freedesktop/systemd1", - "org.freedesktop.systemd1.Manager", - "ServiceWatchdogs", - &error, - 'b', - &b); + r = bus_get_property_trivial(bus, bus_systemd_mgr, "ServiceWatchdogs", &error, 'b', &b); if (r < 0) return log_error_errno(r, "Failed to get service-watchdog state: %s", bus_error_message(&error, r)); @@ -2141,15 +2072,7 @@ static int service_watchdogs(int argc, char *argv[], void *userdata) { if (b < 0) return log_error_errno(b, "Failed to parse service-watchdogs argument: %m"); - r = sd_bus_set_property( - bus, - "org.freedesktop.systemd1", - "/org/freedesktop/systemd1", - "org.freedesktop.systemd1.Manager", - "ServiceWatchdogs", - &error, - "b", - b); + r = bus_set_property(bus, bus_systemd_mgr, "ServiceWatchdogs", &error, "b", b); if (r < 0) return log_error_errno(r, "Failed to set service-watchdog state: %s", bus_error_message(&error, r)); }