[Spice-devel] [spice-server v2 10/14] rcc: Replace 'opaque' arg with typed RedChannelClient

Christophe Fergeau cfergeau at redhat.com
Tue Feb 14 14:17:35 UTC 2017


The methods previously used by OutgoingHandlerInterface and
IncomingHandlerInterface are no longer used as generic callbacks,
but are directly called from RedChannelClient code. We can be explicit
about the type of their first argument (RedChannelClient *) rather than
using a generic void * pointer.

Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
---
 server/red-channel-client.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 8b2434c..d33e756 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -368,9 +368,8 @@ RedChannel* red_channel_client_get_channel(RedChannelClient *rcc)
     return rcc->priv->channel;
 }
 
-static void red_channel_client_data_sent(void *opaque, int n)
+static void red_channel_client_data_sent(RedChannelClient *rcc, int n)
 {
-    RedChannelClient *rcc = opaque;
     RedChannel *channel = red_channel_client_get_channel(rcc);
 
     if (rcc->priv->connectivity_monitor.timer) {
@@ -380,35 +379,29 @@ static void red_channel_client_data_sent(void *opaque, int n)
     red_channel_on_output(channel, n);
 }
 
-static void red_channel_client_data_read(void *opaque, int n)
+static void red_channel_client_data_read(RedChannelClient *rcc, int n)
 {
-    RedChannelClient *rcc = opaque;
-
     if (rcc->priv->connectivity_monitor.timer) {
         rcc->priv->connectivity_monitor.in_bytes += n;
     }
 }
 
-static int red_channel_client_get_out_msg_size(void *opaque)
+static int red_channel_client_get_out_msg_size(RedChannelClient *rcc)
 {
-    RedChannelClient *rcc = RED_CHANNEL_CLIENT(opaque);
-
     return rcc->priv->send_data.size;
 }
 
-static void red_channel_client_prepare_out_msg(void *opaque, struct iovec *vec,
-                                               int *vec_size, int pos)
+static void red_channel_client_prepare_out_msg(RedChannelClient *rcc,
+                                               struct iovec *vec, int *vec_size,
+                                               int pos)
 {
-    RedChannelClient *rcc = RED_CHANNEL_CLIENT(opaque);
-
     *vec_size = spice_marshaller_fill_iovec(rcc->priv->send_data.marshaller,
                                             vec, IOV_MAX, pos);
 }
 
-static void red_channel_client_set_blocked(void *opaque)
+static void red_channel_client_set_blocked(RedChannelClient *rcc)
 {
     SpiceCoreInterfaceInternal *core;
-    RedChannelClient *rcc = RED_CHANNEL_CLIENT(opaque);
 
     rcc->priv->send_data.blocked = TRUE;
     core = red_channel_get_core_interface(rcc->priv->channel);
@@ -545,9 +538,8 @@ static void red_channel_client_restore_main_sender(RedChannelClient *rcc)
     rcc->priv->send_data.header.data = rcc->priv->send_data.main.header_data;
 }
 
-static void red_channel_client_msg_sent(void *opaque)
+static void red_channel_client_msg_sent(RedChannelClient *rcc)
 {
-    RedChannelClient *rcc = RED_CHANNEL_CLIENT(opaque);
     int fd;
 
     if (spice_marshaller_get_fd(rcc->priv->send_data.marshaller, &fd)) {
-- 
2.9.3



More information about the Spice-devel mailing list