[Spice-devel,08/13] Remove use of opaque from vdi_port_read_one_msg_from_device

Submitted by Jonathon Jongsma on April 13, 2016, 7:37 p.m.

Details

Message ID 1460576282-27544-9-git-send-email-jjongsma@redhat.com
State Superseded
Headers show
Series "Backported patches from refactory branch (April 13)" ( rev: 4 3 2 1 ) in Spice

Commit Message

Jonathon Jongsma April 13, 2016, 7:37 p.m.
From: Christophe Fergeau <cfergeau@redhat.com>

We can get 'reds' from the RedCharDevice accessible from the
SpiceCharDeviceInstance passed as an argument.
---
 server/reds.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/server/reds.c b/server/reds.c
index f7f6828..47385e4 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -786,12 +786,14 @@  static void vdi_port_read_buf_free(VDIReadBuf *buf)
 static RedPipeItem *vdi_port_read_one_msg_from_device(SpiceCharDeviceInstance *sin,
                                                       void *opaque)
 {
-    RedsState *reds = opaque;
-    RedCharDeviceVDIPort *dev = reds->agent_dev;
+    RedsState *reds;
+    RedCharDeviceVDIPort *dev = RED_CHAR_DEVICE_VDIPORT(sin->st);
     SpiceCharDeviceInterface *sif;
     VDIReadBuf *dispatch_buf;
     int n;
 
+    g_object_get(dev, "spice-server", &reds, NULL);
+    g_assert(RED_CHAR_DEVICE(reds->agent_dev) == sin->st);
     if (!reds->vdagent) {
         return NULL;
     }

Comments

On Wed, 2016-04-13 at 14:37 -0500, Jonathon Jongsma wrote:
> From: Christophe Fergeau <cfergeau@redhat.com>
> 
> We can get 'reds' from the RedCharDevice accessible from the
> SpiceCharDeviceInstance passed as an argument.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
> ---
>  server/reds.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/server/reds.c b/server/reds.c
> index f7f6828..47385e4 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -786,12 +786,14 @@ static void vdi_port_read_buf_free(VDIReadBuf
> *buf)
>  static RedPipeItem
> *vdi_port_read_one_msg_from_device(SpiceCharDeviceInstance *sin,
>                                                        void *opaque)
>  {
> -    RedsState *reds = opaque;
> -    RedCharDeviceVDIPort *dev = reds->agent_dev;
> +    RedsState *reds;
> +    RedCharDeviceVDIPort *dev = RED_CHAR_DEVICE_VDIPORT(sin->st);
>      SpiceCharDeviceInterface *sif;
>      VDIReadBuf *dispatch_buf;
>      int n;
>  
> +    g_object_get(dev, "spice-server", &reds, NULL);
> +    g_assert(RED_CHAR_DEVICE(reds->agent_dev) == sin->st);
>      if (!reds->vdagent) {
>          return NULL;
>      }