[PATCH 07/11] make red_pipe_item_unref more typesafe

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

 



Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/char-device.c   |  2 +-
 server/red-pipe-item.c |  4 +---
 server/red-pipe-item.h |  2 +-
 server/reds.c          | 12 +++++-------
 4 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/server/char-device.c b/server/char-device.c
index b67e192..4a6e4c8 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -189,7 +189,7 @@ static void red_char_device_client_free(RedCharDevice *dev,
         dev_client->wait_for_tokens_timer = NULL;
     }
 
-    g_queue_free_full(dev_client->send_queue, red_pipe_item_unref);
+    g_queue_free_full(dev_client->send_queue, (GDestroyNotify)red_pipe_item_unref);
 
     /* remove write buffers that are associated with the client */
     spice_debug("write_queue_is_empty %d", ring_is_empty(&dev->priv->write_queue) && !dev->priv->cur_write_buf);
diff --git a/server/red-pipe-item.c b/server/red-pipe-item.c
index 74bf267..31262fa 100644
--- a/server/red-pipe-item.c
+++ b/server/red-pipe-item.c
@@ -29,10 +29,8 @@ RedPipeItem *red_pipe_item_ref(RedPipeItem *item)
     return item;
 }
 
-void red_pipe_item_unref(gpointer object)
+void red_pipe_item_unref(RedPipeItem *item)
 {
-    RedPipeItem *item = object;
-
     g_return_if_fail(item->refcount > 0);
 
     if (g_atomic_int_dec_and_test(&item->refcount)) {
diff --git a/server/red-pipe-item.h b/server/red-pipe-item.h
index 0138216..bf13b0b 100644
--- a/server/red-pipe-item.h
+++ b/server/red-pipe-item.h
@@ -37,7 +37,7 @@ typedef struct RedPipeItem {
 
 void red_pipe_item_init_full(RedPipeItem *item, int type, red_pipe_item_free_t free_func);
 RedPipeItem *red_pipe_item_ref(RedPipeItem *item);
-void red_pipe_item_unref(gpointer item);
+void red_pipe_item_unref(RedPipeItem *item);
 
 static inline int red_pipe_item_is_linked(RedPipeItem *item)
 {
diff --git a/server/reds.c b/server/reds.c
index 8ea6098..74de7d5 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -523,7 +523,7 @@ static void reds_reset_vdp(RedsState *reds)
     dev->priv->receive_len = sizeof(dev->priv->vdi_chunk_header);
     dev->priv->message_receive_len = 0;
     if (dev->priv->current_read_buf) {
-        red_pipe_item_unref(dev->priv->current_read_buf);
+        red_pipe_item_unref(&dev->priv->current_read_buf->parent);
         dev->priv->current_read_buf = NULL;
     }
     /* Reset read filter to start with clean state when the agent reconnects */
@@ -747,9 +747,7 @@ static void reds_agent_remove(RedsState *reds)
 
 static void vdi_port_read_buf_release(uint8_t *data, void *opaque)
 {
-    RedVDIReadBuf *buf = (RedVDIReadBuf *)opaque;
-
-    red_pipe_item_unref(buf);
+    red_pipe_item_unref((RedPipeItem *)opaque);
 }
 
 /* returns TRUE if the buffer can be forwarded */
@@ -895,7 +893,7 @@ static RedPipeItem *vdi_port_read_one_msg_from_device(SpiceCharDeviceInstance *s
                 if (error) {
                     reds_agent_remove(reds);
                 }
-                red_pipe_item_unref(dispatch_buf);
+                red_pipe_item_unref(&dispatch_buf->parent);
             }
         }
         } /* END switch */
@@ -1273,7 +1271,7 @@ void reds_on_main_channel_migrate(RedsState *reds, MainChannelClient *mcc)
             if (error) {
                reds_agent_remove(reds);
             }
-            red_pipe_item_unref(read_buf);
+            red_pipe_item_unref(&read_buf->parent);
         }
 
         spice_assert(agent_dev->priv->receive_len);
@@ -4353,7 +4351,7 @@ red_char_device_vdi_port_init(RedCharDeviceVDIPort *self)
         /* This ensures the newly created buffer is placed in the
          * RedCharDeviceVDIPort::read_bufs queue ready to be reused
          */
-        red_pipe_item_unref(buf);
+        red_pipe_item_unref(&buf->parent);
     }
 }
 
-- 
2.7.4

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]