]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind-dbus: minor modernization
authorMike Yuan <me@yhndnzj.com>
Sat, 13 Jan 2024 21:14:25 +0000 (05:14 +0800)
committerMike Yuan <me@yhndnzj.com>
Sat, 13 Jan 2024 21:14:25 +0000 (05:14 +0800)
src/login/logind-dbus.c

index 99b9da6ba10802795c7118e347ef0e7a627094a1..2b993fd842f85d30768e70f7923d29a3c3ae4b66 100644 (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;
         }