common: Replace spice_return_if_fail with g_return_if_fail

Submitted by Christophe de Dinechin on July 3, 2018, 1:14 p.m.

Details

Message ID 20180703131458.15890-1-christophe@dinechin.org
State New
Headers show
Series "common: Replace spice_return_if_fail with g_return_if_fail" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Christophe de Dinechin July 3, 2018, 1:14 p.m.
From: Christophe de Dinechin <dinechin@redhat.com>

The spice_ variants simply mirror the glib API,
without adding significant value.

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
--
Follow up a comment from Christophe Fergeau:

>I'd favour g_return_if_fail(), I'd really like to kill these various
> spice_* calls mirroring glib API.

---
 common/canvas_base.c      | 95 +++++++++++++++++++++++------------------------
 common/canvas_utils.c     |  2 +-
 common/log.h              | 14 -------
 common/lz.c               | 12 +++---
 common/quic_family_tmpl.c |  2 +-
 common/ssl_verify.c       |  6 +--
 common/sw_canvas.c        | 20 +++++-----
 7 files changed, 68 insertions(+), 83 deletions(-)

--
2.13.5 (Apple Git-94)

Patch hide | download patch | download mbox

diff --git a/common/canvas_base.c b/common/canvas_base.c
index 6bf6e5d..d163a1e 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -412,13 +412,13 @@  static pixman_image_t *canvas_get_quic(CanvasBase *canvas, SpiceImage *image,
         return NULL;
     }

-    spice_return_val_if_fail((uint32_t)width == image->descriptor.width, NULL);
-    spice_return_val_if_fail((uint32_t)height == image->descriptor.height, NULL);
+    g_return_val_if_fail((uint32_t)width == image->descriptor.width, NULL);
+    g_return_val_if_fail((uint32_t)height == image->descriptor.height, NULL);

     surface = surface_create(pixman_format,
                              width, height, FALSE);

-    spice_return_val_if_fail(surface != NULL, NULL);
+    g_return_val_if_fail(surface != NULL, NULL);

     dest = (uint8_t *)pixman_image_get_data(surface);
     stride = pixman_image_get_stride(surface);
@@ -471,11 +471,11 @@  static pixman_image_t *canvas_get_jpeg(CanvasBase *canvas, SpiceImage *image)
     int height;
     uint8_t *dest;

-    spice_return_val_if_fail(image->u.jpeg.data->num_chunks == 1, NULL);
+    g_return_val_if_fail(image->u.jpeg.data->num_chunks == 1, NULL);
     canvas->jpeg->ops->begin_decode(canvas->jpeg, image->u.jpeg.data->chunk[0].data, image->u.jpeg.data->chunk[0].len,
                                     &width, &height);
-    spice_return_val_if_fail((uint32_t)width == image->descriptor.width, NULL);
-    spice_return_val_if_fail((uint32_t)height == image->descriptor.height, NULL);
+    g_return_val_if_fail((uint32_t)width == image->descriptor.width, NULL);
+    g_return_val_if_fail((uint32_t)height == image->descriptor.height, NULL);

     surface = surface_create(PIXMAN_LE_x8r8g8b8,
                              width, height, FALSE);
