summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2016-04-07 17:11:22 -0500
committerJonathon Jongsma <jjongsma@redhat.com>2016-04-15 11:14:36 -0500
commit021d960471559cb1f65cd676c16da6f71bef3352 (patch)
treee3b66858145dafc17258e1ada6fccd68a5ffacab
parent521dd24ffbbfd9ae2864ad3f8dd21126fc60f899 (diff)
char-device: Replace RedCharDeviceMsgToClient with PipeItem
Now that all derived classes use a type deriving from PipeItem for their RedCharDeviceMsgToClient, we can make this explicit in the RedCharDeviceClass vfuncs, and remove the RedCharDeviceMsgToClient typedef.
-rw-r--r--server/char-device.c18
-rw-r--r--server/char-device.h15
-rw-r--r--server/reds.c16
-rw-r--r--server/smartcard.c14
-rw-r--r--server/spicevmc.c16
5 files changed, 38 insertions, 41 deletions
diff --git a/server/char-device.c b/server/char-device.c
index e17e3be1..ce89d379 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -99,10 +99,10 @@ static void red_char_device_write_retry(void *opaque);
typedef struct RedCharDeviceMsgToClientItem {
RingItem link;
- RedCharDeviceMsgToClient *msg;
+ PipeItem *msg;
} RedCharDeviceMsgToClientItem;
-static RedCharDeviceMsgToClient *
+static PipeItem *
red_char_device_read_one_msg_from_device(RedCharDevice *dev)
{
RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
@@ -110,9 +110,9 @@ red_char_device_read_one_msg_from_device(RedCharDevice *dev)
return klass->read_one_msg_from_device(dev->priv->sin, dev->priv->opaque);
}
-static RedCharDeviceMsgToClient *
+static PipeItem *
red_char_device_ref_msg_to_client(RedCharDevice *dev,
- RedCharDeviceMsgToClient *msg)
+ PipeItem *msg)
{
RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
@@ -121,7 +121,7 @@ red_char_device_ref_msg_to_client(RedCharDevice *dev,
static void
red_char_device_unref_msg_to_client(RedCharDevice *dev,
- RedCharDeviceMsgToClient *msg)
+ PipeItem *msg)
{
RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
@@ -130,7 +130,7 @@ red_char_device_unref_msg_to_client(RedCharDevice *dev,
static void
red_char_device_send_msg_to_client(RedCharDevice *dev,
- RedCharDeviceMsgToClient *msg,
+ PipeItem *msg,
RedClient *client)
{
RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
@@ -320,7 +320,7 @@ static uint64_t red_char_device_max_send_tokens(RedCharDevice *dev)
}
static void red_char_device_add_msg_to_client_queue(RedCharDeviceClient *dev_client,
- RedCharDeviceMsgToClient *msg)
+ PipeItem *msg)
{
RedCharDevice *dev = dev_client->dev;
RedCharDeviceMsgToClientItem *msg_item;
@@ -342,7 +342,7 @@ static void red_char_device_add_msg_to_client_queue(RedCharDeviceClient *dev_cli
}
static void red_char_device_send_msg_to_clients(RedCharDevice *dev,
- RedCharDeviceMsgToClient *msg)
+ PipeItem *msg)
{
RingItem *item, *next;
@@ -388,7 +388,7 @@ static int red_char_device_read_from_device(RedCharDevice *dev)
* All messages will be discarded if no client is attached to the device
*/
while ((max_send_tokens || ring_is_empty(&dev->priv->clients)) && dev->priv->running) {
- RedCharDeviceMsgToClient *msg;
+ PipeItem *msg;
msg = red_char_device_read_one_msg_from_device(dev);
if (!msg) {
diff --git a/server/char-device.h b/server/char-device.h
index f4d62836..b5a83837 100644
--- a/server/char-device.h
+++ b/server/char-device.h
@@ -24,8 +24,6 @@
#include "red-channel.h"
#include "migration-protocol.h"
-typedef void RedCharDeviceMsgToClient;
-
#define RED_TYPE_CHAR_DEVICE red_char_device_get_type()
#define RED_CHAR_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), RED_TYPE_CHAR_DEVICE, RedCharDevice))
@@ -58,13 +56,12 @@ struct RedCharDeviceClass
/* reads from the device till reaching a msg that should be sent to the client,
* or till the reading fails */
- RedCharDeviceMsgToClient* (*read_one_msg_from_device)(SpiceCharDeviceInstance *sin,
- void *opaque);
- RedCharDeviceMsgToClient* (*ref_msg_to_client)(RedCharDeviceMsgToClient *msg,
- void *opaque);
- void (*unref_msg_to_client)(RedCharDeviceMsgToClient *msg,
- void *opaque);
- void (*send_msg_to_client)(RedCharDeviceMsgToClient *msg,
+ PipeItem* (*read_one_msg_from_device)(SpiceCharDeviceInstance *sin,
+ void *opaque);
+ PipeItem* (*ref_msg_to_client)(PipeItem *msg, void *opaque);
+ void (*unref_msg_to_client)(PipeItem *msg, void *opaque);
+
+ void (*send_msg_to_client)(PipeItem *msg,
RedClient *client,
void *opaque); /* after this call, the message is unreferenced */
diff --git a/server/reds.c b/server/reds.c
index 521bc842..555b2542 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -783,8 +783,8 @@ static void vdi_port_read_buf_free(VDIReadBuf *buf)
/* reads from the device till completes reading a message that is addressed to the client,
* or otherwise, when reading from the device fails */
-static RedCharDeviceMsgToClient *vdi_port_read_one_msg_from_device(SpiceCharDeviceInstance *sin,
- void *opaque)
+static PipeItem *vdi_port_read_one_msg_from_device(SpiceCharDeviceInstance *sin,
+ void *opaque)
{
RedsState *reds = opaque;
RedCharDeviceVDIPort *dev = reds->agent_dev;
@@ -842,7 +842,7 @@ static RedCharDeviceMsgToClient *vdi_port_read_one_msg_from_device(SpiceCharDevi
dev->priv->read_state = VDI_PORT_READ_STATE_GET_BUFF;
}
if (vdi_port_read_buf_process(reds->agent_dev, dispatch_buf, &error)) {
- return dispatch_buf;
+ return (PipeItem *)dispatch_buf;
} else {
if (error) {
reds_agent_remove(reds);
@@ -855,24 +855,24 @@ static RedCharDeviceMsgToClient *vdi_port_read_one_msg_from_device(SpiceCharDevi
return NULL;
}
-static RedCharDeviceMsgToClient *vdi_port_ref_msg_to_client(RedCharDeviceMsgToClient *msg,
- void *opaque)
+static PipeItem *vdi_port_ref_msg_to_client(PipeItem *msg,
+ void *opaque)
{
return pipe_item_ref(msg);
}
-static void vdi_port_unref_msg_to_client(RedCharDeviceMsgToClient *msg,
+static void vdi_port_unref_msg_to_client(PipeItem *msg,
void *opaque)
{
pipe_item_unref(msg);
}
/* after calling this, we unref the message, and the ref is in the instance side */
-static void vdi_port_send_msg_to_client(RedCharDeviceMsgToClient *msg,
+static void vdi_port_send_msg_to_client(PipeItem *msg,
RedClient *client,
void *opaque)
{
- VDIReadBuf *agent_data_buf = msg;
+ VDIReadBuf *agent_data_buf = (VDIReadBuf *)msg;
pipe_item_ref(agent_data_buf);
main_channel_client_push_agent_data(red_client_get_main(client),
diff --git a/server/smartcard.c b/server/smartcard.c
index 76b07f08..6bdbef50 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -129,8 +129,8 @@ static void smartcard_read_buf_prepare(RedCharDeviceSmartcard *dev, VSCMsgHeader
}
}
-static RedCharDeviceMsgToClient *smartcard_read_msg_from_device(SpiceCharDeviceInstance *sin,
- void *opaque)
+static PipeItem *smartcard_read_msg_from_device(SpiceCharDeviceInstance *sin,
+ void *opaque)
{
RedCharDeviceSmartcard *dev = opaque;
SpiceCharDeviceInterface *sif = spice_char_device_get_interface(sin);
@@ -160,25 +160,25 @@ static RedCharDeviceMsgToClient *smartcard_read_msg_from_device(SpiceCharDeviceI
dev->priv->buf_pos = dev->priv->buf;
dev->priv->buf_used = remaining;
if (msg_to_client) {
- return msg_to_client;
+ return (PipeItem *)msg_to_client;
}
}
return NULL;
}
-static RedCharDeviceMsgToClient *smartcard_ref_msg_to_client(RedCharDeviceMsgToClient *msg,
- void *opaque)
+static PipeItem *smartcard_ref_msg_to_client(PipeItem *msg,
+ void *opaque)
{
return pipe_item_ref(msg);
}
-static void smartcard_unref_msg_to_client(RedCharDeviceMsgToClient *msg,
+static void smartcard_unref_msg_to_client(PipeItem *msg,
void *opaque)
{
pipe_item_ref(msg);
}
-static void smartcard_send_msg_to_client(RedCharDeviceMsgToClient *msg,
+static void smartcard_send_msg_to_client(PipeItem *msg,
RedClient *client,
void *opaque)
{
diff --git a/server/spicevmc.c b/server/spicevmc.c
index 246886c1..3ab067f1 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -105,20 +105,20 @@ enum {
PIPE_ITEM_TYPE_PORT_EVENT,
};
-static RedCharDeviceMsgToClient *spicevmc_chardev_ref_msg_to_client(RedCharDeviceMsgToClient *msg,
- void *opaque)
+static PipeItem *spicevmc_chardev_ref_msg_to_client(PipeItem *msg,
+ void *opaque)
{
return pipe_item_ref(msg);
}
-static void spicevmc_chardev_unref_msg_to_client(RedCharDeviceMsgToClient *msg,
+static void spicevmc_chardev_unref_msg_to_client(PipeItem *msg,
void *opaque)
{
pipe_item_unref(msg);
}
-static RedCharDeviceMsgToClient *spicevmc_chardev_read_msg_from_dev(SpiceCharDeviceInstance *sin,
- void *opaque)
+static PipeItem *spicevmc_chardev_read_msg_from_dev(SpiceCharDeviceInstance *sin,
+ void *opaque)
{
SpiceVmcState *state = opaque;
SpiceCharDeviceInterface *sif;
@@ -145,19 +145,19 @@ static RedCharDeviceMsgToClient *spicevmc_chardev_read_msg_from_dev(SpiceCharDev
if (n > 0) {
spice_debug("read from dev %d", n);
msg_item->buf_used = n;
- return msg_item;
+ return (PipeItem *)msg_item;
} else {
state->pipe_item = msg_item;
return NULL;
}
}
-static void spicevmc_chardev_send_msg_to_client(RedCharDeviceMsgToClient *msg,
+static void spicevmc_chardev_send_msg_to_client(PipeItem *msg,
RedClient *client,
void *opaque)
{
SpiceVmcState *state = opaque;
- SpiceVmcPipeItem *vmc_msg = msg;
+ SpiceVmcPipeItem *vmc_msg = (SpiceVmcPipeItem *)msg;
spice_assert(state->rcc->client == client);
pipe_item_ref(vmc_msg);