[Spice-commits] server/red_worker.c

Frediano Ziglio fziglio at kemper.freedesktop.org
Wed Nov 4 10:26:40 PST 2015


 server/red_worker.c |   46 ++++++++++++++++++++++++----------------------
 1 file changed, 24 insertions(+), 22 deletions(-)

New commits:
commit ac53e6a3c3dceaf640cb7832f39a4182b9b79931
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Wed Nov 4 11:18:31 2015 -0600

    style: prefer early return to large if blocks
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/red_worker.c b/server/red_worker.c
index 5b1ece8..1c37dc0 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -958,11 +958,12 @@ static void release_image_item(ImageItem *item)
 
 static void release_upgrade_item(RedWorker* worker, UpgradeItem *item)
 {
-    if (!--item->refs) {
-        red_worker_drawable_unref(worker, item->drawable);
-        free(item->rects);
-        free(item);
-    }
+    if (--item->refs != 0)
+        return;
+
+    red_worker_drawable_unref(worker, item->drawable);
+    free(item->rects);
+    free(item);
 }
 
 static uint8_t *common_alloc_recv_buf(RedChannelClient *rcc, uint16_t type, uint32_t size)
@@ -1159,27 +1160,28 @@ static void red_worker_drawable_unref(RedWorker *worker, Drawable *drawable)
 {
     RingItem *item, *next;
 
-    if (!--drawable->refs) {
-        spice_assert(!drawable->tree_item.shadow);
-        spice_assert(ring_is_empty(&drawable->pipes));
+    if (--drawable->refs != 0)
+        return;
 
-        if (drawable->stream) {
-            red_detach_stream(worker, drawable->stream, TRUE);
-        }
-        region_destroy(&drawable->tree_item.base.rgn);
+    spice_warn_if_fail(!drawable->tree_item.shadow);
+    spice_warn_if_fail(ring_is_empty(&drawable->pipes));
 
-        remove_drawable_dependencies(worker, drawable);
-        red_dec_surfaces_drawable_dependencies(worker, drawable);
-        red_destroy_surface(worker, drawable->surface_id);
+    if (drawable->stream) {
+        red_detach_stream(worker, drawable->stream, TRUE);
+    }
+    region_destroy(&drawable->tree_item.base.rgn);
 
-        RING_FOREACH_SAFE(item, next, &drawable->glz_ring) {
-            SPICE_CONTAINEROF(item, RedGlzDrawable, drawable_link)->drawable = NULL;
-            ring_remove(item);
-        }
-        put_red_drawable(worker, drawable->red_drawable, drawable->group_id);
-        free_drawable(worker, drawable);
-        worker->drawable_count--;
+    remove_drawable_dependencies(worker, drawable);
+    red_dec_surfaces_drawable_dependencies(worker, drawable);
+    red_destroy_surface(worker, drawable->surface_id);
+
+    RING_FOREACH_SAFE(item, next, &drawable->glz_ring) {
+        SPICE_CONTAINEROF(item, RedGlzDrawable, drawable_link)->drawable = NULL;
+        ring_remove(item);
     }
+    put_red_drawable(worker, drawable->red_drawable, drawable->group_id);
+    free_drawable(worker, drawable);
+    worker->drawable_count--;
 }
 
 static inline void remove_shadow(RedWorker *worker, DrawItem *item)


More information about the Spice-commits mailing list