]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: fix handle_action_valid()
authorLudwig Nussel <ludwig.nussel@suse.de>
Wed, 23 Feb 2022 07:49:56 +0000 (08:49 +0100)
committerLudwig Nussel <ludwig.nussel@suse.de>
Mon, 28 Feb 2022 09:31:10 +0000 (10:31 +0100)
src/login/logind-action.h
src/login/logind-button.c

index 621c5f97bc6b50f6e8692f1ff8b7093ac83ceb69..4dcf719488d0a50cb9d8c9ccedef73b8937de5e8 100644 (file)
@@ -21,7 +21,7 @@ typedef enum HandleAction {
 
 typedef struct ActionTableItem ActionTableItem;
 
-#define handle_action_valid(x) (x && (x < _HANDLE_ACTION_MAX))
+#define handle_action_valid(x) (x >= 0 && x < _HANDLE_ACTION_MAX)
 
 #include "logind-inhibit.h"
 #include "logind.h"
index 0f4e1f1b4173721f992e5be1edad1c4b71ae43f8..a2b43d368430dbc4461a7c4c0fe7a087b9c13940 100644 (file)
@@ -84,7 +84,7 @@ static void button_lid_switch_handle_action(Manager *manager, bool is_edge) {
          * differently */
         if (manager_is_docked_or_external_displays(manager))
                 handle_action = manager->handle_lid_switch_docked;
-        else if (!handle_action_valid(manager->handle_lid_switch_ep) && manager_is_on_external_power())
+        else if (handle_action_valid(manager->handle_lid_switch_ep) && manager_is_on_external_power())
                 handle_action = manager->handle_lid_switch_ep;
         else
                 handle_action = manager->handle_lid_switch;