Re: [Spice-devel] [PATCH 4/4] spicevmc: use 'channel' instead of 'state'
> > After renaming the object to RedVmcChannel, the local variables still > used the old 'state' terminology. Changing these variables to 'channel' > makes things a bit more consistent. > --- > server/spicevmc.c | 146 > +++--- > 1 file changed, 73 insertions(+), 73 deletions(-) > > diff --git a/server/spicevmc.c b/server/spicevmc.c > index 49de9cc..664896c 100644 > --- a/server/spicevmc.c > +++ b/server/spicevmc.c > @@ -328,12 +328,12 @@ static void > spicevmc_red_channel_release_msg_rcv_buf(RedChannelClient *rcc, > * - a new pipe item with the compressed data in it upon success > */ > #ifdef USE_LZ4 > -static RedVmcPipeItem* try_compress_lz4(RedVmcChannel *state, int n, > RedVmcPipeItem *msg_item) > +static RedVmcPipeItem* try_compress_lz4(RedVmcChannel *channel, int n, > RedVmcPipeItem *msg_item) > { > RedVmcPipeItem *msg_item_compressed; > int compressed_data_count; > > -if (reds_stream_get_family(red_channel_client_get_stream(state->rcc)) == > AF_UNIX) { > +if (reds_stream_get_family(red_channel_client_get_stream(channel->rcc)) > == AF_UNIX) { > /* AF_LOCAL - data will not be compressed */ > return NULL; > } > @@ -341,7 +341,7 @@ static RedVmcPipeItem* try_compress_lz4(RedVmcChannel > *state, int n, RedVmcPipeI > /* n <= threshold - data will not be compressed */ > return NULL; > } > -if (!red_channel_test_remote_cap(RED_CHANNEL(state), > SPICE_SPICEVMC_CAP_DATA_COMPRESS_LZ4)) { > +if (!red_channel_test_remote_cap(RED_CHANNEL(channel), > SPICE_SPICEVMC_CAP_DATA_COMPRESS_LZ4)) { > /* Client doesn't have compression cap - data will not be compressed > */ > return NULL; > } > @@ -370,25 +370,25 @@ static RedPipeItem > *spicevmc_chardev_read_msg_from_dev(RedCharDevice *self, > > SpiceCharDeviceInstance > *sin) > { > RedCharDeviceSpiceVmc *vmc = RED_CHAR_DEVICE_SPICEVMC(self); > -RedVmcChannel *state = RED_VMC_CHANNEL(vmc->channel); > +RedVmcChannel *channel = RED_VMC_CHANNEL(vmc->channel); > SpiceCharDeviceInterface *sif; > RedVmcPipeItem *msg_item; > int n; > > sif = spice_char_device_get_interface(sin); > > -if (!state->rcc) { > +if (!channel->rcc) { > return NULL; > } > > -if (!state->pipe_item) { > +if (!channel->pipe_item) { > msg_item = spice_new0(RedVmcPipeItem, 1); > msg_item->type = SPICE_DATA_COMPRESSION_TYPE_NONE; > red_pipe_item_init(_item->base, > RED_PIPE_ITEM_TYPE_SPICEVMC_DATA); > } else { > -spice_assert(state->pipe_item->buf_used == 0); > -msg_item = state->pipe_item; > -state->pipe_item = NULL; > +spice_assert(channel->pipe_item->buf_used == 0); > +msg_item = channel->pipe_item; > +channel->pipe_item = NULL; > } > > n = sif->read(sin, msg_item->buf, > @@ -398,7 +398,7 @@ static RedPipeItem > *spicevmc_chardev_read_msg_from_dev(RedCharDevice *self, > #ifdef USE_LZ4 > RedVmcPipeItem *msg_item_compressed; > > -msg_item_compressed = try_compress_lz4(state, n, msg_item); > +msg_item_compressed = try_compress_lz4(channel, n, msg_item); > if (msg_item_compressed != NULL) { > return _item_compressed->base; > } > @@ -407,7 +407,7 @@ static RedPipeItem > *spicevmc_chardev_read_msg_from_dev(RedCharDevice *self, > msg_item->buf_used = n; > return _item->base; > } else { > -state->pipe_item = msg_item; > +channel->pipe_item = msg_item; > return NULL; > } > } > @@ -417,24 +417,24 @@ static void > spicevmc_chardev_send_msg_to_client(RedCharDevice *self, > RedClient *client) > { > RedCharDeviceSpiceVmc *vmc = RED_CHAR_DEVICE_SPICEVMC(self); > -RedVmcChannel *state = RED_VMC_CHANNEL(vmc->channel); > +RedVmcChannel *channel = RED_VMC_CHANNEL(vmc->channel); > > -spice_assert(red_channel_client_get_client(state->rcc) == client); > +spice_assert(red_channel_client_get_client(channel->rcc) == client); > red_pipe_item_ref(msg); > -red_channel_client_pipe_add_push(state->rcc, msg); > +red_channel_client_pipe_add_push(channel->rcc, msg); > } > > static void spicevmc_port_send_init(RedChannelClient *rcc) > { > -RedVmcChannel *state = > RED_VMC_CHANNEL(red_channel_client_get_channel(rcc)); > +RedVmcChannel *channel = > RED_VMC_CHANNEL(red_channel_client_get_channel(rcc)); > SpiceCharDeviceInstance *sin; > RedPortInitPipeItem *item = spice_malloc(sizeof(RedPortInitPipeItem)); > > -g_object_get(state->chardev, "sin", , NULL); > +g_object_get(channel->chardev, "sin", , NULL); > > red_pipe_item_init(>base, RED_PIPE_ITEM_TYPE_PORT_INIT); >
[Spice-devel] [PATCH 4/4] spicevmc: use 'channel' instead of 'state'
After renaming the object to RedVmcChannel, the local variables still used the old 'state' terminology. Changing these variables to 'channel' makes things a bit more consistent. --- server/spicevmc.c | 146 +++--- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/server/spicevmc.c b/server/spicevmc.c index 49de9cc..664896c 100644 --- a/server/spicevmc.c +++ b/server/spicevmc.c @@ -328,12 +328,12 @@ static void spicevmc_red_channel_release_msg_rcv_buf(RedChannelClient *rcc, * - a new pipe item with the compressed data in it upon success */ #ifdef USE_LZ4 -static RedVmcPipeItem* try_compress_lz4(RedVmcChannel *state, int n, RedVmcPipeItem *msg_item) +static RedVmcPipeItem* try_compress_lz4(RedVmcChannel *channel, int n, RedVmcPipeItem *msg_item) { RedVmcPipeItem *msg_item_compressed; int compressed_data_count; -if (reds_stream_get_family(red_channel_client_get_stream(state->rcc)) == AF_UNIX) { +if (reds_stream_get_family(red_channel_client_get_stream(channel->rcc)) == AF_UNIX) { /* AF_LOCAL - data will not be compressed */ return NULL; } @@ -341,7 +341,7 @@ static RedVmcPipeItem* try_compress_lz4(RedVmcChannel *state, int n, RedVmcPipeI /* n <= threshold - data will not be compressed */ return NULL; } -if (!red_channel_test_remote_cap(RED_CHANNEL(state), SPICE_SPICEVMC_CAP_DATA_COMPRESS_LZ4)) { +if (!red_channel_test_remote_cap(RED_CHANNEL(channel), SPICE_SPICEVMC_CAP_DATA_COMPRESS_LZ4)) { /* Client doesn't have compression cap - data will not be compressed */ return NULL; } @@ -370,25 +370,25 @@ static RedPipeItem *spicevmc_chardev_read_msg_from_dev(RedCharDevice *self, SpiceCharDeviceInstance *sin) { RedCharDeviceSpiceVmc *vmc = RED_CHAR_DEVICE_SPICEVMC(self); -RedVmcChannel *state = RED_VMC_CHANNEL(vmc->channel); +RedVmcChannel *channel = RED_VMC_CHANNEL(vmc->channel); SpiceCharDeviceInterface *sif; RedVmcPipeItem *msg_item; int n; sif = spice_char_device_get_interface(sin); -if (!state->rcc) { +if (!channel->rcc) { return NULL; } -if (!state->pipe_item) { +if (!channel->pipe_item) { msg_item = spice_new0(RedVmcPipeItem, 1); msg_item->type = SPICE_DATA_COMPRESSION_TYPE_NONE; red_pipe_item_init(_item->base, RED_PIPE_ITEM_TYPE_SPICEVMC_DATA); } else { -spice_assert(state->pipe_item->buf_used == 0); -msg_item = state->pipe_item; -state->pipe_item = NULL; +spice_assert(channel->pipe_item->buf_used == 0); +msg_item = channel->pipe_item; +channel->pipe_item = NULL; } n = sif->read(sin, msg_item->buf, @@ -398,7 +398,7 @@ static RedPipeItem *spicevmc_chardev_read_msg_from_dev(RedCharDevice *self, #ifdef USE_LZ4 RedVmcPipeItem *msg_item_compressed; -msg_item_compressed = try_compress_lz4(state, n, msg_item); +msg_item_compressed = try_compress_lz4(channel, n, msg_item); if (msg_item_compressed != NULL) { return _item_compressed->base; } @@ -407,7 +407,7 @@ static RedPipeItem *spicevmc_chardev_read_msg_from_dev(RedCharDevice *self, msg_item->buf_used = n; return _item->base; } else { -state->pipe_item = msg_item; +channel->pipe_item = msg_item; return NULL; } } @@ -417,24 +417,24 @@ static void spicevmc_chardev_send_msg_to_client(RedCharDevice *self, RedClient *client) { RedCharDeviceSpiceVmc *vmc = RED_CHAR_DEVICE_SPICEVMC(self); -RedVmcChannel *state = RED_VMC_CHANNEL(vmc->channel); +RedVmcChannel *channel = RED_VMC_CHANNEL(vmc->channel); -spice_assert(red_channel_client_get_client(state->rcc) == client); +spice_assert(red_channel_client_get_client(channel->rcc) == client); red_pipe_item_ref(msg); -red_channel_client_pipe_add_push(state->rcc, msg); +red_channel_client_pipe_add_push(channel->rcc, msg); } static void spicevmc_port_send_init(RedChannelClient *rcc) { -RedVmcChannel *state = RED_VMC_CHANNEL(red_channel_client_get_channel(rcc)); +RedVmcChannel *channel = RED_VMC_CHANNEL(red_channel_client_get_channel(rcc)); SpiceCharDeviceInstance *sin; RedPortInitPipeItem *item = spice_malloc(sizeof(RedPortInitPipeItem)); -g_object_get(state->chardev, "sin", , NULL); +g_object_get(channel->chardev, "sin", , NULL); red_pipe_item_init(>base, RED_PIPE_ITEM_TYPE_PORT_INIT); item->name = strdup(sin->portname); -item->opened = state->port_opened; +item->opened = channel->port_opened; red_channel_client_pipe_add_push(rcc, >base); } @@ -458,13 +458,13 @@ static void spicevmc_char_dev_remove_client(RedCharDevice *self, RedClient