summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathon Jongsma <jjongsma@redhat.com>2016-10-11 17:28:58 -0500
committerFrediano Ziglio <fziglio@redhat.com>2016-10-14 11:49:25 +0100
commitefe49fa275dfb6140d6d9e7f7bed499c8d46211a (patch)
tree20dd05dc924987d4942f809756ff7041925666fb
parentbcb8503659ce281d1a07fc506df9dc8830b03775 (diff)
Use macros for casting Channel types
In preparation for converting RedChannel to GObject, switch to using RED_CHANNEL()-type macros for casting. For now they just do a regular cast, but it helps reduce the size of the GObject patch to make it easier to review. Acked-by: Frediano Ziglio <fziglio@redhat.com>
-rw-r--r--server/common-graphics-channel.c2
-rw-r--r--server/cursor-channel.c8
-rw-r--r--server/display-channel.c4
-rw-r--r--server/display-channel.h2
-rw-r--r--server/inputs-channel-client.c2
-rw-r--r--server/inputs-channel.c18
-rw-r--r--server/inputs-channel.h2
-rw-r--r--server/main-channel.c2
-rw-r--r--server/main-channel.h2
9 files changed, 25 insertions, 17 deletions
diff --git a/server/common-graphics-channel.c b/server/common-graphics-channel.c
index 625162c4..bcf72792 100644
--- a/server/common-graphics-channel.c
+++ b/server/common-graphics-channel.c
@@ -122,7 +122,7 @@ CommonGraphicsChannel* common_graphics_channel_new(RedsState *server,
migration_flags);
spice_return_val_if_fail(channel, NULL);
- common = (CommonGraphicsChannel *)channel;
+ common = COMMON_GRAPHICS_CHANNEL(channel);
common->qxl = qxl;
return common;
}
diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index d064ee38..a4d5b589 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -28,6 +28,8 @@
#include "reds.h"
#include "red-qxl.h"
+#define CURSOR_CHANNEL(channel) ((CursorChannel*)(channel))
+
enum {
RED_PIPE_ITEM_TYPE_CURSOR = RED_PIPE_ITEM_TYPE_COMMON_LAST,
RED_PIPE_ITEM_TYPE_CURSOR_INIT,
@@ -170,7 +172,7 @@ static void cursor_fill(CursorChannelClient *ccc, SpiceCursor *red_cursor,
void cursor_channel_disconnect(CursorChannel *cursor_channel)
{
- RedChannel *channel = (RedChannel *)cursor_channel;
+ RedChannel *channel = RED_CHANNEL(cursor_channel);
if (!channel || !red_channel_is_connected(channel)) {
return;
@@ -198,7 +200,7 @@ static void red_marshall_cursor_init(CursorChannelClient *ccc, SpiceMarshaller *
AddBufInfo info;
spice_assert(rcc);
- cursor_channel = (CursorChannel*)red_channel_client_get_channel(rcc);
+ cursor_channel = CURSOR_CHANNEL(red_channel_client_get_channel(rcc));
red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_INIT, NULL);
msg.visible = cursor_channel->priv->cursor_visible;
@@ -324,7 +326,7 @@ CursorChannel* cursor_channel_new(RedsState *server, QXLInstance *qxl,
SPICE_CHANNEL_CURSOR, 0,
&cbs, red_channel_client_handle_message);
- cursor_channel = (CursorChannel *)channel;
+ cursor_channel = CURSOR_CHANNEL(channel);
cursor_channel->priv->cursor_visible = TRUE;
cursor_channel->priv->mouse_mode = SPICE_MOUSE_MODE_SERVER;
diff --git a/server/display-channel.c b/server/display-channel.c
index 93744a43..b9e2b931 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -1924,10 +1924,10 @@ DisplayChannel* display_channel_new(RedsState *reds,
};
spice_info("create display channel");
- display = (DisplayChannel *)common_graphics_channel_new(
+ display = DISPLAY_CHANNEL(common_graphics_channel_new(
reds, qxl, core, sizeof(*display), SPICE_CHANNEL_DISPLAY,
SPICE_MIGRATE_NEED_FLUSH | SPICE_MIGRATE_NEED_DATA_TRANSFER,
- &cbs, dcc_handle_message);
+ &cbs, dcc_handle_message));
spice_return_val_if_fail(display, NULL);
display->priv->pub = display;
diff --git a/server/display-channel.h b/server/display-channel.h
index 936768ea..3762e54e 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -45,6 +45,8 @@
#include "image-encoders.h"
#include "common-graphics-channel.h"
+#define DISPLAY_CHANNEL(channel) ((DisplayChannel*)(channel))
+
typedef struct DependItem {
Drawable *drawable;
RingItem ring_item;
diff --git a/server/inputs-channel-client.c b/server/inputs-channel-client.c
index 76de3820..4ab24574 100644
--- a/server/inputs-channel-client.c
+++ b/server/inputs-channel-client.c
@@ -110,7 +110,7 @@ void inputs_channel_client_handle_migrate_data(InputsChannelClient *icc,
void inputs_channel_client_on_mouse_motion(InputsChannelClient *icc)
{
- InputsChannel *inputs_channel = (InputsChannel *)red_channel_client_get_channel(RED_CHANNEL_CLIENT(icc));
+ InputsChannel *inputs_channel = INPUTS_CHANNEL(red_channel_client_get_channel(RED_CHANNEL_CLIENT(icc)));
if (++icc->priv->motion_count % SPICE_INPUT_MOTION_ACK_BUNCH == 0 &&
!inputs_channel_is_src_during_migrate(inputs_channel)) {
diff --git a/server/inputs-channel.c b/server/inputs-channel.c
index 840d5e9d..85ca155d 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -151,7 +151,7 @@ static uint8_t *inputs_channel_alloc_msg_rcv_buf(RedChannelClient *rcc,
uint16_t type,
uint32_t size)
{
- InputsChannel *inputs_channel = (InputsChannel*)red_channel_client_get_channel(rcc);
+ InputsChannel *inputs_channel = INPUTS_CHANNEL(red_channel_client_get_channel(rcc));
if (size > RECEIVE_BUF_SIZE) {
spice_printerr("error: too large incoming message");
@@ -259,7 +259,7 @@ static void inputs_channel_send_item(RedChannelClient *rcc, RedPipeItem *base)
red_channel_client_init_send_data(rcc, SPICE_MSG_INPUTS_MOUSE_MOTION_ACK, base);
break;
case RED_PIPE_ITEM_MIGRATE_DATA:
- ((InputsChannel*)red_channel_client_get_channel(rcc))->src_during_migrate = FALSE;
+ INPUTS_CHANNEL(red_channel_client_get_channel(rcc))->src_during_migrate = FALSE;
inputs_channel_client_send_migrate_data(rcc, m, base);
break;
default:
@@ -272,7 +272,7 @@ static void inputs_channel_send_item(RedChannelClient *rcc, RedPipeItem *base)
static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint16_t type,
void *message)
{
- InputsChannel *inputs_channel = (InputsChannel *)red_channel_client_get_channel(rcc);
+ InputsChannel *inputs_channel = INPUTS_CHANNEL(red_channel_client_get_channel(rcc));
InputsChannelClient *icc = INPUTS_CHANNEL_CLIENT(rcc);
uint32_t i;
RedsState *reds = red_channel_get_server(&inputs_channel->base);
@@ -458,13 +458,13 @@ static void inputs_channel_on_disconnect(RedChannelClient *rcc)
if (!rcc) {
return;
}
- inputs_release_keys((InputsChannel*)red_channel_client_get_channel(rcc));
+ inputs_release_keys(INPUTS_CHANNEL(red_channel_client_get_channel(rcc)));
}
static void inputs_pipe_add_init(RedChannelClient *rcc)
{
RedInputsInitPipeItem *item = spice_malloc(sizeof(RedInputsInitPipeItem));
- InputsChannel *inputs = (InputsChannel*)red_channel_client_get_channel(rcc);
+ InputsChannel *inputs = INPUTS_CHANNEL(red_channel_client_get_channel(rcc));
red_pipe_item_init(&item->base, RED_PIPE_ITEM_INPUTS_INIT);
item->modifiers = kbd_get_leds(inputs_channel_get_keyboard(inputs));
@@ -511,7 +511,7 @@ static void inputs_connect(RedChannel *channel, RedClient *client,
static void inputs_migrate(RedChannelClient *rcc)
{
- InputsChannel *inputs = (InputsChannel*)red_channel_client_get_channel(rcc);
+ InputsChannel *inputs = INPUTS_CHANNEL(red_channel_client_get_channel(rcc));
inputs->src_during_migrate = TRUE;
red_channel_client_default_migrate(rcc);
}
@@ -548,7 +548,7 @@ static int inputs_channel_handle_migrate_data(RedChannelClient *rcc,
void *message)
{
InputsChannelClient *icc = INPUTS_CHANNEL_CLIENT(rcc);
- InputsChannel *inputs = (InputsChannel*)red_channel_client_get_channel(rcc);
+ InputsChannel *inputs = INPUTS_CHANNEL(red_channel_client_get_channel(rcc));
SpiceMigrateDataHeader *header;
SpiceMigrateDataInputs *mig_data;
@@ -580,7 +580,7 @@ InputsChannel* inputs_channel_new(RedsState *reds)
channel_cbs.handle_migrate_data = inputs_channel_handle_migrate_data;
channel_cbs.handle_migrate_flush_mark = inputs_channel_handle_migrate_flush_mark;
- inputs = (InputsChannel *)red_channel_create_parser(
+ inputs = INPUTS_CHANNEL(red_channel_create_parser(
sizeof(InputsChannel),
reds,
reds_get_core_interface(reds),
@@ -589,7 +589,7 @@ InputsChannel* inputs_channel_new(RedsState *reds)
spice_get_client_channel_parser(SPICE_CHANNEL_INPUTS, NULL),
inputs_channel_handle_parsed,
&channel_cbs,
- SPICE_MIGRATE_NEED_FLUSH | SPICE_MIGRATE_NEED_DATA_TRANSFER);
+ SPICE_MIGRATE_NEED_FLUSH | SPICE_MIGRATE_NEED_DATA_TRANSFER));
if (!inputs) {
spice_error("failed to allocate Inputs Channel");
diff --git a/server/inputs-channel.h b/server/inputs-channel.h
index e8f92ccf..ae84eed1 100644
--- a/server/inputs-channel.h
+++ b/server/inputs-channel.h
@@ -26,6 +26,8 @@
#include "red-channel.h"
+#define INPUTS_CHANNEL(channel) ((InputsChannel*)(channel))
+
typedef struct InputsChannel InputsChannel;
InputsChannel* inputs_channel_new(RedsState *reds);
diff --git a/server/main-channel.c b/server/main-channel.c
index bf84694b..a1b8e319 100644
--- a/server/main-channel.c
+++ b/server/main-channel.c
@@ -329,7 +329,7 @@ MainChannel* main_channel_new(RedsState *reds)
client_cbs.migrate = main_channel_client_migrate;
red_channel_register_client_cbs(channel, &client_cbs, NULL);
- return (MainChannel *)channel;
+ return MAIN_CHANNEL(channel);
}
static int main_channel_connect_semi_seamless(MainChannel *main_channel)
diff --git a/server/main-channel.h b/server/main-channel.h
index 868a14af..e0858d0c 100644
--- a/server/main-channel.h
+++ b/server/main-channel.h
@@ -25,6 +25,8 @@
#include "red-channel.h"
#include "main-channel-client.h"
+#define MAIN_CHANNEL(channel) ((MainChannel*)(channel))
+
// TODO: Defines used to calculate receive buffer size, and also by reds.c
// other options: is to make a reds_main_consts.h, to duplicate defines.
#define REDS_AGENT_WINDOW_SIZE 10