[spice-server,1/2] replay: Remove some goto statement

Submitted by Frediano Ziglio on July 23, 2019, 8:22 a.m.

Details

Message ID 20190723082230.10381-1-fziglio@redhat.com
State Accepted
Commit 3af64b61dc5d565aea64cd528f5d24434c7fa5f6
Headers show
Series "Series without cover letter" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio July 23, 2019, 8:22 a.m.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 server/tests/replay.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

Patch hide | download patch | download mbox

diff --git a/server/tests/replay.c b/server/tests/replay.c
index e3ef7bf15..992f26d63 100644
--- a/server/tests/replay.c
+++ b/server/tests/replay.c
@@ -116,7 +116,7 @@  static gboolean fill_queue_idle(gpointer user_data)
         if (!cmd) {
             g_async_queue_push(display_queue, GINT_TO_POINTER(-1));
             g_async_queue_push(cursor_queue, GINT_TO_POINTER(-1));
-            goto end;
+            break;
         }
 
         ++ncommands;
@@ -133,7 +133,6 @@  static gboolean fill_queue_idle(gpointer user_data)
         }
     }
 
-end:
     if (!keep) {
         pthread_mutex_lock(&mutex);
         if (fill_source) {
@@ -153,17 +152,12 @@  static void fill_queue(void)
 {
     pthread_mutex_lock(&mutex);
 
-    if (!started)
-        goto end;
-
-    if (fill_source)
-        goto end;
-
-    fill_source = g_idle_source_new();
-    g_source_set_callback(fill_source, fill_queue_idle, NULL, NULL);
-    g_source_attach(fill_source, basic_event_loop_get_context());
+    if (started && fill_source == NULL) {
+        fill_source = g_idle_source_new();
+        g_source_set_callback(fill_source, fill_queue_idle, NULL, NULL);
+        g_source_attach(fill_source, basic_event_loop_get_context());
+    }
 
-end:
     pthread_mutex_unlock(&mutex);
 }
 

Comments

ping the series

> 
> Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
> ---
>  server/tests/replay.c | 18 ++++++------------
>  1 file changed, 6 insertions(+), 12 deletions(-)
> 
> diff --git a/server/tests/replay.c b/server/tests/replay.c
> index e3ef7bf15..992f26d63 100644
> --- a/server/tests/replay.c
> +++ b/server/tests/replay.c
> @@ -116,7 +116,7 @@ static gboolean fill_queue_idle(gpointer user_data)
>          if (!cmd) {
>              g_async_queue_push(display_queue, GINT_TO_POINTER(-1));
>              g_async_queue_push(cursor_queue, GINT_TO_POINTER(-1));
> -            goto end;
> +            break;
>          }
>  
>          ++ncommands;
> @@ -133,7 +133,6 @@ static gboolean fill_queue_idle(gpointer user_data)
>          }
>      }
>  
> -end:
>      if (!keep) {
>          pthread_mutex_lock(&mutex);
>          if (fill_source) {
> @@ -153,17 +152,12 @@ static void fill_queue(void)
>  {
>      pthread_mutex_lock(&mutex);
>  
> -    if (!started)
> -        goto end;
> -
> -    if (fill_source)
> -        goto end;
> -
> -    fill_source = g_idle_source_new();
> -    g_source_set_callback(fill_source, fill_queue_idle, NULL, NULL);
> -    g_source_attach(fill_source, basic_event_loop_get_context());
> +    if (started && fill_source == NULL) {
> +        fill_source = g_idle_source_new();
> +        g_source_set_callback(fill_source, fill_queue_idle, NULL, NULL);
> +        g_source_attach(fill_source, basic_event_loop_get_context());
> +    }
>  
> -end:
>      pthread_mutex_unlock(&mutex);
>  }
>
ping

> 
> ping the series
> 
> > 
> > Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
> > ---
> >  server/tests/replay.c | 18 ++++++------------
> >  1 file changed, 6 insertions(+), 12 deletions(-)
> > 
> > diff --git a/server/tests/replay.c b/server/tests/replay.c
> > index e3ef7bf15..992f26d63 100644
> > --- a/server/tests/replay.c
> > +++ b/server/tests/replay.c
> > @@ -116,7 +116,7 @@ static gboolean fill_queue_idle(gpointer user_data)
> >          if (!cmd) {
> >              g_async_queue_push(display_queue, GINT_TO_POINTER(-1));
> >              g_async_queue_push(cursor_queue, GINT_TO_POINTER(-1));
> > -            goto end;
> > +            break;
> >          }
> >  
> >          ++ncommands;
> > @@ -133,7 +133,6 @@ static gboolean fill_queue_idle(gpointer user_data)
> >          }
> >      }
> >  
> > -end:
> >      if (!keep) {
> >          pthread_mutex_lock(&mutex);
> >          if (fill_source) {
> > @@ -153,17 +152,12 @@ static void fill_queue(void)
> >  {
> >      pthread_mutex_lock(&mutex);
> >  
> > -    if (!started)
> > -        goto end;
> > -
> > -    if (fill_source)
> > -        goto end;
> > -
> > -    fill_source = g_idle_source_new();
> > -    g_source_set_callback(fill_source, fill_queue_idle, NULL, NULL);
> > -    g_source_attach(fill_source, basic_event_loop_get_context());
> > +    if (started && fill_source == NULL) {
> > +        fill_source = g_idle_source_new();
> > +        g_source_set_callback(fill_source, fill_queue_idle, NULL, NULL);
> > +        g_source_attach(fill_source, basic_event_loop_get_context());
> > +    }
> >  
> > -end:
> >      pthread_mutex_unlock(&mutex);
> >  }
> >  
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
Acked-by: Snir Sheriber <ssheribe@redhat.com>

On 7/23/19 11:22 AM, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
> ---
>   server/tests/replay.c | 18 ++++++------------
>   1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/server/tests/replay.c b/server/tests/replay.c
> index e3ef7bf15..992f26d63 100644
> --- a/server/tests/replay.c
> +++ b/server/tests/replay.c
> @@ -116,7 +116,7 @@ static gboolean fill_queue_idle(gpointer user_data)
>           if (!cmd) {
>               g_async_queue_push(display_queue, GINT_TO_POINTER(-1));
>               g_async_queue_push(cursor_queue, GINT_TO_POINTER(-1));
> -            goto end;
> +            break;
>           }
>   
>           ++ncommands;
> @@ -133,7 +133,6 @@ static gboolean fill_queue_idle(gpointer user_data)
>           }
>       }
>   
> -end:
>       if (!keep) {
>           pthread_mutex_lock(&mutex);
>           if (fill_source) {
> @@ -153,17 +152,12 @@ static void fill_queue(void)
>   {
>       pthread_mutex_lock(&mutex);
>   
> -    if (!started)
> -        goto end;
> -
> -    if (fill_source)
> -        goto end;
> -
> -    fill_source = g_idle_source_new();
> -    g_source_set_callback(fill_source, fill_queue_idle, NULL, NULL);
> -    g_source_attach(fill_source, basic_event_loop_get_context());
> +    if (started && fill_source == NULL) {
> +        fill_source = g_idle_source_new();
> +        g_source_set_callback(fill_source, fill_queue_idle, NULL, NULL);
> +        g_source_attach(fill_source, basic_event_loop_get_context());
> +    }
>   
> -end:
>       pthread_mutex_unlock(&mutex);
>   }
>