Re: [PATCH] server: Replace spice_return_if_fail with g_return_if_fail

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

 



> 
> From: Christophe de Dinechin <dinechin@xxxxxxxxxx>
> 
> The spice_ variants simply mirror the glib API,
> without adding significant value.
> 
> Signed-off-by: Christophe de Dinechin <dinechin@xxxxxxxxxx>
> --
> Following up on Christophe Fergeau's comment:
> 
> > I'd favour g_return_if_fail(), I'd really like to kill these various
> > spice_* calls mirroring glib API.

What is this?
Another set of untested patch?
If you tried you'll have realised (just as I did) that the behaviour is different!

Frediano

> ---
> 
>  server/cursor-channel-client.c |  2 +-
>  server/cursor-channel.c        | 18 ++++++++---------
>  server/dcc-send.c              | 10 ++++-----
>  server/dcc.c                   | 22 ++++++++++----------
>  server/display-channel.c       | 46
>  +++++++++++++++++++++---------------------
>  server/event-loop.c            |  4 ++--
>  server/gstreamer-encoder.c     | 14 ++++++-------
>  server/image-encoders.c        |  6 +++---
>  server/memslot.c               |  4 ++--
>  server/mjpeg-encoder.c         |  2 +-
>  server/red-channel.c           |  6 +++---
>  server/red-qxl.c               | 14 ++++++-------
>  server/red-replay-qxl.c        | 10 ++++-----
>  server/red-stream.c            |  6 +++---
>  server/red-worker.c            | 18 ++++++++---------
>  server/reds.c                  |  2 +-
>  server/spice-bitmap-utils.h    |  6 +++---
>  server/stream-channel.c        |  4 ++--
>  server/tests/test-stream.c     |  2 +-
>  server/tree.c                  |  6 +++---
>  server/video-stream.c          | 10 ++++-----
>  21 files changed, 106 insertions(+), 106 deletions(-)
> 
> diff --git a/server/cursor-channel-client.c b/server/cursor-channel-client.c
> index 6d39e24e..3a177467 100644
> --- a/server/cursor-channel-client.c
> +++ b/server/cursor-channel-client.c
> @@ -91,7 +91,7 @@ static void
> cursor_channel_client_on_disconnect(RedChannelClient *rcc)
> 
>  void cursor_channel_client_migrate(RedChannelClient *rcc)
>  {
> -    spice_return_if_fail(rcc);
> +    g_return_if_fail(rcc);
> 
>      red_channel_client_pipe_add_type(rcc,
>      RED_PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE);
>      red_channel_client_default_migrate(rcc);
> diff --git a/server/cursor-channel.c b/server/cursor-channel.c
> index ada1d62a..68fe1005 100644
> --- a/server/cursor-channel.c
> +++ b/server/cursor-channel.c
> @@ -58,7 +58,7 @@ static RedCursorPipeItem *cursor_pipe_item_new(RedCursorCmd
> *cmd)
>  {
>      RedCursorPipeItem *item = g_new0(RedCursorPipeItem, 1);
> 
> -    spice_return_val_if_fail(cmd != NULL, NULL);
> +    g_return_val_if_fail(cmd != NULL, NULL);
> 
>      red_pipe_item_init_full(&item->base, RED_PIPE_ITEM_TYPE_CURSOR,
>                              cursor_pipe_item_free);
> @@ -151,7 +151,7 @@ static void red_marshall_cursor(CursorChannelClient *ccc,
>      RedCursorPipeItem *item = cursor_pipe_item;
>      RedCursorCmd *cmd;
> 
> -    spice_return_if_fail(cursor_channel);
> +    g_return_if_fail(cursor_channel);
> 
>      cmd = item->red_cursor;
>      switch (cmd->type) {
> @@ -251,8 +251,8 @@ void cursor_channel_process_cmd(CursorChannel *cursor,
> RedCursorCmd *cursor_cmd)
>      RedCursorPipeItem *cursor_pipe_item;
>      bool cursor_show = false;
> 
> -    spice_return_if_fail(cursor);
> -    spice_return_if_fail(cursor_cmd);
> +    g_return_if_fail(cursor);
> +    g_return_if_fail(cursor_cmd);
> 
>      cursor_pipe_item = cursor_pipe_item_new(cursor_cmd);
> 
> @@ -293,7 +293,7 @@ void cursor_channel_reset(CursorChannel *cursor)
>  {
>      RedChannel *channel = RED_CHANNEL(cursor);
> 
> -    spice_return_if_fail(cursor);
> +    g_return_if_fail(cursor);
> 
>      cursor_channel_set_item(cursor, NULL);
>      cursor->cursor_visible = true;
> @@ -311,7 +311,7 @@ void cursor_channel_reset(CursorChannel *cursor)
> 
>  static void cursor_channel_init_client(CursorChannel *cursor,
>  CursorChannelClient *client)
>  {
> -    spice_return_if_fail(cursor);
> +    g_return_if_fail(cursor);
> 
>      if (!red_channel_is_connected(RED_CHANNEL(cursor))
>          || common_graphics_channel_get_during_target_migrate(COMMON_GRAPHICS_CHANNEL(cursor)))
>          || {
> @@ -333,7 +333,7 @@ void cursor_channel_do_init(CursorChannel *cursor)
> 
>  void cursor_channel_set_mouse_mode(CursorChannel *cursor, uint32_t mode)
>  {
> -    spice_return_if_fail(cursor);
> +    g_return_if_fail(cursor);
> 
>      cursor->mouse_mode = mode;
>  }
> @@ -344,13 +344,13 @@ void cursor_channel_connect(CursorChannel *cursor,
> RedClient *client, RedStream
>  {
>      CursorChannelClient *ccc;
> 
> -    spice_return_if_fail(cursor != NULL);
> +    g_return_if_fail(cursor != NULL);
> 
>      spice_debug("add cursor channel client");
>      ccc = cursor_channel_client_new(cursor, client, stream,
>                                      migrate,
>                                      caps);
> -    spice_return_if_fail(ccc != NULL);
> +    g_return_if_fail(ccc != NULL);
> 
>      RedChannelClient *rcc = RED_CHANNEL_CLIENT(ccc);
>      red_channel_client_ack_zero_messages_window(rcc);
> diff --git a/server/dcc-send.c b/server/dcc-send.c
> index 211c69d7..8877ee0c 100644
> --- a/server/dcc-send.c
> +++ b/server/dcc-send.c
> @@ -94,7 +94,7 @@ static bool is_surface_area_lossy(DisplayChannelClient
> *dcc, uint32_t surface_id
>      QRegion lossy_region;
>      DisplayChannel *display = DCC_TO_DC(dcc);
> 
> -    spice_return_val_if_fail(display_channel_validate_surface(display,
> surface_id), FALSE);
> +    g_return_val_if_fail(display_channel_validate_surface(display,
> surface_id), FALSE);
> 
>      surface = &display->priv->surfaces[surface_id];
>      surface_lossy_region =
>      &dcc->priv->surface_client_lossy_region[surface_id];
> @@ -335,7 +335,7 @@ static void marshaller_add_compressed(SpiceMarshaller *m,
>      size_t max = size;
>      size_t now;
>      do {
> -        spice_return_if_fail(comp_buf);
> +        g_return_if_fail(comp_buf);
>          now = MIN(sizeof(comp_buf->buf), max);
>          max -= now;
>          spice_marshaller_add_by_ref_full(m, comp_buf->buf.bytes, now,
> @@ -2135,13 +2135,13 @@ static void marshall_qxl_drawable(RedChannelClient
> *rcc,
>                                    SpiceMarshaller *m,
>                                    RedDrawablePipeItem *dpi)
>  {
> -    spice_return_if_fail(rcc);
> +    g_return_if_fail(rcc);
> 
>      Drawable *item = dpi->drawable;
>      DisplayChannel *display =
>          DISPLAY_CHANNEL(red_channel_client_get_channel(rcc));
> 
> -    spice_return_if_fail(display);
> +    g_return_if_fail(display);
>      /* allow sized frames to be streamed, even if they where replaced by
>      another frame, since
>       * newer frames might not cover sized frames completely if they are
>       bigger */
>      if (item->stream && red_marshall_stream_data(rcc, m, item)) {
> @@ -2201,7 +2201,7 @@ static void marshall_stream_clip(RedChannelClient *rcc,
>      DisplayChannelClient *dcc = DISPLAY_CHANNEL_CLIENT(rcc);
>      VideoStreamAgent *agent = item->stream_agent;
> 
> -    spice_return_if_fail(agent->stream);
> +    g_return_if_fail(agent->stream);
> 
>      red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_CLIP);
>      SpiceMsgDisplayStreamClip stream_clip;
> diff --git a/server/dcc.c b/server/dcc.c
> index 15b65978..0b33d466 100644
> --- a/server/dcc.c
> +++ b/server/dcc.c
> @@ -232,7 +232,7 @@ bool
> dcc_clear_surface_drawables_from_pipe(DisplayChannelClient *dcc, int surfac
>      int x;
>      RedChannelClient *rcc;
> 
> -    spice_return_val_if_fail(dcc != NULL, TRUE);
> +    g_return_val_if_fail(dcc != NULL, TRUE);
>      /* removing the newest drawables that their destination is surface_id
>      and
>         no other drawable depends on them */
> 
> @@ -1009,20 +1009,20 @@ static bool dcc_handle_init(DisplayChannelClient
> *dcc, SpiceMsgcDisplayInit *ini
>      gboolean success;
>      RedClient *client =
>      red_channel_client_get_client(RED_CHANNEL_CLIENT(dcc));
> 
> -    spice_return_val_if_fail(dcc->priv->expect_init, FALSE);
> +    g_return_val_if_fail(dcc->priv->expect_init, FALSE);
>      dcc->priv->expect_init = FALSE;
> 
> -    spice_return_val_if_fail(!dcc->priv->pixmap_cache, FALSE);
> +    g_return_val_if_fail(!dcc->priv->pixmap_cache, FALSE);
>      dcc->priv->pixmap_cache = pixmap_cache_get(client,
>                                                 init->pixmap_cache_id,
>                                                 init->pixmap_cache_size);
> -    spice_return_val_if_fail(dcc->priv->pixmap_cache, FALSE);
> +    g_return_val_if_fail(dcc->priv->pixmap_cache, FALSE);
> 
>      success = image_encoders_get_glz_dictionary(&dcc->priv->encoders,
>                                                  client,
>                                                  init->glz_dictionary_id,
>                                                  init->glz_dictionary_window_size);
> -    spice_return_val_if_fail(success, FALSE);
> +    g_return_val_if_fail(success, FALSE);
> 
>      return TRUE;
>  }
> @@ -1121,7 +1121,7 @@ static void
> dcc_update_preferred_video_codecs(DisplayChannelClient *dcc)
>      GString *msg;
> 
>      server_codecs = display_channel_get_video_codecs(DCC_TO_DC(dcc));
> -    spice_return_if_fail(server_codecs != NULL);
> +    g_return_if_fail(server_codecs != NULL);
> 
>      /* Copy current host preference */
>      video_codecs = g_array_sized_new(FALSE, FALSE, sizeof(RedVideoCodec),
>      server_codecs->len);
> @@ -1313,9 +1313,9 @@ bool dcc_handle_migrate_data(DisplayChannelClient *dcc,
> uint32_t size, void *mes
>      uint8_t *surfaces;
>      int i;
> 
> -    spice_return_val_if_fail(
> +    g_return_val_if_fail(
>          size >= (sizeof(*migrate_data) + sizeof(SpiceMigrateDataHeader)),
>          FALSE);
> -    spice_return_val_if_fail(
> +    g_return_val_if_fail(
>           migration_protocol_validate_header(header,
>               SPICE_MIGRATE_DATA_DISPLAY_MAGIC,
>               SPICE_MIGRATE_DATA_DISPLAY_VERSION), FALSE);
> 
> @@ -1325,7 +1325,7 @@ bool dcc_handle_migrate_data(DisplayChannelClient *dcc,
> uint32_t size, void *mes
>       * pixmap_cache_reset */
>      dcc->priv->pixmap_cache =
>      pixmap_cache_get(red_channel_client_get_client(RED_CHANNEL_CLIENT(dcc)),
>                                                 migrate_data->pixmap_cache_id,
>                                                 -1);
> -    spice_return_val_if_fail(dcc->priv->pixmap_cache, FALSE);
> +    g_return_val_if_fail(dcc->priv->pixmap_cache, FALSE);
> 
>      pthread_mutex_lock(&dcc->priv->pixmap_cache->lock);
>      for (i = 0; i < MAX_CACHE_CLIENTS; i++) {
> @@ -1364,7 +1364,7 @@ bool dcc_handle_migrate_data(DisplayChannelClient *dcc,
> uint32_t size, void *mes
>          restore_surfaces_lossy(dcc, (MigrateDisplaySurfacesAtClientLossy
>          *)surfaces) :
>          restore_surfaces_lossless(dcc,
>          (MigrateDisplaySurfacesAtClientLossless*)surfaces);
> 
> -    spice_return_val_if_fail(surfaces_restored, FALSE);
> +    g_return_val_if_fail(surfaces_restored, FALSE);
> 
>      red_channel_client_pipe_add_type(RED_CHANNEL_CLIENT(dcc),
>      RED_PIPE_ITEM_TYPE_INVAL_PALETTE_CACHE);
>      /* enable sending messages */
> @@ -1428,7 +1428,7 @@ static void dcc_on_disconnect(RedChannelClient *rcc)
>      DisplayChannelClient *dcc;
> 
>      spice_debug("trace");
> -    spice_return_if_fail(rcc != NULL);
> +    g_return_if_fail(rcc != NULL);
> 
>      dcc = DISPLAY_CHANNEL_CLIENT(rcc);
>      display = DCC_TO_DC(dcc);
> diff --git a/server/display-channel.c b/server/display-channel.c
> index 229f2c0f..d0bfd304 100644
> --- a/server/display-channel.c
> +++ b/server/display-channel.c
> @@ -125,7 +125,7 @@ static Drawable
> *display_channel_drawable_try_new(DisplayChannel *display,
> 
>  uint32_t display_channel_generate_uid(DisplayChannel *display)
>  {
> -    spice_return_val_if_fail(display != NULL, 0);
> +    g_return_val_if_fail(display != NULL, 0);
> 
>      return ++display->priv->bits_unique;
>  }
> @@ -135,7 +135,7 @@ uint32_t display_channel_generate_uid(DisplayChannel
> *display)
> 
>  void display_channel_compress_stats_reset(DisplayChannel *display)
>  {
> -    spice_return_if_fail(display);
> +    g_return_if_fail(display);
> 
>      image_encoder_shared_stat_reset(&display->priv->encoder_shared_data);
>  }
> @@ -145,7 +145,7 @@ void display_channel_compress_stats_print(DisplayChannel
> *display_channel)
>  #ifdef COMPRESS_STAT
>      uint32_t id;
> 
> -    spice_return_if_fail(display_channel);
> +    g_return_if_fail(display_channel);
> 
>      g_object_get(display_channel, "id", &id, NULL);
> 
> @@ -222,8 +222,8 @@ int display_channel_get_streams_timeout(DisplayChannel
> *display)
> 
>  void display_channel_set_stream_video(DisplayChannel *display, int
>  stream_video)
>  {
> -    spice_return_if_fail(display);
> -    spice_return_if_fail(stream_video != SPICE_STREAM_VIDEO_INVALID);
> +    g_return_if_fail(display);
> +    g_return_if_fail(stream_video != SPICE_STREAM_VIDEO_INVALID);
> 
>      switch (stream_video) {
>      case SPICE_STREAM_VIDEO_ALL:
> @@ -245,7 +245,7 @@ void display_channel_set_stream_video(DisplayChannel
> *display, int stream_video)
> 
>  void display_channel_set_video_codecs(DisplayChannel *display, GArray
>  *video_codecs)
>  {
> -    spice_return_if_fail(display);
> +    g_return_if_fail(display);
> 
>      g_clear_pointer(&display->priv->video_codecs, g_array_unref);
>      display->priv->video_codecs = g_array_ref(video_codecs);
> @@ -254,7 +254,7 @@ void display_channel_set_video_codecs(DisplayChannel
> *display, GArray *video_cod
> 
>  GArray *display_channel_get_video_codecs(DisplayChannel *display)
>  {
> -    spice_return_val_if_fail(display, NULL);
> +    g_return_val_if_fail(display, NULL);
> 
>      return display->priv->video_codecs;
>  }
> @@ -1506,7 +1506,7 @@ void
> display_channel_free_glz_drawables_to_free(DisplayChannel *display)
>  {
>      DisplayChannelClient *dcc;
> 
> -    spice_return_if_fail(display);
> +    g_return_if_fail(display);
> 
>      FOREACH_DCC(display, dcc) {
>          image_encoders_free_glz_drawables_to_free(dcc_get_encoders(dcc));
> @@ -1517,7 +1517,7 @@ void display_channel_free_glz_drawables(DisplayChannel
> *display)
>  {
>      DisplayChannelClient *dcc;
> 
> -    spice_return_if_fail(display);
> +    g_return_if_fail(display);
> 
>      FOREACH_DCC(display, dcc) {
>          image_encoders_free_glz_drawables(dcc_get_encoders(dcc));
> @@ -1647,8 +1647,8 @@ static Drawable
> *display_channel_drawable_try_new(DisplayChannel *display,
> 
>  static void depended_item_remove(DependItem *item)
>  {
> -    spice_return_if_fail(item->drawable);
> -    spice_return_if_fail(ring_item_is_linked(&item->ring_item));
> +    g_return_if_fail(item->drawable);
> +    g_return_if_fail(ring_item_is_linked(&item->ring_item));
> 
>      item->drawable = NULL;
>      ring_remove(&item->ring_item);
> @@ -1733,7 +1733,7 @@ static void drawable_draw(DisplayChannel *display,
> Drawable *drawable)
> 
>      surface = &display->priv->surfaces[drawable->surface_id];
>      canvas = surface->context.canvas;
> -    spice_return_if_fail(canvas);
> +    g_return_if_fail(canvas);
> 
>      image_cache_aging(&display->priv->image_cache);
> 
> @@ -1876,7 +1876,7 @@ static void surface_update_dest(RedSurface *surface,
> const SpiceRect *area)
>      if (h == 0)
>          return;
> 
> -    spice_return_if_fail(stride < 0);
> +    g_return_if_fail(stride < 0);
> 
>      uint8_t *dest = line_0 + (area->top * stride) + area->left *
>      sizeof(uint32_t);
>      dest += (h - 1) * stride;
> @@ -1949,8 +1949,8 @@ void display_channel_draw_until(DisplayChannel
> *display, const SpiceRect *area,
>      RingItem *ring_item;
>      Drawable *now;
> 
> -    spice_return_if_fail(last);
> -    spice_return_if_fail(ring_item_is_linked(&last->list_link));
> +    g_return_if_fail(last);
> +    g_return_if_fail(ring_item_is_linked(&last->list_link));
> 
>      surface = &display->priv->surfaces[surface_id];
> 
> @@ -1992,9 +1992,9 @@ void display_channel_draw(DisplayChannel *display,
> const SpiceRect *area, int su
>      spice_debug("surface %d: area ==>", surface_id);
>      rect_debug(area);
> 
> -    spice_return_if_fail(surface_id >= 0 && surface_id < NUM_SURFACES);
> -    spice_return_if_fail(area);
> -    spice_return_if_fail(area->left >= 0 && area->top >= 0 &&
> +    g_return_if_fail(surface_id >= 0 && surface_id < NUM_SURFACES);
> +    g_return_if_fail(area);
> +    g_return_if_fail(area->left >= 0 && area->top >= 0 &&
>                           area->left < area->right && area->top <
>                           area->bottom);
> 
>      surface = &display->priv->surfaces[surface_id];
> @@ -2029,7 +2029,7 @@ void display_channel_update(DisplayChannel *display,
>      SpiceRect rect;
>      RedSurface *surface;
> 
> -    spice_return_if_fail(display_channel_validate_surface(display,
> surface_id));
> +    g_return_if_fail(display_channel_validate_surface(display, surface_id));
> 
>      red_get_rect_ptr(&rect, area);
>      display_channel_draw(display, &rect, surface_id);
> @@ -2188,7 +2188,7 @@ void display_channel_create_surface(DisplayChannel
> *display, uint32_t surface_id
>          surface->context.canvas = create_canvas_for_surface(display,
>          surface, display->priv->renderer);
>      }
> 
> -    spice_return_if_fail(surface->context.canvas);
> +    g_return_if_fail(surface->context.canvas);
>      if (send_client)
>          send_create_surface(display, surface_id, data_is_valid);
>  }
> @@ -2220,7 +2220,7 @@ static SpiceCanvas
> *image_surfaces_get(SpiceImageSurfaces *surfaces, uint32_t su
>      DisplayChannelPrivate *p = SPICE_CONTAINEROF(surfaces,
>      DisplayChannelPrivate, image_surfaces);
>      DisplayChannel *display = p->pub;
> 
> -    spice_return_val_if_fail(display_channel_validate_surface(display,
> surface_id), NULL);
> +    g_return_val_if_fail(display_channel_validate_surface(display,
> surface_id), NULL);
> 
>      return p->surfaces[surface_id].context.canvas;
>  }
> @@ -2396,7 +2396,7 @@ void display_channel_gl_draw(DisplayChannel *display,
> SpiceMsgDisplayGlDraw *dra
>  {
>      int num;
> 
> -    spice_return_if_fail(display->priv->gl_draw_async_count == 0);
> +    g_return_if_fail(display->priv->gl_draw_async_count == 0);
> 
>      num = red_channel_pipes_new_add(RED_CHANNEL(display),
>      dcc_gl_draw_item_new, draw);
>      set_gl_draw_async_count(display, num);
> @@ -2461,7 +2461,7 @@ void
> display_channel_set_monitors_config_to_primary(DisplayChannel *display)
>      QXLHead head = { 0, };
>      uint16_t old_max = 1;
> 
> -    spice_return_if_fail(display->priv->surfaces[0].context.canvas);
> +    g_return_if_fail(display->priv->surfaces[0].context.canvas);
> 
>      if (display->priv->monitors_config) {
>          old_max = display->priv->monitors_config->max_allowed;
> diff --git a/server/event-loop.c b/server/event-loop.c
> index 413102e8..f98a2003 100644
> --- a/server/event-loop.c
> +++ b/server/event-loop.c
> @@ -157,8 +157,8 @@ static SpiceWatch *watch_add(const
> SpiceCoreInterfaceInternal *iface,
>  {
>      SpiceWatch *watch;
> 
> -    spice_return_val_if_fail(fd != -1, NULL);
> -    spice_return_val_if_fail(func != NULL, NULL);
> +    g_return_val_if_fail(fd != -1, NULL);
> +    g_return_val_if_fail(func != NULL, NULL);
> 
>      watch = g_new0(SpiceWatch, 1);
>      watch->context = iface->main_context;
> diff --git a/server/gstreamer-encoder.c b/server/gstreamer-encoder.c
> index 04f0c02f..4aaa49cd 100644
> --- a/server/gstreamer-encoder.c
> +++ b/server/gstreamer-encoder.c
> @@ -1265,7 +1265,7 @@ static inline int line_copy(SpiceGstEncoder *encoder,
> const SpiceBitmap *bitmap,
>           dst += stream_stride;
>           chunk_offset += bitmap->stride;
>       }
> -     spice_return_val_if_fail(dst - buffer == stream_stride * height,
> FALSE);
> +     g_return_val_if_fail(dst - buffer == stream_stride * height, FALSE);
>       return TRUE;
>  }
> 
> @@ -1298,7 +1298,7 @@ static inline int chunk_copy(SpiceGstEncoder *encoder,
> const SpiceBitmap *bitmap
>          chunk_offset = 0;
>          chunk_index++;
>      }
> -    spice_return_val_if_fail(len == 0, FALSE);
> +    g_return_val_if_fail(len == 0, FALSE);
>      return TRUE;
>  }
> 
> @@ -1692,7 +1692,7 @@ static void spice_gst_encoder_get_stats(VideoEncoder
> *video_encoder,
>      SpiceGstEncoder *encoder = (SpiceGstEncoder*)video_encoder;
>      uint64_t raw_bit_rate = encoder->width * encoder->height *
>      encoder->format->bpp * get_source_fps(encoder);
> 
> -    spice_return_if_fail(stats != NULL);
> +    g_return_if_fail(stats != NULL);
>      stats->starting_bit_rate = encoder->starting_bit_rate;
>      stats->cur_bit_rate = get_effective_bit_rate(encoder);
> 
> @@ -1734,10 +1734,10 @@ VideoEncoder
> *gstreamer_encoder_new(SpiceVideoCodecType codec_type,
>                                      bitmap_unref_t bitmap_unref)
>  {
>      SPICE_VERIFY(SPICE_GST_FRAME_STATISTICS_COUNT <=
>      SPICE_GST_HISTORY_SIZE);
> -    spice_return_val_if_fail(codec_type == SPICE_VIDEO_CODEC_TYPE_MJPEG ||
> -                             codec_type == SPICE_VIDEO_CODEC_TYPE_VP8 ||
> -                             codec_type == SPICE_VIDEO_CODEC_TYPE_VP9 ||
> -                             codec_type == SPICE_VIDEO_CODEC_TYPE_H264,
> NULL);
> +    g_return_val_if_fail(codec_type == SPICE_VIDEO_CODEC_TYPE_MJPEG ||
> +                         codec_type == SPICE_VIDEO_CODEC_TYPE_VP8 ||
> +                         codec_type == SPICE_VIDEO_CODEC_TYPE_VP9 ||
> +                         codec_type == SPICE_VIDEO_CODEC_TYPE_H264, NULL);
> 
>      GError *err = NULL;
>      if (!gst_init_check(NULL, NULL, &err)) {
> diff --git a/server/image-encoders.c b/server/image-encoders.c
> index 880972e7..f9e910bb 100644
> --- a/server/image-encoders.c
> +++ b/server/image-encoders.c
> @@ -684,7 +684,7 @@ void image_encoders_glz_get_restore_data(ImageEncoders
> *enc,
>  static GlzSharedDictionary *glz_shared_dictionary_new(RedClient *client,
>  uint8_t id,
>                                                        GlzEncDictContext
>                                                        *dict)
>  {
> -    spice_return_val_if_fail(dict != NULL, NULL);
> +    g_return_val_if_fail(dict != NULL, NULL);
> 
>      GlzSharedDictionary *shared_dict = g_new0(GlzSharedDictionary, 1);
> 
> @@ -737,7 +737,7 @@ gboolean image_encoders_get_glz_dictionary(ImageEncoders
> *enc,
>  {
>      GlzSharedDictionary *shared_dict;
> 
> -    spice_return_val_if_fail(!enc->glz_dict, FALSE);
> +    g_return_val_if_fail(!enc->glz_dict, FALSE);
> 
>      pthread_mutex_lock(&glz_dictionary_list_lock);
> 
> @@ -774,7 +774,7 @@ gboolean
> image_encoders_restore_glz_dictionary(ImageEncoders *enc,
>  {
>      GlzSharedDictionary *shared_dict = NULL;
> 
> -    spice_return_val_if_fail(!enc->glz_dict, FALSE);
> +    g_return_val_if_fail(!enc->glz_dict, FALSE);
> 
>      pthread_mutex_lock(&glz_dictionary_list_lock);
> 
> diff --git a/server/memslot.c b/server/memslot.c
> index 7074b432..52a45356 100644
> --- a/server/memslot.c
> +++ b/server/memslot.c
> @@ -191,8 +191,8 @@ void memslot_info_add_slot(RedMemSlotInfo *info, uint32_t
> slot_group_id, uint32_
> 
>  void memslot_info_del_slot(RedMemSlotInfo *info, uint32_t slot_group_id,
>  uint32_t slot_id)
>  {
> -    spice_return_if_fail(info->num_memslots_groups > slot_group_id);
> -    spice_return_if_fail(info->num_memslots > slot_id);
> +    g_return_if_fail(info->num_memslots_groups > slot_group_id);
> +    g_return_if_fail(info->num_memslots > slot_id);
> 
>      info->mem_slots[slot_group_id][slot_id].virt_start_addr = 0;
>      info->mem_slots[slot_group_id][slot_id].virt_end_addr = 0;
> diff --git a/server/mjpeg-encoder.c b/server/mjpeg-encoder.c
> index d4b5c6fc..1744812c 100644
> --- a/server/mjpeg-encoder.c
> +++ b/server/mjpeg-encoder.c
> @@ -1355,7 +1355,7 @@ VideoEncoder *mjpeg_encoder_new(SpiceVideoCodecType
> codec_type,
>  {
>      MJpegEncoder *encoder;
> 
> -    spice_return_val_if_fail(codec_type == SPICE_VIDEO_CODEC_TYPE_MJPEG,
> NULL);
> +    g_return_val_if_fail(codec_type == SPICE_VIDEO_CODEC_TYPE_MJPEG, NULL);
> 
>      encoder = g_new0(MJpegEncoder, 1);
>      encoder->base.destroy = mjpeg_encoder_destroy;
> diff --git a/server/red-channel.c b/server/red-channel.c
> index 1b38f04d..cc683c46 100644
> --- a/server/red-channel.c
> +++ b/server/red-channel.c
> @@ -353,7 +353,7 @@ bool red_channel_is_waiting_for_migrate_data(RedChannel
> *channel)
> 
>  void red_channel_init_stat_node(RedChannel *channel, const RedStatNode
>  *parent, const char *name)
>  {
> -    spice_return_if_fail(channel != NULL);
> +    g_return_if_fail(channel != NULL);
> 
>      // TODO check not already initialized
>      stat_init_node(&channel->priv->stat, channel->priv->reds, parent, name,
>      TRUE);
> @@ -477,9 +477,9 @@ void red_channel_remove_client(RedChannel *channel,
> RedChannelClient *rcc)
>                              "this might be a BUG",
>                              channel->priv->thread_id, pthread_self());
>      }
> -    spice_return_if_fail(channel);
> +    g_return_if_fail(channel);
>      link = g_list_find(channel->priv->clients, rcc);
> -    spice_return_if_fail(link != NULL);
> +    g_return_if_fail(link != NULL);
> 
>      channel->priv->clients = g_list_delete_link(channel->priv->clients,
>      link);
>      // TODO: should we set rcc->channel to NULL???
> diff --git a/server/red-qxl.c b/server/red-qxl.c
> index 730b9f3d..aa00363c 100644
> --- a/server/red-qxl.c
> +++ b/server/red-qxl.c
> @@ -809,10 +809,10 @@ void spice_qxl_gl_scanout(QXLInstance *qxl,
>                            int y_0_top)
>  {
>      RedWorkerMessageGlScanout payload = { /* empty */ };
> -    spice_return_if_fail(qxl != NULL);
> +    g_return_if_fail(qxl != NULL);
> 
>      QXLState *qxl_state = qxl->st;
> -    spice_return_if_fail(qxl_state->gl_draw_cookie ==
> GL_DRAW_COOKIE_INVALID);
> +    g_return_if_fail(qxl_state->gl_draw_cookie == GL_DRAW_COOKIE_INVALID);
> 
>      pthread_mutex_lock(&qxl_state->scanout_mutex);
> 
> @@ -855,14 +855,14 @@ void spice_qxl_gl_draw_async(QXLInstance *qxl,
>          },
>      };
> 
> -    spice_return_if_fail(qxl != NULL);
> +    g_return_if_fail(qxl != NULL);
>      qxl_state = qxl->st;
>      if (qxl_state->scanout.drm_dma_buf_fd == -1) {
>          spice_warning("called spice_qxl_gl_draw_async without a buffer");
>          red_qxl_async_complete(qxl, cookie);
>          return;
>      }
> -    spice_return_if_fail(qxl_state->gl_draw_cookie ==
> GL_DRAW_COOKIE_INVALID);
> +    g_return_if_fail(qxl_state->gl_draw_cookie == GL_DRAW_COOKIE_INVALID);
> 
>      qxl_state->gl_draw_cookie = cookie;
>      dispatcher_send_message(qxl_state->dispatcher, message, &draw);
> @@ -882,7 +882,7 @@ void red_qxl_init(RedsState *reds, QXLInstance *qxl)
>      ClientCbs client_cursor_cbs = { NULL, };
>      ClientCbs client_display_cbs = { NULL, };
> 
> -    spice_return_if_fail(qxl != NULL);
> +    g_return_if_fail(qxl != NULL);
> 
>      qxl_state = g_new0(QXLState, 1);
>      qxl_state->reds = reds;
> @@ -930,7 +930,7 @@ void red_qxl_init(RedsState *reds, QXLInstance *qxl)
> 
>  void red_qxl_destroy(QXLInstance *qxl)
>  {
> -    spice_return_if_fail(qxl->st != NULL && qxl->st->dispatcher != NULL);
> +    g_return_if_fail(qxl->st != NULL && qxl->st->dispatcher != NULL);
> 
>      QXLState *qxl_state = qxl->st;
> 
> @@ -954,7 +954,7 @@ Dispatcher *red_qxl_get_dispatcher(QXLInstance *qxl)
> 
>  void red_qxl_clear_pending(QXLState *qxl_state, int pending)
>  {
> -    spice_return_if_fail(qxl_state != NULL);
> +    g_return_if_fail(qxl_state != NULL);
> 
>      clear_bit(pending, &qxl_state->pending);
>  }
> diff --git a/server/red-replay-qxl.c b/server/red-replay-qxl.c
> index 18f348a1..5b197be4 100644
> --- a/server/red-replay-qxl.c
> +++ b/server/red-replay-qxl.c
> @@ -1379,13 +1379,13 @@ error:
> 
>  SPICE_GNUC_VISIBLE void spice_replay_free_cmd(SpiceReplay *replay,
>  QXLCommandExt *cmd)
>  {
> -    spice_return_if_fail(replay);
> -    spice_return_if_fail(cmd);
> +    g_return_if_fail(replay);
> +    g_return_if_fail(cmd);
> 
>      switch (cmd->cmd.type) {
>      case QXL_CMD_DRAW: {
>          // FIXME: compat flag must be saved somewhere...
> -        spice_return_if_fail(cmd->flags == 0);
> +        g_return_if_fail(cmd->flags == 0);
>          QXLDrawable *qxl = QXLPHYSICAL_TO_PTR(cmd->cmd.data);
>          red_replay_native_drawable_free(replay, qxl, cmd->flags);
>          break;
> @@ -1420,7 +1420,7 @@ SpiceReplay *spice_replay_new(FILE *file, int
> nsurfaces)
>      unsigned int version = 0;
>      SpiceReplay *replay;
> 
> -    spice_return_val_if_fail(file != NULL, NULL);
> +    g_return_val_if_fail(file != NULL, NULL);
> 
>      if (fscanf(file, "SPICE_REPLAY %u\n", &version) == 1) {
>          if (version != 1) {
> @@ -1453,7 +1453,7 @@ SpiceReplay *spice_replay_new(FILE *file, int
> nsurfaces)
> 
>  SPICE_GNUC_VISIBLE void spice_replay_free(SpiceReplay *replay)
>  {
> -    spice_return_if_fail(replay != NULL);
> +    g_return_if_fail(replay != NULL);
> 
>      g_list_free_full(replay->allocated, g_free);
>      pthread_mutex_destroy(&replay->mutex);
> diff --git a/server/red-stream.c b/server/red-stream.c
> index 18c4a935..6158be59 100644
> --- a/server/red-stream.c
> +++ b/server/red-stream.c
> @@ -270,7 +270,7 @@ ssize_t red_stream_write(RedStream *s, const void *buf,
> size_t nbyte)
> 
>  int red_stream_get_family(const RedStream *s)
>  {
> -    spice_return_val_if_fail(s != NULL, -1);
> +    g_return_val_if_fail(s != NULL, -1);
> 
>      if (s->socket == -1)
>          return -1;
> @@ -280,7 +280,7 @@ int red_stream_get_family(const RedStream *s)
> 
>  bool red_stream_is_plain_unix(const RedStream *s)
>  {
> -    spice_return_val_if_fail(s != NULL, false);
> +    g_return_val_if_fail(s != NULL, false);
> 
>      if (red_stream_get_family(s) != AF_UNIX) {
>          return false;
> @@ -329,7 +329,7 @@ int red_stream_send_msgfd(RedStream *stream, int fd)
>          char data[CMSG_SPACE(fd_size)];
>      } control;
> 
> -    spice_return_val_if_fail(red_stream_is_plain_unix(stream), -1);
> +    g_return_val_if_fail(red_stream_is_plain_unix(stream), -1);
> 
>      /* set the payload */
>      iov.iov_base = (char*)"@";
> diff --git a/server/red-worker.c b/server/red-worker.c
> index fe4cd325..fcd2b4f9 100644
> --- a/server/red-worker.c
> +++ b/server/red-worker.c
> @@ -421,8 +421,8 @@ static void handle_dev_update_async(void *opaque, void
> *payload)
>      QXLRect *qxl_dirty_rects = NULL;
>      uint32_t num_dirty_rects = 0;
> 
> -    spice_return_if_fail(worker->running);
> -
> spice_return_if_fail(qxl_get_interface(worker->qxl)->update_area_complete);
> +    g_return_if_fail(worker->running);
> +    g_return_if_fail(qxl_get_interface(worker->qxl)->update_area_complete);
> 
>      flush_display_commands(worker);
>      display_channel_update(worker->display_channel,
> @@ -441,7 +441,7 @@ static void handle_dev_update(void *opaque, void
> *payload)
>      RedWorkerMessageUpdate *msg = payload;
>      QXLRect *qxl_dirty_rects = msg->qxl_dirty_rects;
> 
> -    spice_return_if_fail(worker->running);
> +    g_return_if_fail(worker->running);
> 
>      flush_display_commands(worker);
>      display_channel_update(worker->display_channel,
> @@ -467,7 +467,7 @@ static void handle_dev_destroy_surface_wait(void *opaque,
> void *payload)
>      RedWorkerMessageDestroySurfaceWait *msg = payload;
>      RedWorker *worker = opaque;
> 
> -    spice_return_if_fail(msg->surface_id == 0);
> +    g_return_if_fail(msg->surface_id == 0);
> 
>      flush_all_qxl_commands(worker);
>      display_channel_destroy_surface_wait(worker->display_channel,
>      msg->surface_id);
> @@ -653,7 +653,7 @@ static void handle_dev_oom(void *opaque, void *payload)
>      RedChannel *display_red_channel = RED_CHANNEL(display);
>      int ring_is_empty;
> 
> -    spice_return_if_fail(worker->running);
> +    g_return_if_fail(worker->running);
>      // streams? but without streams also leak
>      display_channel_debug_oom(display, "OOM1");
>      while (red_process_display(worker, &ring_is_empty)) {
> @@ -719,7 +719,7 @@ static void handle_dev_display_connect(void *opaque, void
> *payload)
>      DisplayChannelClient *dcc;
> 
>      spice_debug("connect new client");
> -    spice_return_if_fail(display);
> +    g_return_if_fail(display);
> 
>      dcc = dcc_new(display, msg->client, msg->stream, msg->migration,
>      &msg->caps,
>                    worker->image_compression, worker->jpeg_state,
>                    worker->zlib_glz_state);
> @@ -829,7 +829,7 @@ static void handle_dev_cursor_disconnect(void *opaque,
> void *payload)
>      RedChannelClient *rcc = msg->rcc;
> 
>      spice_debug("disconnect cursor client");
> -    spice_return_if_fail(rcc);
> +    g_return_if_fail(rcc);
>      red_channel_client_disconnect(rcc);
>  }
> 
> @@ -1385,8 +1385,8 @@ bool red_worker_run(RedWorker *worker)
>      sigset_t curr_sig_mask;
>      int r;
> 
> -    spice_return_val_if_fail(worker, FALSE);
> -    spice_return_val_if_fail(!worker->thread, FALSE);
> +    g_return_val_if_fail(worker, FALSE);
> +    g_return_val_if_fail(!worker->thread, FALSE);
> 
>      sigfillset(&thread_sig_mask);
>      sigdelset(&thread_sig_mask, SIGILL);
> diff --git a/server/reds.c b/server/reds.c
> index 935448d8..40146e55 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -3972,7 +3972,7 @@ static void reds_set_video_codecs(RedsState *reds,
> GArray *video_codecs)
>      /* The video_codecs array is immutable */
>      g_clear_pointer(&reds->config->video_codecs, g_array_unref);
> 
> -    spice_return_if_fail(video_codecs != NULL);
> +    g_return_if_fail(video_codecs != NULL);
> 
>      reds->config->video_codecs = video_codecs;
>  }
> diff --git a/server/spice-bitmap-utils.h b/server/spice-bitmap-utils.h
> index 517ddabf..b4d72525 100644
> --- a/server/spice-bitmap-utils.h
> +++ b/server/spice-bitmap-utils.h
> @@ -53,7 +53,7 @@ static inline int bitmap_fmt_get_bytes_per_pixel(uint8_t
> fmt)
>  {
>      static const int bytes_per_pixel[] = {0, 0, 0, 0, 0, 1, 2, 3, 4, 4, 1};
> 
> -    spice_return_val_if_fail(fmt < SPICE_N_ELEMENTS(bytes_per_pixel), 0);
> +    g_return_val_if_fail(fmt < SPICE_N_ELEMENTS(bytes_per_pixel), 0);
> 
>      return bytes_per_pixel[fmt];
>  }
> @@ -63,7 +63,7 @@ static inline int bitmap_fmt_is_plt(uint8_t fmt)
>  {
>      static const int fmt_is_plt[] = {0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0};
> 
> -    spice_return_val_if_fail(fmt < SPICE_N_ELEMENTS(fmt_is_plt), 0);
> +    g_return_val_if_fail(fmt < SPICE_N_ELEMENTS(fmt_is_plt), 0);
> 
>      return fmt_is_plt[fmt];
>  }
> @@ -72,7 +72,7 @@ static inline int bitmap_fmt_is_rgb(uint8_t fmt)
>  {
>      static const int fmt_is_rgb[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1};
> 
> -    spice_return_val_if_fail(fmt < SPICE_N_ELEMENTS(fmt_is_rgb), 0);
> +    g_return_val_if_fail(fmt < SPICE_N_ELEMENTS(fmt_is_rgb), 0);
> 
>      return fmt_is_rgb[fmt];
>  }
> diff --git a/server/stream-channel.c b/server/stream-channel.c
> index 680fa3d1..ae069251 100644
> --- a/server/stream-channel.c
> +++ b/server/stream-channel.c
> @@ -398,10 +398,10 @@ stream_channel_connect(RedChannel *red_channel,
> RedClient *red_client, RedStream
>      } start_msg;
>      StreamMsgStartStop *const start = &start_msg.base;
> 
> -    spice_return_if_fail(stream != NULL);
> +    g_return_if_fail(stream != NULL);
> 
>      client = stream_channel_client_new(channel, red_client, stream,
>      migration, caps);
> -    spice_return_if_fail(client != NULL);
> +    g_return_if_fail(client != NULL);
> 
>      // request new stream
>      start->num_codecs = stream_channel_get_supported_codecs(channel,
>      start->codecs);
> diff --git a/server/tests/test-stream.c b/server/tests/test-stream.c
> index d56109d1..1f53d2d9 100644
> --- a/server/tests/test-stream.c
> +++ b/server/tests/test-stream.c
> @@ -106,7 +106,7 @@ int main(int argc, char *argv[])
>      int ret, fd = -1;
>      char c;
> 
> -    spice_return_val_if_fail(server_init() == 0, -1);
> +    g_return_val_if_fail(server_init() == 0, -1);
> 
>      if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sv) == -1) {
>          spice_error("socketpair failed %s", strerror(errno));
> diff --git a/server/tree.c b/server/tree.c
> index 89186a85..c013b1f0 100644
> --- a/server/tree.c
> +++ b/server/tree.c
> @@ -181,7 +181,7 @@ void tree_item_dump(TreeItem *item)
>  {
>      DumpItem di = { 0, };
> 
> -    spice_return_if_fail(item != NULL);
> +    g_return_if_fail(item != NULL);
>      tree_foreach(item, dump_item, &di);
>  }
> 
> @@ -190,7 +190,7 @@ void tree_item_dump(TreeItem *item)
>   * DrawItem represents the destination region for the operation */
>  Shadow* shadow_new(DrawItem *item, const SpicePoint *delta)
>  {
> -    spice_return_val_if_fail(item->shadow == NULL, NULL);
> +    g_return_val_if_fail(item->shadow == NULL, NULL);
>      if (!delta->x && !delta->y) {
>          return NULL;
>      }
> @@ -233,7 +233,7 @@ Container* container_new(DrawItem *item)
> 
>  void container_free(Container *container)
>  {
> -    spice_return_if_fail(ring_is_empty(&container->items));
> +    g_return_if_fail(ring_is_empty(&container->items));
> 
>      ring_remove(&container->base.siblings_link);
>      region_destroy(&container->base.rgn);
> diff --git a/server/video-stream.c b/server/video-stream.c
> index a4b83b4f..557379f6 100644
> --- a/server/video-stream.c
> +++ b/server/video-stream.c
> @@ -99,8 +99,8 @@ void video_stream_stop(DisplayChannel *display, VideoStream
> *stream)
>      DisplayChannelClient *dcc;
>      int stream_id = display_channel_get_video_stream_id(display, stream);
> 
> -    spice_return_if_fail(ring_item_is_linked(&stream->link));
> -    spice_return_if_fail(!stream->current);
> +    g_return_if_fail(ring_item_is_linked(&stream->link));
> +    g_return_if_fail(!stream->current);
> 
>      spice_debug("stream %d", stream_id);
>      FOREACH_DCC(display, dcc) {
> @@ -205,7 +205,7 @@ static int is_stream_start(Drawable *drawable)
>  static void update_copy_graduality(DisplayChannel *display, Drawable
>  *drawable)
>  {
>      SpiceBitmap *bitmap;
> -    spice_return_if_fail(drawable->red_drawable->type == QXL_DRAW_COPY);
> +    g_return_if_fail(drawable->red_drawable->type == QXL_DRAW_COPY);
> 
>      if (display_channel_get_stream_video(display) !=
>      SPICE_STREAM_VIDEO_FILTER) {
>          drawable->copy_bitmap_graduality = BITMAP_GRADUAL_INVALID;
> @@ -346,7 +346,7 @@ static void before_reattach_stream(DisplayChannel
> *display,
>      VideoStreamAgent *agent;
>      GList *dpi_link, *dpi_next;
> 
> -    spice_return_if_fail(stream->current);
> +    g_return_if_fail(stream->current);
> 
>      if (!red_channel_is_connected(RED_CHANNEL(display))) {
>          return;
> @@ -732,7 +732,7 @@ void dcc_create_stream(DisplayChannelClient *dcc,
> VideoStream *stream)
>      int stream_id = display_channel_get_video_stream_id(DCC_TO_DC(dcc),
>      stream);
>      VideoStreamAgent *agent = dcc_get_video_stream_agent(dcc, stream_id);
> 
> -    spice_return_if_fail(region_is_empty(&agent->vis_region));
> +    g_return_if_fail(region_is_empty(&agent->vis_region));
> 
>      if (stream->current) {
>          region_clone(&agent->vis_region,
>          &stream->current->tree_item.base.rgn);

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel





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