[vd_agent_linux,1/3] x11-randr: Avoid passing XEvent as value

Submitted by Frediano Ziglio on July 15, 2019, 11:13 a.m.

Details

Message ID 20190715111308.22291-1-fziglio@redhat.com
State Accepted
Commit b6dfef73f2926c65ed146eea6ab061dd87d77f10
Headers show
Series "Series without cover letter" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio July 15, 2019, 11:13 a.m.
The structure is not that small and is not necessary to copy
the value.
This also removed a Coverity warning.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 src/vdagent/x11-priv.h  | 2 +-
 src/vdagent/x11-randr.c | 8 ++++----
 src/vdagent/x11.c       | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/vdagent/x11-priv.h b/src/vdagent/x11-priv.h
index 99676d2..730b9b3 100644
--- a/src/vdagent/x11-priv.h
+++ b/src/vdagent/x11-priv.h
@@ -152,7 +152,7 @@  void vdagent_x11_send_daemon_guest_xorg_res(struct vdagent_x11 *x11,
 void vdagent_x11_randr_handle_root_size_change(struct vdagent_x11 *x11,
                                             int screen, int width, int height);
 int vdagent_x11_randr_handle_event(struct vdagent_x11 *x11,
-    XEvent event);
+    const XEvent *event);
 void vdagent_x11_set_error_handler(struct vdagent_x11 *x11,
     int (*handler)(Display *, XErrorEvent *));
 int vdagent_x11_restore_error_handler(struct vdagent_x11 *x11);
diff --git a/src/vdagent/x11-randr.c b/src/vdagent/x11-randr.c
index 88857c8..e299970 100644
--- a/src/vdagent/x11-randr.c
+++ b/src/vdagent/x11-randr.c
@@ -529,14 +529,14 @@  void vdagent_x11_randr_handle_root_size_change(struct vdagent_x11 *x11,
 }
 
 int vdagent_x11_randr_handle_event(struct vdagent_x11 *x11,
-    XEvent event)
+    const XEvent *event)
 {
     int handled = TRUE;
 
-    switch (event.type - x11->xrandr_event_base) {
+    switch (event->type - x11->xrandr_event_base) {
         case RRScreenChangeNotify: {
-            XRRScreenChangeNotifyEvent *sce =
-                (XRRScreenChangeNotifyEvent *) &event;
+            const XRRScreenChangeNotifyEvent *sce =
+                (const XRRScreenChangeNotifyEvent *) event;
             vdagent_x11_randr_handle_root_size_change(x11, 0,
                 sce->width, sce->height);
             break;
diff --git a/src/vdagent/x11.c b/src/vdagent/x11.c
index c2515a8..61d7c69 100644
--- a/src/vdagent/x11.c
+++ b/src/vdagent/x11.c
@@ -545,7 +545,7 @@  static void vdagent_x11_handle_event(struct vdagent_x11 *x11, XEvent event)
     }
 #endif
 
-    if (vdagent_x11_randr_handle_event(x11, event))
+    if (vdagent_x11_randr_handle_event(x11, &event))
         return;
 
     switch (event.type) {

Comments

ping the series

> 
> The structure is not that small and is not necessary to copy
> the value.
> This also removed a Coverity warning.
> 
> Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
> ---
>  src/vdagent/x11-priv.h  | 2 +-
>  src/vdagent/x11-randr.c | 8 ++++----
>  src/vdagent/x11.c       | 2 +-
>  3 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/src/vdagent/x11-priv.h b/src/vdagent/x11-priv.h
> index 99676d2..730b9b3 100644
> --- a/src/vdagent/x11-priv.h
> +++ b/src/vdagent/x11-priv.h
> @@ -152,7 +152,7 @@ void vdagent_x11_send_daemon_guest_xorg_res(struct
> vdagent_x11 *x11,
>  void vdagent_x11_randr_handle_root_size_change(struct vdagent_x11 *x11,
>                                              int screen, int width, int
>                                              height);
>  int vdagent_x11_randr_handle_event(struct vdagent_x11 *x11,
> -    XEvent event);
> +    const XEvent *event);
>  void vdagent_x11_set_error_handler(struct vdagent_x11 *x11,
>      int (*handler)(Display *, XErrorEvent *));
>  int vdagent_x11_restore_error_handler(struct vdagent_x11 *x11);
> diff --git a/src/vdagent/x11-randr.c b/src/vdagent/x11-randr.c
> index 88857c8..e299970 100644
> --- a/src/vdagent/x11-randr.c
> +++ b/src/vdagent/x11-randr.c
> @@ -529,14 +529,14 @@ void vdagent_x11_randr_handle_root_size_change(struct
> vdagent_x11 *x11,
>  }
>  
>  int vdagent_x11_randr_handle_event(struct vdagent_x11 *x11,
> -    XEvent event)
> +    const XEvent *event)
>  {
>      int handled = TRUE;
>  
> -    switch (event.type - x11->xrandr_event_base) {
> +    switch (event->type - x11->xrandr_event_base) {
>          case RRScreenChangeNotify: {
> -            XRRScreenChangeNotifyEvent *sce =
> -                (XRRScreenChangeNotifyEvent *) &event;
> +            const XRRScreenChangeNotifyEvent *sce =
> +                (const XRRScreenChangeNotifyEvent *) event;
>              vdagent_x11_randr_handle_root_size_change(x11, 0,
>                  sce->width, sce->height);
>              break;
> diff --git a/src/vdagent/x11.c b/src/vdagent/x11.c
> index c2515a8..61d7c69 100644
> --- a/src/vdagent/x11.c
> +++ b/src/vdagent/x11.c
> @@ -545,7 +545,7 @@ static void vdagent_x11_handle_event(struct vdagent_x11
> *x11, XEvent event)
>      }
>  #endif
>  
> -    if (vdagent_x11_randr_handle_event(x11, event))
> +    if (vdagent_x11_randr_handle_event(x11, &event))
>          return;
>  
>      switch (event.type) {