@@ -609,13 +609,13 @@  static pixman_image_t *canvas_get_jpeg_alpha(CanvasBase *canvas, SpiceImage *ima
     int alpha_size;
     int lz_alpha_width, lz_alpha_height, n_comp_pixels, lz_alpha_top_down;

-    spice_return_val_if_fail(image->u.jpeg_alpha.data->num_chunks == 1, NULL);
+    g_return_val_if_fail(image->u.jpeg_alpha.data->num_chunks == 1, NULL);
     canvas->jpeg->ops->begin_decode(canvas->jpeg,
                                     image->u.jpeg_alpha.data->chunk[0].data,
                                     image->u.jpeg_alpha.jpeg_size,
                                     &width, &height);
-    spice_return_val_if_fail((uint32_t)width == image->descriptor.width, NULL);
-    spice_return_val_if_fail((uint32_t)height == image->descriptor.height, NULL);
+    g_return_val_if_fail((uint32_t)width == image->descriptor.width, NULL);
+    g_return_val_if_fail((uint32_t)height == image->descriptor.height, NULL);

     if (image->u.jpeg_alpha.flags & SPICE_JPEG_ALPHA_FLAGS_TOP_DOWN) {
         alpha_top_down = TRUE;
@@ -640,11 +640,11 @@  static pixman_image_t *canvas_get_jpeg_alpha(CanvasBase *canvas, SpiceImage *ima
     lz_decode_begin(lz_data->lz, comp_alpha_buf, alpha_size, &lz_alpha_type,
                     &lz_alpha_width, &lz_alpha_height, &n_comp_pixels,
                     &lz_alpha_top_down, NULL);
-    spice_return_val_if_fail(lz_alpha_type == LZ_IMAGE_TYPE_XXXA, NULL);
-    spice_return_val_if_fail(!!lz_alpha_top_down == !!alpha_top_down, NULL);
-    spice_return_val_if_fail(lz_alpha_width == width, NULL);
-    spice_return_val_if_fail(lz_alpha_height == height, NULL);
-    spice_return_val_if_fail(n_comp_pixels == width * height, NULL);
+    g_return_val_if_fail(lz_alpha_type == LZ_IMAGE_TYPE_XXXA, NULL);
+    g_return_val_if_fail(!!lz_alpha_top_down == !!alpha_top_down, NULL);
+    g_return_val_if_fail(lz_alpha_width == width, NULL);
+    g_return_val_if_fail(lz_alpha_height == height, NULL);
+    g_return_val_if_fail(n_comp_pixels == width * height, NULL);

     if (!alpha_top_down) {
         decomp_alpha_buf = dest + stride * (height - 1);
@@ -772,12 +772,12 @@  static pixman_image_t *canvas_get_lz(CanvasBase *canvas, SpiceImage *image,
     }

     if (image->descriptor.type == SPICE_IMAGE_TYPE_LZ_RGB) {
-        spice_return_val_if_fail(image->u.lz_rgb.data->num_chunks == 1, NULL); /* TODO: Handle chunks */
+        g_return_val_if_fail(image->u.lz_rgb.data->num_chunks == 1, NULL); /* TODO: Handle chunks */
         comp_buf = image->u.lz_rgb.data->chunk[0].data;
         comp_size = image->u.lz_rgb.data->chunk[0].len;
         palette = NULL;
     } else if (image->descriptor.type == SPICE_IMAGE_TYPE_LZ_PLT) {
-        spice_return_val_if_fail(image->u.lz_plt.data->num_chunks == 1, NULL); /* TODO: Handle chunks */
+        g_return_val_if_fail(image->u.lz_plt.data->num_chunks == 1, NULL); /* TODO: Handle chunks */
         comp_buf = image->u.lz_plt.data->chunk[0].data;
         comp_size = image->u.lz_plt.data->chunk[0].len;
         palette = canvas_get_localized_palette(canvas, image->u.lz_plt.palette,
@@ -831,10 +831,10 @@  static pixman_image_t *canvas_get_lz(CanvasBase *canvas, SpiceImage *image,
         return NULL;
     }

-    spice_return_val_if_fail((unsigned)width == image->descriptor.width, NULL);
-    spice_return_val_if_fail((unsigned)height == image->descriptor.height, NULL);
+    g_return_val_if_fail((unsigned)width == image->descriptor.width, NULL);
+    g_return_val_if_fail((unsigned)height == image->descriptor.height, NULL);

-    spice_return_val_if_fail((image->descriptor.type == SPICE_IMAGE_TYPE_LZ_PLT) || (n_comp_pixels == width * height), NULL);
+    g_return_val_if_fail((image->descriptor.type == SPICE_IMAGE_TYPE_LZ_PLT) || (n_comp_pixels == width * height), NULL);

     alloc_lz_image_surface(&lz_data->decode_data, pixman_format,
                            width, height, n_comp_pixels, top_down);
@@ -861,7 +861,7 @@  static pixman_image_t *canvas_get_lz(CanvasBase *canvas, SpiceImage *image,
 static pixman_image_t *canvas_get_glz_rgb_common(CanvasBase *canvas, uint8_t *data,
                                                  int want_original)
 {
-    spice_return_val_if_fail(canvas->glz_data.decoder != NULL, NULL);
+    g_return_val_if_fail(canvas->glz_data.decoder != NULL, NULL);

     canvas->glz_data.decoder->ops->decode(canvas->glz_data.decoder,
                                           data, NULL,
@@ -876,9 +876,9 @@  static pixman_image_t *canvas_get_glz_rgb_common(CanvasBase *canvas, uint8_t *da
 static pixman_image_t *canvas_get_glz(CanvasBase *canvas, SpiceImage *image,
                                       int want_original)
 {
-    spice_return_val_if_fail(image->descriptor.type == SPICE_IMAGE_TYPE_GLZ_RGB, NULL);
+    g_return_val_if_fail(image->descriptor.type == SPICE_IMAGE_TYPE_GLZ_RGB, NULL);

-    spice_return_val_if_fail(image->u.lz_rgb.data->num_chunks == 1, NULL); /* TODO: Handle chunks */
+    g_return_val_if_fail(image->u.lz_rgb.data->num_chunks == 1, NULL); /* TODO: Handle chunks */
     return canvas_get_glz_rgb_common(canvas, image->u.lz_rgb.data->chunk[0].data, want_original);
 }

@@ -888,9 +888,9 @@  static pixman_image_t *canvas_get_zlib_glz_rgb(CanvasBase *canvas, SpiceImage *i
     uint8_t *glz_data;
     pixman_image_t *surface;

-    spice_return_val_if_fail(canvas->zlib != NULL, NULL);
+    g_return_val_if_fail(canvas->zlib != NULL, NULL);

-    spice_return_val_if_fail(image->u.zlib_glz.data->num_chunks == 1, NULL); /* TODO: Handle chunks */
+    g_return_val_if_fail(image->u.zlib_glz.data->num_chunks == 1, NULL); /* TODO: Handle chunks */
     glz_data = (uint8_t*)spice_malloc(image->u.zlib_glz.glz_data_size);
     canvas->zlib->ops->decode(canvas->zlib, image->u.zlib_glz.data->chunk[0].data,
                               image->u.zlib_glz.data->chunk[0].len,
@@ -1161,8 +1161,8 @@  static pixman_image_t *canvas_get_image_internal(CanvasBase *canvas, SpiceImage

     surface = get_surface_from_canvas(canvas, image, want_original);

-    spice_return_val_if_fail(surface != NULL, NULL);
-    spice_return_val_if_fail(spice_pixman_image_get_format(surface, &surface_format), NULL);
+    g_return_val_if_fail(surface != NULL, NULL);
+    g_return_val_if_fail(spice_pixman_image_get_format(surface, &surface_format), NULL);

     if (descriptor->flags & SPICE_IMAGE_FLAGS_HIGH_BITS_SET &&
         descriptor->type != SPICE_IMAGE_TYPE_FROM_CACHE &&
@@ -1292,13 +1292,12 @@  static pixman_image_t* canvas_get_image_from_self(SpiceCanvas *canvas,
         /* Set alpha bits of the format to 0 */
         format = (pixman_format_code_t)(((uint32_t)format) & ~(0xf << 12));

-        spice_return_val_if_fail (
-            pixman_format_supported_destination (format), NULL);
+        g_return_val_if_fail (pixman_format_supported_destination (format), NULL);
     }

     surface = pixman_image_create_bits(spice_surface_format_to_pixman (canvas_base->format),
                                        width, height, NULL, 0);
-    spice_return_val_if_fail(surface != NULL, NULL);
+    g_return_val_if_fail(surface != NULL, NULL);

     dest = (uint8_t *)pixman_image_get_data(surface);
     dest_stride = pixman_image_get_stride(surface);
@@ -1380,7 +1379,7 @@  static pixman_image_t *canvas_get_bitmap_mask(CanvasBase *canvas, SpiceBitmap* b
     int dest_stride;

     surface = surface_create(PIXMAN_a1, bitmap->x, bitmap->y, TRUE);
-    spice_return_val_if_fail(surface != NULL, NULL);
+    g_return_val_if_fail(surface != NULL, NULL);

     spice_chunks_linearize(bitmap->data);
     src_line = bitmap->data->chunk[0].data;
@@ -1391,7 +1390,7 @@  static pixman_image_t *canvas_get_bitmap_mask(CanvasBase *canvas, SpiceBitmap* b
     dest_stride = pixman_image_get_stride(surface);
     dest_line = (uint8_t *)pixman_image_get_data(surface);
     if (!(bitmap->flags & SPICE_BITMAP_FLAGS_TOP_DOWN)) {
-        spice_return_val_if_fail(bitmap->y > 0, NULL);
+        g_return_val_if_fail(bitmap->y > 0, NULL);
         dest_line += dest_stride * ((int)bitmap->y - 1);
         dest_stride = -dest_stride;
     }
@@ -1461,10 +1460,10 @@  static inline pixman_image_t *canvas_A1_invers(pixman_image_t *src_surf)
     uint8_t *src_line, *end_line,  *dest_line;
     int src_stride, line_size, dest_stride;

-    spice_return_val_if_fail(pixman_image_get_depth(src_surf) == 1, NULL);
+    g_return_val_if_fail(pixman_image_get_depth(src_surf) == 1, NULL);

     invers = pixman_image_create_bits(PIXMAN_a1, width, height, NULL, 0);
-    spice_return_val_if_fail(invers != NULL, NULL);
+    g_return_val_if_fail(invers != NULL, NULL);

     src_line = (uint8_t *)pixman_image_get_data(src_surf);
     src_stride = pixman_image_get_stride(src_surf);
@@ -1546,7 +1545,7 @@  static pixman_image_t *canvas_get_mask(CanvasBase *canvas, SpiceQMask *mask, int

 static inline void canvas_raster_glyph_box(const SpiceRasterGlyph *glyph, SpiceRect *r)
 {
-    spice_return_if_fail(r != NULL);
+    g_return_if_fail(r != NULL);

     r->top = glyph->render_pos.y + glyph->glyph_origin.y;
     r->bottom = r->top + glyph->height;
@@ -1598,8 +1597,8 @@  static void canvas_put_glyph_bits(SpiceRasterGlyph *glyph, int bpp, uint8_t *des

     //todo: support SPICE_STRING_FLAGS_RASTER_TOP_DOWN
     canvas_raster_glyph_box(glyph, &glyph_box);
-    spice_return_if_fail(glyph_box.top >= bounds->top && glyph_box.bottom <= bounds->bottom);
-    spice_return_if_fail(glyph_box.left >= bounds->left && glyph_box.right <= bounds->right);
+    g_return_if_fail(glyph_box.top >= bounds->top && glyph_box.bottom <= bounds->bottom);
+    g_return_if_fail(glyph_box.left >= bounds->left && glyph_box.right <= bounds->right);
     rect_offset(&glyph_box, -bounds->left, -bounds->top);

     dest += glyph_box.top * dest_stride;
@@ -1674,7 +1673,7 @@  static pixman_image_t *canvas_get_str_mask(CanvasBase *canvas, SpiceString *str,
     int dest_stride;
     int i;

-    spice_return_val_if_fail(str->length > 0, NULL);
+    g_return_val_if_fail(str->length > 0, NULL);

     glyph = str->glyphs[0];
     canvas_raster_glyph_box(glyph, &bounds);
@@ -1689,7 +1688,7 @@  static pixman_image_t *canvas_get_str_mask(CanvasBase *canvas, SpiceString *str,
     str_mask = pixman_image_create_bits((bpp == 1) ? PIXMAN_a1 : PIXMAN_a8,
                                         bounds.right - bounds.left,
                                         bounds.bottom - bounds.top, NULL, 0);
-    spice_return_val_if_fail(str_mask != NULL, NULL);
+    g_return_val_if_fail(str_mask != NULL, NULL);

     dest = (uint8_t *)pixman_image_get_data(str_mask);
     dest_stride = pixman_image_get_stride(str_mask);
@@ -1711,10 +1710,10 @@  static pixman_image_t *canvas_scale_surface(pixman_image_t *src, const SpiceRect
     pixman_format_code_t format;
     double sx, sy;

-    spice_return_val_if_fail(spice_pixman_image_get_format (src, &format), NULL);
+    g_return_val_if_fail(spice_pixman_image_get_format (src, &format), NULL);

     surface = pixman_image_create_bits(format, width, height, NULL, 0);
-    spice_return_val_if_fail(surface != NULL, NULL);
+    g_return_val_if_fail(surface != NULL, NULL);

     sx = (double)(src_area->right - src_area->left) / width;
     sy = (double)(src_area->bottom - src_area->top) / height;
@@ -1723,7 +1722,7 @@  static pixman_image_t *canvas_scale_surface(pixman_image_t *src, const SpiceRect

     pixman_image_set_transform (src, &transform);
     pixman_image_set_repeat(src, PIXMAN_REPEAT_NONE);
-    spice_return_val_if_fail(scale_mode == SPICE_IMAGE_SCALE_MODE_INTERPOLATE || scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST, NULL);
+    g_return_val_if_fail(scale_mode == SPICE_IMAGE_SCALE_MODE_INTERPOLATE || scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST, NULL);
     pixman_image_set_filter(src,
                             (scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST) ?PIXMAN_FILTER_NEAREST : PIXMAN_FILTER_GOOD,
                             NULL, 0);
@@ -2026,7 +2025,7 @@  static void draw_brush(SpiceCanvas *canvas,
             }
         } else {
             tile = canvas_get_image(canvas_base, pattern->pat, FALSE);
-            spice_return_if_fail(tile != NULL);
+            g_return_if_fail(tile != NULL);

             if (rop == SPICE_ROP_COPY) {
                 canvas->ops->fill_tiled_rects(canvas, rects, n_rects, tile, offset_x, offset_y);
@@ -2163,7 +2162,7 @@  static void canvas_draw_copy(SpiceCanvas *spice_canvas, SpiceRect *bbox, SpiceCl
         }
     } else {
         src_image = canvas_get_image(canvas, copy->src_bitmap, FALSE);
-        spice_return_if_fail(src_image != NULL);
+        g_return_if_fail(src_image != NULL);

         if (rect_is_same_size(bbox, &copy->src_area)) {
             if (rop == SPICE_ROP_COPY) {
@@ -2270,7 +2269,7 @@  static void canvas_draw_transparent(SpiceCanvas *spice_canvas, SpiceRect *bbox,
         }
     } else {
         src_image = canvas_get_image(canvas, transparent->src_bitmap, FALSE);
-        spice_return_if_fail(src_image != NULL);
+        g_return_if_fail(src_image != NULL);

         if (rect_is_same_size(bbox, &transparent->src_area)) {
             spice_canvas->ops->colorkey_image(spice_canvas, &dest_region,
@@ -2349,7 +2348,7 @@  static void canvas_draw_alpha_blend(SpiceCanvas *spice_canvas, SpiceRect *bbox,
         }
      } else {
         src_image = canvas_get_image(canvas, alpha_blend->src_bitmap, TRUE);
-        spice_return_if_fail(src_image != NULL);
+        g_return_if_fail(src_image != NULL);

         if (rect_is_same_size(bbox, &alpha_blend->src_area)) {
             spice_canvas->ops->blend_image(spice_canvas, &dest_region,
@@ -2434,7 +2433,7 @@  static void canvas_draw_opaque(SpiceCanvas *spice_canvas, SpiceRect *bbox, Spice
         }
     } else {
         src_image = canvas_get_image(canvas, opaque->src_bitmap, FALSE);
-        spice_return_if_fail(src_image != NULL);
+        g_return_if_fail(src_image != NULL);

         if (rect_is_same_size(bbox, &opaque->src_area)) {
             spice_canvas->ops->blit_image(spice_canvas, &dest_region,
@@ -2532,7 +2531,7 @@  static void canvas_draw_blend(SpiceCanvas *spice_canvas, SpiceRect *bbox, SpiceC
         }
     } else {
         src_image = canvas_get_image(canvas, blend->src_bitmap, FALSE);
-        spice_return_if_fail(src_image != NULL);
+        g_return_if_fail(src_image != NULL);

         if (rect_is_same_size(bbox, &blend->src_area)) {
             if (rop == SPICE_ROP_COPY)
@@ -3097,7 +3096,7 @@  static void canvas_draw_stroke(SpiceCanvas *spice_canvas, SpiceRect *bbox,
         }

         if (seg->flags & SPICE_PATH_BEZIER) {
-            spice_return_if_fail((point - end_point) % 3 == 0);
+            g_return_if_fail((point - end_point) % 3 == 0);
             for (; point + 2 < end_point; point += 3) {
                 stroke_lines_append_bezier(&lines,
                                            &point[0],
diff --git a/common/canvas_utils.c b/common/canvas_utils.c
index a95501f..783ea57 100644
--- a/common/canvas_utils.c
+++ b/common/canvas_utils.c
@@ -72,7 +72,7 @@  int spice_pixman_image_get_format(pixman_image_t *image, pixman_format_code_t *f
 {
     PixmanData *data;

-    spice_return_val_if_fail(format != NULL, 0);
+    g_return_val_if_fail(format != NULL, 0);

     data = (PixmanData *)pixman_image_get_destroy_data(image);
     if (data != NULL && data->format != 0) {
diff --git a/common/log.h b/common/log.h
index e0fd34b..60bece4 100644
--- a/common/log.h
+++ b/common/log.h
@@ -39,20 +39,6 @@  void spice_log(GLogLevelFlags log_level,
                const char *format,
                ...) SPICE_ATTR_PRINTF(4, 5);

-#define spice_return_if_fail(x) G_STMT_START {                          \
-    if G_LIKELY(x) { } else {                                           \
-        spice_log(G_LOG_LEVEL_CRITICAL, SPICE_STRLOC, G_STRFUNC, "condition `%s' failed", #x); \
-        return;                                                         \
-    }                                                                   \
-} G_STMT_END
-
-#define spice_return_val_if_fail(x, val) G_STMT_START {                 \
-    if G_LIKELY(x) { } else {                                           \
-        spice_log(G_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__, "condition `%s' failed", #x); \
-        return (val);                                                   \
-    }                                                                   \
-} G_STMT_END
-
 #define spice_warn_if_reached() G_STMT_START {                          \
     spice_log(G_LOG_LEVEL_WARNING, SPICE_STRLOC, __FUNCTION__, "should not be reached"); \
 } G_STMT_END
diff --git a/common/lz.c b/common/lz.c
index b7e7d48..25bff7a 100644
--- a/common/lz.c
+++ b/common/lz.c
@@ -171,7 +171,7 @@  static int lz_read_image_segments(Encoder *encoder, uint8_t *first_lines,
     uint8_t* lines = first_lines;
     int row;

-    spice_return_val_if_fail(!encoder->head_image_segs, FALSE);
+    g_return_val_if_fail(!encoder->head_image_segs, FALSE);

     image_seg = lz_alloc_image_seg(encoder);
     if (!image_seg) {
@@ -227,10 +227,10 @@  static inline void encode(Encoder *encoder, uint8_t byte)
         if (more_io_bytes(encoder) <= 0) {
             encoder->usr->error(encoder->usr, "%s: no more bytes\n", __FUNCTION__);
         }
-        spice_return_if_fail(encoder->io_now);
+        g_return_if_fail(encoder->io_now);
     }

-    spice_return_if_fail(encoder->io_now < encoder->io_end);
+    g_return_if_fail(encoder->io_now < encoder->io_end);
     *(encoder->io_now++) = byte;
 }

@@ -250,7 +250,7 @@  static inline void encode_copy_count(Encoder *encoder, uint8_t copy_count)

 static inline void update_copy_count(Encoder *encoder, uint8_t copy_count)
 {
-    spice_return_if_fail(encoder->io_last_copy);
+    g_return_if_fail(encoder->io_last_copy);
     *(encoder->io_last_copy) = copy_count;
 }

@@ -260,12 +260,12 @@  static inline void compress_output_prev(Encoder *encoder)
     // io_now cannot be the first byte of the buffer
     encoder->io_now--;
     // the function should be called only when copy count is written unnecessarily by lz_compress
-    spice_return_if_fail(encoder->io_now == encoder->io_last_copy);
+    g_return_if_fail(encoder->io_now == encoder->io_last_copy);
 }

 static int encoder_reset(Encoder *encoder, uint8_t *io_ptr, uint8_t *io_ptr_end)
 {
-    spice_return_val_if_fail(io_ptr <= io_ptr_end, FALSE);
+    g_return_val_if_fail(io_ptr <= io_ptr_end, FALSE);

     encoder->io_bytes_count = io_ptr_end - io_ptr;
     encoder->io_now = io_ptr;
diff --git a/common/quic_family_tmpl.c b/common/quic_family_tmpl.c
index cda15bd..bffdeae 100644
--- a/common/quic_family_tmpl.c
+++ b/common/quic_family_tmpl.c
@@ -72,7 +72,7 @@  static void FNAME(update_model)(CommonState *state, s_bucket * const bucket,
                                 const BYTE curval)
 {
     SPICE_VERIFY(BPC >= 1);
-    spice_return_if_fail (bucket != NULL);
+    g_return_if_fail (bucket != NULL);

     const unsigned int bpp = BPC;
     COUNTER * const pcounters = bucket->pcounters;
diff --git a/common/ssl_verify.c b/common/ssl_verify.c
index 0ac00a6..06f5187 100644
--- a/common/ssl_verify.c
+++ b/common/ssl_verify.c
@@ -160,7 +160,7 @@  static int verify_hostname(X509* cert, const char *hostname)
     int cn_match = 0;
     X509_NAME* subject;

-    spice_return_val_if_fail(hostname != NULL, 0);
+    g_return_val_if_fail(hostname != NULL, 0);

     if (!cert) {
         spice_debug("warning: no cert!");
@@ -288,8 +288,8 @@  static X509_NAME* subject_to_x509_name(const char *subject, int *nentries)
         VALUE
     } state;

-    spice_return_val_if_fail(subject != NULL, NULL);
-    spice_return_val_if_fail(nentries != NULL, NULL);
+    g_return_val_if_fail(subject != NULL, NULL);
+    g_return_val_if_fail(nentries != NULL, NULL);

     key = (char*)alloca(strlen(subject));
     val = (char*)alloca(strlen(subject));
diff --git a/common/sw_canvas.c b/common/sw_canvas.c
index c41edb1..6944285 100644
--- a/common/sw_canvas.c
+++ b/common/sw_canvas.c
@@ -489,8 +489,8 @@  static void __scale_image(SpiceCanvas *spice_canvas,

     pixman_image_set_transform(src, &transform);
     pixman_image_set_repeat(src, PIXMAN_REPEAT_NONE);
-    spice_return_if_fail(scale_mode == SPICE_IMAGE_SCALE_MODE_INTERPOLATE ||
-                         scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST);
+    g_return_if_fail(scale_mode == SPICE_IMAGE_SCALE_MODE_INTERPOLATE ||
+                     scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST);
     pixman_image_set_filter(src,
                             (scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST) ?
                             PIXMAN_FILTER_NEAREST : PIXMAN_FILTER_GOOD,
@@ -556,7 +556,7 @@  static void __scale_image_rop(SpiceCanvas *spice_canvas,
     fsx = ((pixman_fixed_48_16_t) src_width * 65536) / dest_width;
     fsy = ((pixman_fixed_48_16_t) src_height * 65536) / dest_height;

-    spice_return_if_fail(spice_pixman_image_get_format(src, &format));
+    g_return_if_fail(spice_pixman_image_get_format(src, &format));
     scaled = pixman_image_create_bits(format,
                                       dest_width,
                                       dest_height,
@@ -572,8 +572,8 @@  static void __scale_image_rop(SpiceCanvas *spice_canvas,

     pixman_image_set_transform(src, &transform);
     pixman_image_set_repeat(src, PIXMAN_REPEAT_NONE);
-    spice_return_if_fail(scale_mode == SPICE_IMAGE_SCALE_MODE_INTERPOLATE ||
-                         scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST);
+    g_return_if_fail(scale_mode == SPICE_IMAGE_SCALE_MODE_INTERPOLATE ||
+                     scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST);
     pixman_image_set_filter(src,
                             (scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST) ?
                             PIXMAN_FILTER_NEAREST : PIXMAN_FILTER_GOOD,
@@ -773,8 +773,8 @@  static void __blend_scale_image(SpiceCanvas *spice_canvas,

     pixman_image_set_transform(src, &transform);
     pixman_image_set_repeat(src, PIXMAN_REPEAT_NONE);
-    spice_return_if_fail(scale_mode == SPICE_IMAGE_SCALE_MODE_INTERPOLATE ||
-                         scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST);
+    g_return_if_fail(scale_mode == SPICE_IMAGE_SCALE_MODE_INTERPOLATE ||
+                     scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST);
     pixman_image_set_filter(src,
                             (scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST) ?
                             PIXMAN_FILTER_NEAREST : PIXMAN_FILTER_GOOD,
@@ -914,7 +914,7 @@  static void __colorkey_scale_image(SpiceCanvas *spice_canvas,
     fsx = ((pixman_fixed_48_16_t) src_width * 65536) / dest_width;
     fsy = ((pixman_fixed_48_16_t) src_height * 65536) / dest_height;

-    spice_return_if_fail(spice_pixman_image_get_format(src, &format));
+    g_return_if_fail(spice_pixman_image_get_format(src, &format));
     scaled = pixman_image_create_bits(format,
                                       dest_width,
                                       dest_height,
@@ -1077,7 +1077,7 @@  static void canvas_draw_text(SpiceCanvas *spice_canvas, SpiceRect *bbox,

         /* Nothing else makes sense for text and we should deprecate it
          * and actually it means OVER really */
-        spice_return_if_fail(text->fore_mode == SPICE_ROPD_OP_PUT);
+        g_return_if_fail(text->fore_mode == SPICE_ROPD_OP_PUT);

         pixman_region32_init_rect(&back_region,
                                   text->back_area.left,
@@ -1146,7 +1146,7 @@  static void canvas_read_bits(SpiceCanvas *spice_canvas, uint8_t *dest,
     uint8_t *dest_end;
     int bpp;

-    spice_return_if_fail(canvas && area);
+    g_return_if_fail(canvas && area);

     surface = canvas->image;