Blame SOURCES/0006-x11-Avoid-passing-XEvent-as-value.patch

0985ad
From 3522667bfac147f4f959025ccf12ea1d99cc1f75 Mon Sep 17 00:00:00 2001
0985ad
From: Frediano Ziglio <fziglio@redhat.com>
0985ad
Date: Wed, 19 Dec 2018 18:28:38 +0000
0985ad
Subject: [PATCH 6/9] x11: Avoid passing XEvent as value
0985ad
0985ad
The structure is not that small and is not necessary to copy
0985ad
the value.
0985ad
This also removed a Coverity warning.
0985ad
0985ad
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
0985ad
Acked-by: Victor Toso <victortoso@redhat.com>
0985ad
---
0985ad
 src/vdagent/x11.c | 42 +++++++++++++++++++++---------------------
0985ad
 1 file changed, 21 insertions(+), 21 deletions(-)
0985ad
0985ad
diff --git a/src/vdagent/x11.c b/src/vdagent/x11.c
0985ad
index 61d7c69..42f42e7 100644
0985ad
--- a/src/vdagent/x11.c
0985ad
+++ b/src/vdagent/x11.c
0985ad
@@ -494,23 +494,23 @@ static int vdagent_x11_get_clipboard_selection(struct vdagent_x11 *x11,
0985ad
 }
0985ad
 #endif
0985ad
 
