[Spice-commits] server/spicevmc.c
Frediano Ziglio
fziglio at kemper.freedesktop.org
Wed Feb 1 08:48:47 UTC 2017
server/spicevmc.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
New commits:
commit d8a32e77f5b2567f4d12d1172f0479ef22aba9c8
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Wed Nov 2 07:51:38 2016 +0000
spicevmc: Avoid computing some variable value if not necessary
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/spicevmc.c b/server/spicevmc.c
index 89249b2..9bcbada 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -592,13 +592,12 @@ static uint8_t *spicevmc_red_channel_alloc_msg_rcv_buf(RedChannelClient *rcc,
uint16_t type,
uint32_t size)
{
- RedVmcChannel *channel;
- RedClient *client = red_channel_client_get_client(rcc);
-
- channel = RED_VMC_CHANNEL(red_channel_client_get_channel(rcc));
switch (type) {
- case SPICE_MSGC_SPICEVMC_DATA:
+ case SPICE_MSGC_SPICEVMC_DATA: {
+ RedClient *client = red_channel_client_get_client(rcc);
+ RedVmcChannel *channel = RED_VMC_CHANNEL(red_channel_client_get_channel(rcc));
+
assert(!channel->recv_from_client_buf);
channel->recv_from_client_buf = red_char_device_write_buffer_get(channel->chardev,
@@ -609,6 +608,7 @@ static uint8_t *spicevmc_red_channel_alloc_msg_rcv_buf(RedChannelClient *rcc,
return NULL;
}
return channel->recv_from_client_buf->buf;
+ }
default:
return spice_malloc(size);
@@ -621,15 +621,14 @@ static void spicevmc_red_channel_release_msg_rcv_buf(RedChannelClient *rcc,
uint32_t size,
uint8_t *msg)
{
- RedVmcChannel *channel;
-
- channel = RED_VMC_CHANNEL(red_channel_client_get_channel(rcc));
switch (type) {
- case SPICE_MSGC_SPICEVMC_DATA:
+ case SPICE_MSGC_SPICEVMC_DATA: {
+ RedVmcChannel *channel = RED_VMC_CHANNEL(red_channel_client_get_channel(rcc));
/* buffer wasn't pushed to device */
red_char_device_write_buffer_release(channel->chardev, &channel->recv_from_client_buf);
break;
+ }
default:
free(msg);
}
More information about the Spice-commits
mailing list