[Spice-devel] [spice-server v2 6/6] Introduce WriteBufferOrigin enum typedef
Christophe Fergeau
cfergeau at redhat.com
Fri Apr 28 09:11:02 UTC 2017
This use to be an anonymous enum, used as an int in
RedCharDeviceWriteBufferPrivate::origin.
Introducing a typedef clarifies what kind of value it's holding.
Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
---
server/char-device.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/server/char-device.c b/server/char-device.c
index 481ea2a13..43e8d544d 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -31,8 +31,15 @@
#define RED_CHAR_DEVICE_WAIT_TOKENS_TIMEOUT 30000
#define MAX_POOL_SIZE (10 * 64 * 1024)
+typedef enum {
+ WRITE_BUFFER_ORIGIN_NONE,
+ WRITE_BUFFER_ORIGIN_CLIENT,
+ WRITE_BUFFER_ORIGIN_SERVER,
+ WRITE_BUFFER_ORIGIN_SERVER_NO_TOKEN,
+} WriteBufferOrigin;
+
struct RedCharDeviceWriteBufferPrivate {
- int origin;
+ WriteBufferOrigin origin;
RedClient *client; /* The client that sent the message to the device.
NULL if the server created the message */
uint32_t token_price;
@@ -77,14 +84,6 @@ struct RedCharDevicePrivate {
SpiceServer *reds;
};
-enum {
- WRITE_BUFFER_ORIGIN_NONE,
- WRITE_BUFFER_ORIGIN_CLIENT,
- WRITE_BUFFER_ORIGIN_SERVER,
- WRITE_BUFFER_ORIGIN_SERVER_NO_TOKEN,
-};
-
-
G_DEFINE_TYPE(RedCharDevice, red_char_device, G_TYPE_OBJECT)
#define RED_CHAR_DEVICE_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RED_TYPE_CHAR_DEVICE, RedCharDevicePrivate))
@@ -536,7 +535,7 @@ static void red_char_device_write_retry(void *opaque)
static RedCharDeviceWriteBuffer *__red_char_device_write_buffer_get(
RedCharDevice *dev, RedClient *client,
- int size, int origin, int migrated_data_tokens)
+ int size, WriteBufferOrigin origin, int migrated_data_tokens)
{
RedCharDeviceWriteBuffer *ret;
@@ -651,7 +650,7 @@ void red_char_device_write_buffer_release(RedCharDevice *dev,
}
*p_write_buf = NULL;
- int buf_origin = write_buf->priv->origin;
+ WriteBufferOrigin buf_origin = write_buf->priv->origin;
uint32_t buf_token_price = write_buf->priv->token_price;
RedClient *client = write_buf->priv->client;
--
2.12.2
More information about the Spice-devel
mailing list