summaryrefslogtreecommitdiff
path: root/src/login/logind-dbus.c
diff options
context:
space:
mode:
authorLudwig Nussel <ludwig.nussel@suse.de>2022-02-03 17:08:28 +0100
committerLudwig Nussel <ludwig.nussel@suse.de>2022-02-14 09:35:12 +0100
commit138224fc807091d31f19a3b22f066d6044626001 (patch)
tree440f4a24214966c684ed15ff30f6793602e89722 /src/login/logind-dbus.c
parent3c84905b08b07b5a8b38f66649c6a393a8359427 (diff)
downloadsystemd-138224fc807091d31f19a3b22f066d6044626001.tar.gz
logind: add handle enum to struct
Avoid pointer arithmetic at the expense of repeating the enum value in the struct.
Diffstat (limited to 'src/login/logind-dbus.c')
-rw-r--r--src/login/logind-dbus.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index e801f24532..2cdd5b9084 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -349,7 +349,7 @@ static int property_get_scheduled_shutdown(
return r;
r = sd_bus_message_append(reply, "st",
- handle_action_to_string(manager_handle_for_item(m->scheduled_shutdown_type)),
+ m->scheduled_shutdown_type ? handle_action_to_string(m->scheduled_shutdown_type->handle) : NULL,
m->scheduled_shutdown_timeout);
if (r < 0)
return r;
@@ -1884,7 +1884,7 @@ static int method_do_shutdown_or_sleep(
return r;
if ((flags & ~SD_LOGIND_SHUTDOWN_AND_SLEEP_FLAGS_PUBLIC) != 0)
return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid flags parameter");
- if (manager_handle_for_item(a) != HANDLE_REBOOT && (flags & SD_LOGIND_REBOOT_VIA_KEXEC))
+ if (a->handle != HANDLE_REBOOT && (flags & SD_LOGIND_REBOOT_VIA_KEXEC))
return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Reboot via kexec is only applicable with reboot operations");
} else {
/* Old style method: no flags parameter, but interactive bool passed as boolean in
@@ -2035,6 +2035,7 @@ static int update_schedule_file(Manager *m) {
int r;
assert(m);
+ assert(m->scheduled_shutdown_type);
r = mkdir_safe_label("/run/systemd/shutdown", 0755, 0, 0, MKDIR_WARN_MODE);
if (r < 0)
@@ -2052,7 +2053,7 @@ static int update_schedule_file(Manager *m) {
"MODE=%s\n",
m->scheduled_shutdown_timeout,
m->enable_wall_messages,
- handle_action_to_string(manager_handle_for_item(m->scheduled_shutdown_type)));
+ handle_action_to_string(m->scheduled_shutdown_type->handle));
if (!isempty(m->wall_message)) {
_cleanup_free_ char *t = NULL;
@@ -2240,7 +2241,8 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd
assert(m);
assert(message);
- cancelled = !IN_SET(manager_handle_for_item(m->scheduled_shutdown_type), HANDLE_IGNORE, _HANDLE_ACTION_INVALID);
+ cancelled = m->scheduled_shutdown_type
+ && !IN_SET(m->scheduled_shutdown_type->handle, HANDLE_IGNORE, _HANDLE_ACTION_INVALID);
if (!cancelled)
goto done;