logind-dbus: minor modernization

This commit is contained in:
Mike Yuan
2024-01-14 05:14:25 +08:00
parent b24db7052e
commit 1f4cb8c9cf

View File

@@ -1748,6 +1748,7 @@ static int execute_shutdown_or_sleep(
int r;
assert(m);
assert(!m->action_job);
assert(a);
if (a->inhibit_what == INHIBIT_SHUTDOWN)
@@ -1767,9 +1768,11 @@ static int execute_shutdown_or_sleep(
if (r < 0)
goto error;
r = free_and_strdup(&m->action_job, p);
if (r < 0)
m->action_job = strdup(p);
if (!m->action_job) {
r = -ENOMEM;
goto error;
}
m->delayed_action = a;
@@ -2401,8 +2404,9 @@ static int manager_scheduled_shutdown_handler(
/* Don't allow multiple jobs being executed at the same time */
if (m->delayed_action) {
r = -EALREADY;
log_error("Scheduled shutdown to %s failed: shutdown or sleep operation already in progress", a->target);
r = log_error_errno(SYNTHETIC_ERRNO(EALREADY),
"Scheduled shutdown to %s failed: shutdown or sleep operation already in progress.",
a->target);
goto error;
}