[gnome-settings-daemon/benzea/fix-read-len-check] rfkill: Do not sync state immediately when opening rfkill



commit 1ec87c5e989d0549388df373ff9eb3b7d840a156
Author: Benjamin Berg <bberg redhat com>
Date:   Wed Apr 14 12:32:13 2021 +0200

    rfkill: Do not sync state immediately when opening rfkill
    
    We are opening the device asynchronously anyway. There is really no need
    to sync the state immediately, we can simpl rely on the POLL handler to
    do so later on from the mainloop.
    
    The difference we should see is that the debug information about there
    being no rfkill devices is gone. And, that some of the debug messages
    will be slightly different.

 plugins/rfkill/rfkill-glib.c | 39 ---------------------------------------
 1 file changed, 39 deletions(-)
---
diff --git a/plugins/rfkill/rfkill-glib.c b/plugins/rfkill/rfkill-glib.c
index e799174a..b919ca8a 100644
--- a/plugins/rfkill/rfkill-glib.c
+++ b/plugins/rfkill/rfkill-glib.c
@@ -389,7 +389,6 @@ _cc_rfkill_glib_open (CcRfkillGlib  *rfkill,
 {
        int fd;
        int ret;
-       GList *events;
 
        g_return_val_if_fail (CC_RFKILL_IS_GLIB (rfkill), FALSE);
        g_return_val_if_fail (rfkill->stream == NULL, FALSE);
@@ -411,37 +410,6 @@ _cc_rfkill_glib_open (CcRfkillGlib  *rfkill,
                return FALSE;
        }
 
-       events = NULL;
-
-       while (1) {
-               struct rfkill_event event;
-               struct rfkill_event *event_ptr;
-               ssize_t len;
-
-               len = read(fd, &event, sizeof(event));
-               if (len < 0) {
-                       if (errno == EAGAIN)
-                               break;
-                       g_debug ("Reading of RFKILL events failed");
-                       break;
-               }
-
-               if (len != RFKILL_EVENT_SIZE_V1) {
-                       g_warning ("Wrong size of RFKILL event\n");
-                       continue;
-               }
-
-               if (event.op != RFKILL_OP_ADD)
-                       continue;
-
-               g_debug ("Read killswitch of type '%s' (idx=%d): soft %d hard %d",
-                        type_to_string (event.type),
-                        event.idx, event.soft, event.hard);
-
-               event_ptr = g_memdup (&event, sizeof(event));
-               events = g_list_prepend (events, event_ptr);
-       }
-
        /* Setup monitoring */
        rfkill->channel = g_io_channel_unix_new (fd);
        g_io_channel_set_encoding (rfkill->channel, NULL, NULL);
@@ -451,13 +419,6 @@ _cc_rfkill_glib_open (CcRfkillGlib  *rfkill,
                                           (GIOFunc) event_cb,
                                           rfkill);
 
-       if (events) {
-               events = g_list_reverse (events);
-               emit_changed_signal_and_free (rfkill, events);
-       } else {
-               g_debug ("No rfkill device available on startup");
-       }
-
        /* Setup write stream */
        rfkill->stream = g_unix_output_stream_new (fd, TRUE);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]