Introduce WriteBufferOrigin enum typedef

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@redhat.com>
This commit is contained in:
Christophe Fergeau 2017-04-10 11:21:03 +02:00
parent 113b7c8f5e
commit df43483f71

View File

@ -31,10 +31,17 @@
#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 {
RedClient *client; /* The client that sent the message to the device.
NULL if the server created the message */
int origin;
WriteBufferOrigin origin;
uint32_t token_price;
uint32_t refs;
};
@ -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))
@ -535,7 +534,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;
@ -655,7 +654,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;