]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: style fixes
authorLudwig Nussel <ludwig.nussel@suse.de>
Mon, 7 Feb 2022 09:56:19 +0000 (10:56 +0100)
committerLudwig Nussel <ludwig.nussel@suse.de>
Mon, 14 Feb 2022 08:35:12 +0000 (09:35 +0100)
src/login/logind-action.c
src/login/logind-action.h
src/login/logind-dbus.c

index a4f3f6c3f662fada13a7cb253f1efe4876b12725..00ef211964ad2870e6adeca56a5fc42b35c38bb7 100644 (file)
@@ -117,13 +117,6 @@ static const ActionTableItem action_table[_HANDLE_ACTION_MAX] = {
                 },
 };
 
-const char* manager_target_for_action(HandleAction handle) {
-        assert(handle >= 0);
-        assert(handle < (ssize_t) ELEMENTSOF(action_table));
-
-        return action_table[handle].target;
-}
-
 const ActionTableItem* manager_item_for_handle(HandleAction handle) {
         assert(handle >= 0);
         assert(handle < (ssize_t) ELEMENTSOF(action_table));
index 710aa4931d72980e74923efa3358d1daebe512ce..621c5f97bc6b50f6e8692f1ff8b7093ac83ceb69 100644 (file)
@@ -37,8 +37,7 @@ struct ActionTableItem {
         SleepOperation sleep_operation;
         const char* message_id;
         const char* message;
-        const char* log_str;
-
+        const char* log_message;
 };
 
 int manager_handle_action(
@@ -51,7 +50,6 @@ int manager_handle_action(
 const char* handle_action_to_string(HandleAction h) _const_;
 HandleAction handle_action_from_string(const char *s) _pure_;
 
-const char* manager_target_for_action(HandleAction handle);
 const ActionTableItem* manager_item_for_handle(HandleAction handle);
 HandleAction manager_handle_for_item(const ActionTableItem* a);
 
index 2cdd5b9084d2bb2d20dfd5b9ed68c1a4af9b012a..ef31ec654ec9e6e020b77dd2f4a6b18f8d74d288 100644 (file)
@@ -1499,13 +1499,13 @@ static int bus_manager_log_shutdown(
                 Manager *m,
                 const ActionTableItem *a) {
 
-        const char *message, *log_str;
+        const char *message, *log_message;
 
         assert(m);
         assert(a);
 
         message = a->message;
-        log_str = a->log_str;
+        log_message = a->log_message;
 
         if (message)
                 message = strjoina("MESSAGE=", message);
@@ -1517,13 +1517,13 @@ static int bus_manager_log_shutdown(
         else
                 message = strjoina(message, " (", m->wall_message, ").");
 
-        if (log_str)
-                log_str = strjoina("SHUTDOWN=", log_str);
+        if (log_message)
+                log_message = strjoina("SHUTDOWN=", log_message);
 
         return log_struct(LOG_NOTICE,
                         "MESSAGE_ID=%s", a->message_id ? a->message_id : SD_MESSAGE_SHUTDOWN_STR,
                         message,
-                        log_str);
+                        log_message);
 }
 
 static int lid_switch_ignore_handler(sd_event_source *e, uint64_t usec, void *userdata) {
@@ -2244,7 +2244,7 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd
         cancelled = m->scheduled_shutdown_type
                 && !IN_SET(m->scheduled_shutdown_type->handle, HANDLE_IGNORE, _HANDLE_ACTION_INVALID);
         if (!cancelled)
-                goto done;
+                return sd_bus_reply_method_return(message, "b", false);
 
         a = m->scheduled_shutdown_type;
         if (!a->polkit_action)
@@ -2283,8 +2283,7 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd
                           username, tty, logind_wall_tty_filter, m);
         }
 
-done:
-        return sd_bus_reply_method_return(message, "b", cancelled);
+        return sd_bus_reply_method_return(message, "b", true);
 }
 
 static int method_can_shutdown_or_sleep(
@@ -2330,7 +2329,7 @@ static int method_can_shutdown_or_sleep(
         if (handle >= 0) {
                 const char *target;
 
-                target = manager_target_for_action(handle);
+                target = manager_item_for_handle(handle)->target;
                 if (target) {
                         _cleanup_free_ char *load_state = NULL;