Re: [PATCH v2 3/9] worker: use variable already set at beginning of loops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2016-01-26 at 09:44 +0000, Frediano Ziglio wrote:
> 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@xxxxxxxxxx>
Acked-by: Pavel Grunt <pgrunt@xxxxxxxxxx>
> ---
>  server/red-worker.c | 28 +++++++++++++---------------
>  1 file changed, 13 insertions(+), 15 deletions(-)
> 
> diff --git a/server/red-worker.c b/server/red-worker.c
> index dd293f7..32a7110 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_channe
> l);
>              } 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);
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]