[Spice-devel] [PATCH 06/11] make red_pipe_item_ref more typesafe

Frediano Ziglio fziglio at redhat.com
Fri May 20 13:01:44 UTC 2016


Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/red-pipe-item.c | 4 +---
 server/red-pipe-item.h | 2 +-
 server/reds.c          | 2 +-
 server/spicevmc.c      | 4 ++--
 4 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/server/red-pipe-item.c b/server/red-pipe-item.c
index cc0ab5a..74bf267 100644
--- a/server/red-pipe-item.c
+++ b/server/red-pipe-item.c
@@ -20,10 +20,8 @@
 #include "red-channel.h"
 #include "red-pipe-item.h"
 
-RedPipeItem *red_pipe_item_ref(gpointer object)
+RedPipeItem *red_pipe_item_ref(RedPipeItem *item)
 {
-    RedPipeItem *item = object;
-
     g_return_val_if_fail(item->refcount > 0, NULL);
 
     g_atomic_int_inc(&item->refcount);
diff --git a/server/red-pipe-item.h b/server/red-pipe-item.h
index 4b3d892..0138216 100644
--- a/server/red-pipe-item.h
+++ b/server/red-pipe-item.h
@@ -36,7 +36,7 @@ typedef struct RedPipeItem {
 } RedPipeItem;
 
 void red_pipe_item_init_full(RedPipeItem *item, int type, red_pipe_item_free_t free_func);
-RedPipeItem *red_pipe_item_ref(gpointer item);
+RedPipeItem *red_pipe_item_ref(RedPipeItem *item);
 void red_pipe_item_unref(gpointer item);
 
 static inline int red_pipe_item_is_linked(RedPipeItem *item)
diff --git a/server/reds.c b/server/reds.c
index 8a903b7..8ea6098 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -910,7 +910,7 @@ static void vdi_port_send_msg_to_client(RedPipeItem *msg,
 {
     RedVDIReadBuf *agent_data_buf = (RedVDIReadBuf *)msg;
 
-    red_pipe_item_ref(agent_data_buf);
+    red_pipe_item_ref(msg);
     main_channel_client_push_agent_data(red_client_get_main(client),
                                         agent_data_buf->data,
                                         agent_data_buf->len,
diff --git a/server/spicevmc.c b/server/spicevmc.c
index 1e68909..f46b9e5 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -145,10 +145,10 @@ static void spicevmc_chardev_send_msg_to_client(RedPipeItem *msg,
                                                 void *opaque)
 {
     SpiceVmcState *state = opaque;
-    RedVmcPipeItem *vmc_msg = (RedVmcPipeItem *)msg;
+    RedVmcPipeItem *vmc_msg = SPICE_CONTAINEROF(msg, RedVmcPipeItem, base);
 
     spice_assert(state->rcc->client == client);
-    red_pipe_item_ref(vmc_msg);
+    red_pipe_item_ref(msg);
     red_channel_client_pipe_add_push(state->rcc, (RedPipeItem *)vmc_msg);
 }
 
-- 
2.7.4



More information about the Spice-devel mailing list