tree-wide: use bus locator (#24252)

This modifies some sd_bus calls to equivalent bus calls.
This commit is contained in:
gtwang01
2022-08-09 00:19:09 -07:00
committed by GitHub
parent 5ed47c4d23
commit b607fd3f32
4 changed files with 18 additions and 24 deletions

View File

@@ -13,6 +13,7 @@
#include "alloc-util.h"
#include "bus-error.h"
#include "bus-locator.h"
#include "bus-log-control-api.h"
#include "bus-polkit.h"
#include "bus-util.h"
@@ -1041,12 +1042,10 @@ int manager_set_timezone(Manager *m, const char *tz) {
return 0;
}
r = sd_bus_call_method_async(
r = bus_call_method_async(
m->bus,
NULL,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
bus_timedate,
"SetTimezone",
set_timezone_handler,
m,

View File

@@ -597,11 +597,9 @@ static int maybe_start_stop_restart(sd_bus *bus, const char *path, const char *m
if (!arg_now)
return 0;
r = sd_bus_call_method(
r = bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
bus_systemd_mgr,
method,
&error,
&reply,

View File

@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "bus-locator.h"
#include "bus-unit-procs.h"
#include "glyph-util.h"
#include "hashmap.h"
@@ -344,11 +345,9 @@ int unit_show_processes(
prefix = strempty(prefix);
r = sd_bus_call_method(
r = bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
bus_systemd_mgr,
"GetUnitProcesses",
error,
&reply,

View File

@@ -8,6 +8,7 @@
#include "sd-bus.h"
#include "bus-locator.h"
#include "bus-util.h"
#include "bus-error.h"
#include "def.h"
@@ -24,12 +25,10 @@ static int reload_manager(sd_bus *bus) {
log_info("Reloading system manager configuration");
r = sd_bus_message_new_method_call(
r = bus_message_new_method_call(
bus,
&m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
bus_systemd_mgr,
"Reload");
if (r < 0)
return bus_log_create_error(r);
@@ -52,14 +51,13 @@ static int start_default_target(sd_bus *bus) {
log_info("Starting "SPECIAL_DEFAULT_TARGET);
/* Start this unit only if we can replace basic.target with it */
r = sd_bus_call_method(bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"StartUnit",
&error,
NULL,
"ss", SPECIAL_DEFAULT_TARGET, "isolate");
r = bus_call_method(
bus,
bus_systemd_mgr,
"StartUnit",
&error,
NULL,
"ss", SPECIAL_DEFAULT_TARGET, "isolate");
if (r < 0)
return log_error_errno(r, "Failed to start "SPECIAL_DEFAULT_TARGET": %s", bus_error_message(&error, r));