chiark / gitweb /
event: be more conservative when returning errors from event handler callbacks
[elogind.git] / src / login / logind-button.c
index 3dd0829..e29f2c4 100644 (file)
@@ -141,7 +141,9 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
                                    "MESSAGE=Power key pressed.",
                                    MESSAGE_ID(SD_MESSAGE_POWER_KEY),
                                    NULL);
-                        return button_handle(b, INHIBIT_HANDLE_POWER_KEY, b->manager->handle_power_key, b->manager->power_key_ignore_inhibited, true);
+
+                        button_handle(b, INHIBIT_HANDLE_POWER_KEY, b->manager->handle_power_key, b->manager->power_key_ignore_inhibited, true);
+                        break;
 
                 /* The kernel is a bit confused here:
 
@@ -154,41 +156,41 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
                                    "MESSAGE=Suspend key pressed.",
                                    MESSAGE_ID(SD_MESSAGE_SUSPEND_KEY),
                                    NULL);
-                        return button_handle(b, INHIBIT_HANDLE_SUSPEND_KEY, b->manager->handle_suspend_key, b->manager->suspend_key_ignore_inhibited, true);
+
+                        button_handle(b, INHIBIT_HANDLE_SUSPEND_KEY, b->manager->handle_suspend_key, b->manager->suspend_key_ignore_inhibited, true);
+                        break;
 
                 case KEY_SUSPEND:
                         log_struct(LOG_INFO,
                                    "MESSAGE=Hibernate key pressed.",
                                    MESSAGE_ID(SD_MESSAGE_HIBERNATE_KEY),
                                    NULL);
-                        return button_handle(b, INHIBIT_HANDLE_HIBERNATE_KEY, b->manager->handle_hibernate_key, b->manager->hibernate_key_ignore_inhibited, true);
+
+                        button_handle(b, INHIBIT_HANDLE_HIBERNATE_KEY, b->manager->handle_hibernate_key, b->manager->hibernate_key_ignore_inhibited, true);
+                        break;
                 }
 
         } else if (ev.type == EV_SW && ev.value > 0) {
 
-                switch (ev.code) {
-
-                case SW_LID:
+                if (ev.code == SW_LID) {
                         log_struct(LOG_INFO,
                                    "MESSAGE=Lid closed.",
                                    MESSAGE_ID(SD_MESSAGE_LID_CLOSED),
                                    NULL);
-                        b->lid_close_queued = true;
 
-                        return button_handle(b, INHIBIT_HANDLE_LID_SWITCH, b->manager->handle_lid_switch, b->manager->lid_switch_ignore_inhibited, true);
+                        b->lid_close_queued = true;
+                        button_handle(b, INHIBIT_HANDLE_LID_SWITCH, b->manager->handle_lid_switch, b->manager->lid_switch_ignore_inhibited, true);
                 }
 
         } else if (ev.type == EV_SW && ev.value == 0) {
 
-                switch (ev.code) {
-
-                case SW_LID:
+                if (ev.code == SW_LID) {
                         log_struct(LOG_INFO,
                                    "MESSAGE=Lid opened.",
                                    MESSAGE_ID(SD_MESSAGE_LID_OPENED),
                                    NULL);
+
                         b->lid_close_queued = false;
-                        break;
                 }
         }