[Spice-commits] server/red-worker.c

Frediano Ziglio fziglio at kemper.freedesktop.org
Tue Jan 26 02:32:24 PST 2016


 server/red-worker.c |   28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

New commits:
commit 4084b2b246b05dc8c173f597036f7eb1239798a2
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Mon Jan 25 08:26:05 2016 +0000

    worker: use variable already set at beginning of loops
    
    This is mainly question of style.
    Instead of repeating same conversion use the variable we set at the
    beginning of the function.
    Note also that I used same name to make the two functions more
    similar.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Pavel Grunt <pgrunt at redhat.com>

diff --git a/server/red-worker.c b/server/red-worker.c
index 9a392ec..5012556 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -379,7 +379,7 @@ static void red_migrate_display(DisplayChannel *display, RedChannelClient *rcc)
 
 static void flush_display_commands(RedWorker *worker)
 {
-    RedChannel *display_red_channel = RED_CHANNEL(worker->display_channel);
+    RedChannel *red_channel = RED_CHANNEL(worker->display_channel);
 
     for (;;) {
         uint64_t end_time;
@@ -391,7 +391,7 @@ static void flush_display_commands(RedWorker *worker)
         }
 
         while (red_process_display(worker, &ring_is_empty)) {
-            red_channel_push(RED_CHANNEL(worker->display_channel));
+            red_channel_push(red_channel);
         }
 
         if (ring_is_empty) {
@@ -400,19 +400,18 @@ static void flush_display_commands(RedWorker *worker)
         end_time = spice_get_monotonic_time_ns() + COMMON_CLIENT_TIMEOUT;
         int sleep_count = 0;
         for (;;) {
-            red_channel_push(RED_CHANNEL(worker->display_channel));
+            red_channel_push(red_channel);
             if (!display_is_connected(worker) ||
-                red_channel_max_pipe_size(display_red_channel) <= MAX_PIPE_SIZE) {
+                red_channel_max_pipe_size(red_channel) <= MAX_PIPE_SIZE) {
                 break;
             }
-            RedChannel *channel = (RedChannel *)worker->display_channel;
-            red_channel_receive(channel);
-            red_channel_send(channel);
+            red_channel_receive(red_channel);
+            red_channel_send(red_channel);
             // TODO: MC: the whole timeout will break since it takes lowest timeout, should
             // do it client by client.
             if (spice_get_monotonic_time_ns() >= end_time) {
                 spice_warning("update timeout");
-                red_disconnect_all_display_TODO_remove_me(channel);
+                red_disconnect_all_display_TODO_remove_me(red_channel);
             } else {
                 sleep_count++;
                 usleep(DISPLAY_CLIENT_RETRY_INTERVAL);
@@ -423,7 +422,7 @@ static void flush_display_commands(RedWorker *worker)
 
 static void flush_cursor_commands(RedWorker *worker)
 {
-    RedChannel *cursor_red_channel = RED_CHANNEL(worker->cursor_channel);
+    RedChannel *red_channel = RED_CHANNEL(worker->cursor_channel);
 
     for (;;) {
         uint64_t end_time;
@@ -435,7 +434,7 @@ static void flush_cursor_commands(RedWorker *worker)
         }
 
         while (red_process_cursor(worker, &ring_is_empty)) {
-            red_channel_push(RED_CHANNEL(worker->cursor_channel));
+            red_channel_push(red_channel);
         }
 
         if (ring_is_empty) {
@@ -444,14 +443,13 @@ static void flush_cursor_commands(RedWorker *worker)
         end_time = spice_get_monotonic_time_ns() + COMMON_CLIENT_TIMEOUT;
         int sleep_count = 0;
         for (;;) {
-            red_channel_push(RED_CHANNEL(worker->cursor_channel));
+            red_channel_push(red_channel);
             if (!cursor_is_connected(worker)
-                || red_channel_max_pipe_size(cursor_red_channel) <= MAX_PIPE_SIZE) {
+                || red_channel_max_pipe_size(red_channel) <= MAX_PIPE_SIZE) {
                 break;
             }
-            RedChannel *channel = (RedChannel *)worker->cursor_channel;
-            red_channel_receive(channel);
-            red_channel_send(channel);
+            red_channel_receive(red_channel);
+            red_channel_send(red_channel);
             if (spice_get_monotonic_time_ns() >= end_time) {
                 spice_warning("flush cursor timeout");
                 cursor_channel_disconnect(worker->cursor_channel);


More information about the Spice-commits mailing list