0985ad
-static void vdagent_x11_handle_event(struct vdagent_x11 *x11, XEvent event)
0985ad
+static void vdagent_x11_handle_event(struct vdagent_x11 *x11, XEvent *event)
0985ad
 {
0985ad
     int i, handled = 0;
0985ad
 #ifndef WITH_GTK
0985ad
     uint8_t selection;
0985ad
 
0985ad
-    if (event.type == x11->xfixes_event_base) {
0985ad
+    if (event->type == x11->xfixes_event_base) {
0985ad
         union {
0985ad
             XEvent ev;
0985ad
             XFixesSelectionNotifyEvent xfev;
0985ad
         } ev;
0985ad
 
0985ad
-        if (vdagent_x11_get_clipboard_selection(x11, &event, &selection)) {
0985ad
+        if (vdagent_x11_get_clipboard_selection(x11, event, &selection)) {
0985ad
             return;
0985ad
         }
0985ad
 
0985ad
-        ev.ev = event;
0985ad
+        ev.ev = *event;
0985ad
         switch (ev.xfev.subtype) {
0985ad
         case XFixesSetSelectionOwnerNotify:
0985ad
             break;
0985ad
@@ -521,7 +521,7 @@ static void vdagent_x11_handle_event(struct vdagent_x11 *x11, XEvent event)
0985ad
             break;
0985ad
         default:
0985ad
             VSELPRINTF("unexpected xfix event subtype %d window %d",
0985ad
-                       (int)ev.xfev.subtype, (int)event.xany.window);
0985ad
+                       (int)ev.xfev.subtype, (int)event->xany.window);
0985ad
             return;
0985ad
         }
0985ad
         VSELPRINTF("New selection owner: %u", (unsigned int)ev.xfev.owner);
0985ad
@@ -545,20 +545,20 @@ static void vdagent_x11_handle_event(struct vdagent_x11 *x11, XEvent event)
0985ad
     }
0985ad
 #endif
0985ad
 
0985ad
-    if (vdagent_x11_randr_handle_event(x11, &event))
0985ad
+    if (vdagent_x11_randr_handle_event(x11, event))
0985ad
         return;
0985ad
 
0985ad
-    switch (event.type) {
0985ad
+    switch (event->type) {
0985ad
     case ConfigureNotify:
0985ad
         for (i = 0; i < x11->screen_count; i++)
0985ad
-            if (event.xconfigure.window == x11->root_window[i])
0985ad
+            if (event->xconfigure.window == x11->root_window[i])
0985ad
                 break;
0985ad
         if (i == x11->screen_count)
0985ad
             break;
0985ad
 
0985ad
         handled = 1;
0985ad
         vdagent_x11_randr_handle_root_size_change(x11, i,
0985ad
-                event.xconfigure.width, event.xconfigure.height);
0985ad
+                event->xconfigure.width, event->xconfigure.height);
0985ad
         break;
0985ad
     case MappingNotify:
0985ad
         /* These are uninteresting */
0985ad
@@ -566,21 +566,21 @@ static void vdagent_x11_handle_event(struct vdagent_x11 *x11, XEvent event)
0985ad
         break;
0985ad
 #ifndef WITH_GTK
0985ad
     case SelectionNotify:
0985ad
-        if (event.xselection.target == x11->targets_atom)
0985ad
-            vdagent_x11_handle_targets_notify(x11, &event);
0985ad
+        if (event->xselection.target == x11->targets_atom)
0985ad
+            vdagent_x11_handle_targets_notify(x11, event);
0985ad
         else
0985ad
-            vdagent_x11_handle_selection_notify(x11, &event, 0);
0985ad
+            vdagent_x11_handle_selection_notify(x11, event, 0);
0985ad
 
0985ad
         handled = 1;
0985ad
         break;
0985ad
     case PropertyNotify:
0985ad
         if (x11->expect_property_notify &&
0985ad
-                                event.xproperty.state == PropertyNewValue) {
0985ad
-            vdagent_x11_handle_selection_notify(x11, &event, 1);
0985ad
+                                event->xproperty.state == PropertyNewValue) {
0985ad
+            vdagent_x11_handle_selection_notify(x11, event, 1);
0985ad
         }
0985ad
         if (x11->selection_req_data &&
0985ad
-                                 event.xproperty.state == PropertyDelete) {
0985ad
-            vdagent_x11_handle_property_delete_notify(x11, &event);
0985ad
+                                 event->xproperty.state == PropertyDelete) {
0985ad
+            vdagent_x11_handle_property_delete_notify(x11, event);
0985ad
         }
0985ad
         /* Always mark as handled, since we cannot unselect input for property
0985ad
            notifications once we are done with handling the incr transfer. */
0985ad
@@ -594,7 +594,7 @@ static void vdagent_x11_handle_event(struct vdagent_x11 *x11, XEvent event)
0985ad
     case SelectionRequest: {
0985ad
         struct vdagent_x11_selection_request *req, *new_req;
0985ad
 
0985ad
-        if (vdagent_x11_get_clipboard_selection(x11, &event, &selection)) {
0985ad
+        if (vdagent_x11_get_clipboard_selection(x11, event, &selection)) {
0985ad
             return;
0985ad
         }
0985ad
 
0985ad
@@ -606,7 +606,7 @@ static void vdagent_x11_handle_event(struct vdagent_x11 *x11, XEvent event)
0985ad
 
0985ad
         handled = 1;
0985ad
 
0985ad
-        new_req->event = event;
0985ad
+        new_req->event = *event;
0985ad
         new_req->selection = selection;
0985ad
         new_req->next = NULL;
0985ad
 
0985ad
@@ -628,7 +628,7 @@ static void vdagent_x11_handle_event(struct vdagent_x11 *x11, XEvent event)
0985ad
     }
0985ad
     if (!handled && x11->debug)
0985ad
         syslog(LOG_DEBUG, "unhandled x11 event, type %d, window %d",
0985ad
-               (int)event.type, (int)event.xany.window);
0985ad
+               (int)event->type, (int)event->xany.window);
0985ad
 }
0985ad
 
0985ad
 void vdagent_x11_do_read(struct vdagent_x11 *x11)
0985ad
@@ -637,7 +637,7 @@ void vdagent_x11_do_read(struct vdagent_x11 *x11)
0985ad
 
0985ad
     while (XPending(x11->display)) {
0985ad
         XNextEvent(x11->display, &event);
0985ad
-        vdagent_x11_handle_event(x11, event);
0985ad
+        vdagent_x11_handle_event(x11, &event);
0985ad
     }
0985ad
 }
0985ad
 
0985ad
@@ -1370,7 +1370,7 @@ void vdagent_x11_clipboard_release(struct vdagent_x11 *x11, uint8_t selection)
0985ad
     XSync(x11->display, False);
0985ad
     while (XCheckTypedEvent(x11->display, x11->xfixes_event_base,
0985ad
                             &event))
0985ad
-        vdagent_x11_handle_event(x11, event);
0985ad
+        vdagent_x11_handle_event(x11, &event);
0985ad
 
0985ad
     /* Note no need to do a set_clipboard_owner(owner_none) here, as that is
0985ad
        already done by processing the XFixesSetSelectionOwnerNotify event. */
0985ad
-- 
0985ad
2.21.0
0985ad