[Spice-devel] [spice-server 1/2] reds: Move RedsState typedef to red-common.h

Christophe Fergeau cfergeau at redhat.com
Tue Apr 5 13:37:58 UTC 2016


This allows to stop using struct RedsState * rather than RedsState * in
headers which cannot include reds.h. This also allows to remove the
duplicate RedsState typedef in reds.h and reds-stream.h which is causing
issues with older gcc versions.
---
 server/char-device.h  |  8 +++-----
 server/main-channel.h |  4 +---
 server/red-channel.h  | 14 ++++++--------
 server/red-common.h   |  2 ++
 server/reds-stream.h  |  2 +-
 server/reds.h         |  2 --
 6 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/server/char-device.h b/server/char-device.h
index 0a4ae5d..88961cc 100644
--- a/server/char-device.h
+++ b/server/char-device.h
@@ -119,8 +119,6 @@ void red_char_device_set_callbacks(RedCharDevice *dev,
  *
  * */
 
-struct RedsState;
-
 /* buffer that is used for writing to the device */
 typedef struct RedCharDeviceWriteBuffer {
     RingItem link;
@@ -170,7 +168,7 @@ struct RedCharDeviceCallbacks {
 };
 
 RedCharDevice *red_char_device_create(SpiceCharDeviceInstance *sin,
-                                      struct RedsState *reds,
+                                      RedsState *reds,
                                       uint32_t client_tokens_interval,
                                       uint32_t self_tokens,
                                       RedCharDeviceCallbacks *cbs,
@@ -253,10 +251,10 @@ void red_char_device_write_buffer_release(RedCharDevice *dev,
 
 /* api for specific char devices */
 
-RedCharDevice *spicevmc_device_connect(struct RedsState *reds,
+RedCharDevice *spicevmc_device_connect(RedsState *reds,
                                        SpiceCharDeviceInstance *sin,
                                        uint8_t channel_type);
-void spicevmc_device_disconnect(struct RedsState *reds,
+void spicevmc_device_disconnect(RedsState *reds,
                                 SpiceCharDeviceInstance *char_device);
 
 SpiceCharDeviceInterface *spice_char_device_get_interface(SpiceCharDeviceInstance *instance);
diff --git a/server/main-channel.h b/server/main-channel.h
index 26e2129..fd16c94 100644
--- a/server/main-channel.h
+++ b/server/main-channel.h
@@ -32,8 +32,6 @@
 #define MAIN_CHANNEL_RECEIVE_BUF_SIZE \
     (4096 + (REDS_AGENT_WINDOW_SIZE + REDS_NUM_INTERNAL_AGENT_MESSAGES) * SPICE_AGENT_MAX_DATA_SIZE)
 
-struct RedsState;
-
 struct RedsMigSpice {
     char *host;
     char *cert_subject;
@@ -50,7 +48,7 @@ typedef struct MainChannel {
 } MainChannel;
 
 
-MainChannel *main_channel_new(struct RedsState *reds);
+MainChannel *main_channel_new(RedsState *reds);
 RedClient *main_channel_get_client_by_link_id(MainChannel *main_chan, uint32_t link_id);
 /* This is a 'clone' from the reds.h Channel.link callback to allow passing link_id */
 MainChannelClient *main_channel_link(MainChannel *, RedClient *client,
diff --git a/server/red-channel.h b/server/red-channel.h
index c3aeda6..94b09eb 100644
--- a/server/red-channel.h
+++ b/server/red-channel.h
@@ -47,8 +47,6 @@
    The intention is to move towards one channel interface gradually.
    At the final stage, this interface shouldn't be exposed. Only RedChannel will use it. */
 
-struct RedsState;
-
 typedef struct SpiceDataHeaderOpaque SpiceDataHeaderOpaque;
 
 typedef uint16_t (*get_msg_type_proc)(SpiceDataHeaderOpaque *header);
@@ -339,7 +337,7 @@ struct RedChannel {
 
     // TODO: when different channel_clients are in different threads from Channel -> need to protect!
     pthread_t thread_id;
-    struct RedsState *reds;
+    RedsState *reds;
 #ifdef RED_STATISTICS
     StatNodeRef stat;
     uint64_t *out_bytes_counter;
@@ -362,7 +360,7 @@ struct RedChannel {
 /* if one of the callbacks should cause disconnect, use red_channel_shutdown and don't
  * explicitly destroy the channel */
 RedChannel *red_channel_create(int size,
-                               struct RedsState *reds,
+                               RedsState *reds,
                                const SpiceCoreInterfaceInternal *core,
                                uint32_t type, uint32_t id,
                                int handle_acks,
@@ -373,7 +371,7 @@ RedChannel *red_channel_create(int size,
 /* alternative constructor, meant for marshaller based (inputs,main) channels,
  * will become default eventually */
 RedChannel *red_channel_create_parser(int size,
-                                      struct RedsState *reds,
+                                      RedsState *reds,
                                       const SpiceCoreInterfaceInternal *core,
                                       uint32_t type, uint32_t id,
                                       int handle_acks,
@@ -396,7 +394,7 @@ RedChannelClient *red_channel_client_create(int size, RedChannel *channel, RedCl
 // TODO: tmp, for channels that don't use RedChannel yet (e.g., snd channel), but
 // do use the client callbacks. So the channel clients are not connected (the channel doesn't
 // have list of them, but they do have a link to the channel, and the client has a list of them)
-RedChannel *red_channel_create_dummy(int size, struct RedsState *reds, uint32_t type, uint32_t id);
+RedChannel *red_channel_create_dummy(int size, RedsState *reds, uint32_t type, uint32_t id);
 RedChannelClient *red_channel_client_create_dummy(int size,
                                                   RedChannel *channel,
                                                   RedClient  *client,
@@ -569,7 +567,7 @@ void red_channel_apply_clients(RedChannel *channel, channel_client_callback v);
 struct RedsState* red_channel_get_server(RedChannel *channel);
 
 struct RedClient {
-    struct RedsState *reds;
+    RedsState *reds;
     RingItem link;
     Ring channels;
     int channels_num;
@@ -591,7 +589,7 @@ struct RedClient {
     int refs;
 };
 
-RedClient *red_client_new(struct RedsState *reds, int migrated);
+RedClient *red_client_new(RedsState *reds, int migrated);
 
 /*
  * disconnects all the client's channels (should be called from the client's thread)
diff --git a/server/red-common.h b/server/red-common.h
index 90a7d20..a9339fb 100644
--- a/server/red-common.h
+++ b/server/red-common.h
@@ -58,4 +58,6 @@ struct SpiceCoreInterfaceInternal {
 
 extern SpiceCoreInterfaceInternal event_loop_core;
 
+typedef struct RedsState RedsState;
+
 #endif
diff --git a/server/reds-stream.h b/server/reds-stream.h
index 1123048..705d7fd 100644
--- a/server/reds-stream.h
+++ b/server/reds-stream.h
@@ -20,6 +20,7 @@
 
 #include "spice.h"
 #include "common/mem.h"
+#include "red-common.h"
 
 #include <stdbool.h>
 
@@ -28,7 +29,6 @@
 typedef void (*AsyncReadDone)(void *opaque);
 typedef void (*AsyncReadError)(void *opaque, int err);
 
-typedef struct RedsState RedsState;
 typedef struct RedsStream RedsStream;
 typedef struct RedsStreamPrivate RedsStreamPrivate;
 
diff --git a/server/reds.h b/server/reds.h
index 83618e9..2cfd451 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -32,8 +32,6 @@
 #include "main-dispatcher.h"
 #include "migration-protocol.h"
 
-typedef struct RedsState RedsState;
-
 static inline QXLInterface * qxl_get_interface(QXLInstance *qxl)
 {
     return SPICE_CONTAINEROF(qxl->base.sif, QXLInterface, base);
-- 
2.5.5



More information about the Spice-devel mailing list