[Spice-devel] [PATCH v2 5/9] worker: remove useless test

Frediano Ziglio fziglio at redhat.com
Tue Jan 26 01:44:32 PST 2016


red_channel_max_pipe_size returns 0 if no client (channel disconnected)
no need to check if cursor_channel/display_channel are NULL or
connected.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/red-worker.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/server/red-worker.c b/server/red-worker.c
index 32a7110..9f967b4 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -119,12 +119,6 @@ static int display_is_connected(RedWorker *worker)
         &worker->display_channel->common.base));
 }
 
-static int cursor_is_connected(RedWorker *worker)
-{
-    return worker->cursor_channel &&
-        red_channel_is_connected(RED_CHANNEL(worker->cursor_channel));
-}
-
 static uint8_t *common_alloc_recv_buf(RedChannelClient *rcc, uint16_t type, uint32_t size)
 {
     CommonChannel *common = SPICE_CONTAINEROF(rcc->channel, CommonChannel, base);
@@ -176,8 +170,7 @@ static int red_process_cursor(RedWorker *worker, int *ring_is_empty)
     }
 
     *ring_is_empty = FALSE;
-    while (!cursor_is_connected(worker) ||
-           red_channel_max_pipe_size(RED_CHANNEL(worker->cursor_channel)) <= MAX_PIPE_SIZE) {
+    while (red_channel_max_pipe_size(RED_CHANNEL(worker->cursor_channel)) <= MAX_PIPE_SIZE) {
         if (!worker->qxl->st->qif->get_cursor_command(worker->qxl, &ext_cmd)) {
             *ring_is_empty = TRUE;
             if (worker->cursor_poll_tries < CMD_RING_POLL_RETRIES) {
@@ -237,8 +230,7 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
 
     worker->process_display_generation++;
     *ring_is_empty = FALSE;
-    while (!display_is_connected(worker) ||
-           red_channel_max_pipe_size(RED_CHANNEL(worker->display_channel)) <= MAX_PIPE_SIZE) {
+    while (red_channel_max_pipe_size(RED_CHANNEL(worker->display_channel)) <= MAX_PIPE_SIZE) {
         if (!worker->qxl->st->qif->get_command(worker->qxl, &ext_cmd)) {
             *ring_is_empty = TRUE;;
             if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
@@ -401,8 +393,7 @@ static void flush_display_commands(RedWorker *worker)
         int sleep_count = 0;
         for (;;) {
             red_channel_push(red_channel);
-            if (!display_is_connected(worker) ||
-                red_channel_max_pipe_size(red_channel) <= MAX_PIPE_SIZE) {
+            if (red_channel_max_pipe_size(red_channel) <= MAX_PIPE_SIZE) {
                 break;
             }
             red_channel_receive(red_channel);
@@ -444,8 +435,7 @@ static void flush_cursor_commands(RedWorker *worker)
         int sleep_count = 0;
         for (;;) {
             red_channel_push(red_channel);
-            if (!cursor_is_connected(worker)
-                || red_channel_max_pipe_size(red_channel) <= MAX_PIPE_SIZE) {
+            if (red_channel_max_pipe_size(red_channel) <= MAX_PIPE_SIZE) {
                 break;
             }
             red_channel_receive(red_channel);
-- 
2.4.3



More information about the Spice-devel mailing list