[Spice-devel] [PATCH spice-server] marshaller: rename _add_ref() to _add_by_ref()

Pavel Grunt pgrunt at redhat.com
Thu Dec 8 12:22:25 UTC 2016


I did git clean && ./autogen.sh && mak

and
It does not compile:
make[4]: Entering directory '/home/pgrunt/src/spice/server/tests'
  CCLD     test-display-no-ssl
../../server/.libs/libserver.a(smartcard-channel-client.o): In
function `smartcard_channel_client_send_data':
/home/pgrunt/src/spice/server/smartcard-channel-client.c:215:
undefined reference to `spice_marshaller_add_ref'
../../server/.libs/libserver.a(char-device.o): In function
`red_char_device_migrate_data_marshall':
/home/pgrunt/src/spice/server/char-device.c:896: undefined reference
to `spice_marshaller_add_ref_full'
/home/pgrunt/src/spice/server/char-device.c:910: undefined reference
to `spice_marshaller_add_ref_full'


Pavel 

On Thu, 2016-12-08 at 11:58 +0000, Frediano Ziglio wrote:
> The spice_marshaller_add_ref() family of functions is confusing
> since it
> sounds like you're incrementing a reference on the marshaller. What
> it
> is actually doing is adding a data buffer to the marshaller by
> reference
> rather than by value. Changing the function names to _add_by_ref()
> makes
> this clearer.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/cursor-channel.c      |  2 +-
>  server/dcc-send.c            | 16 ++++++++--------
>  server/main-channel-client.c |  4 ++--
>  server/sound.c               |  7 ++++---
>  server/spicevmc.c            |  2 +-
>  spice-common                 |  2 +-
>  6 files changed, 17 insertions(+), 16 deletions(-)
> 
> diff --git a/server/cursor-channel.c b/server/cursor-channel.c
> index e421bf7..d83e820 100644
> --- a/server/cursor-channel.c
> +++ b/server/cursor-channel.c
> @@ -131,7 +131,7 @@ typedef struct {
>  static void add_buf_from_info(SpiceMarshaller *m, AddBufInfo *info)
>  {
>      if (info->data) {
> -        spice_marshaller_add_ref(m, info->data, info->size);
> +        spice_marshaller_add_by_ref(m, info->data, info->size);
>      }
>  }
>  
> diff --git a/server/dcc-send.c b/server/dcc-send.c
> index 4c739c8..edeea62 100644
> --- a/server/dcc-send.c
> +++ b/server/dcc-send.c
> @@ -337,8 +337,8 @@ static void
> marshaller_add_compressed(SpiceMarshaller *m,
>          spice_return_if_fail(comp_buf);
>          now = MIN(sizeof(comp_buf->buf), max);
>          max -= now;
> -        spice_marshaller_add_ref_full(m, comp_buf->buf.bytes, now,
> -                                      marshaller_compress_buf_free,
> comp_buf);
> +        spice_marshaller_add_by_ref_full(m, comp_buf->buf.bytes,
> now,
> +                                         marshaller_compress_buf_fr
> ee, comp_buf);
>          comp_buf = comp_buf->send_next;
>      } while (max);
>  }
> @@ -449,7 +449,7 @@ static FillBitsType
> fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
>                  spice_marshall_Palette(bitmap_palette_out,
> palette);
>              }
>  
> -            spice_marshaller_add_ref_chunks(m, bitmap->data);
> +            spice_marshaller_add_chunks_by_ref(m, bitmap->data);
>              pthread_mutex_unlock(&dcc->priv->pixmap_cache->lock);
>              return FILL_BITS_TYPE_BITMAP;
>          } else {
> @@ -481,7 +481,7 @@ static FillBitsType
> fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
>                               &bitmap_palette_out,
> &lzplt_palette_out);
>          spice_assert(bitmap_palette_out == NULL);
>          spice_assert(lzplt_palette_out == NULL);
> -        spice_marshaller_add_ref_chunks(m, image.u.quic.data);
> +        spice_marshaller_add_chunks_by_ref(m, image.u.quic.data);
>          pthread_mutex_unlock(&dcc->priv->pixmap_cache->lock);
>          return FILL_BITS_TYPE_COMPRESS_LOSSLESS;
>      default:
> @@ -1741,8 +1741,8 @@ static int
> red_marshall_stream_data(RedChannelClient *rcc,
>          rect_debug(&stream_data.dest);
>          spice_marshall_msg_display_stream_data_sized(base_marshalle
> r, &stream_data);
>      }
> -    spice_marshaller_add_ref_full(base_marshaller, outbuf->data,
> outbuf->size,
> -                                  &red_release_video_encoder_buffer
> , outbuf);
> +    spice_marshaller_add_by_ref_full(base_marshaller, outbuf->data, 
> outbuf->size,
> +                                     &red_release_video_encoder_buf
> fer, outbuf);
>  #ifdef STREAM_STATS
>      agent->stats.num_frames_sent++;
>      agent->stats.size_sent += outbuf->size;
> @@ -1984,8 +1984,8 @@ static void
> red_marshall_image(RedChannelClient *rcc,
>  
>          spice_marshall_Image(src_bitmap_out, &red_image,
>                               &bitmap_palette_out,
> &lzplt_palette_out);
> -        spice_marshaller_add_ref(src_bitmap_out, item->data,
> -                                 bitmap.y * bitmap.stride);
> +        spice_marshaller_add_by_ref(src_bitmap_out, item->data,
> +                                    bitmap.y * bitmap.stride);
>          region_remove(surface_lossy_region, &copy.base.box);
>      }
>      spice_chunks_destroy(chunks);
> diff --git a/server/main-channel-client.c b/server/main-channel-
> client.c
> index 15e168d..7e1b1fc 100644
> --- a/server/main-channel-client.c
> +++ b/server/main-channel-client.c
> @@ -793,7 +793,7 @@ static void
> main_channel_marshall_ping(RedChannelClient *rcc,
>      while (size_left > 0) {
>          int now = MIN(ZERO_BUF_SIZE, size_left);
>          size_left -= now;
> -        spice_marshaller_add_ref(m, zero_page, now);
> +        spice_marshaller_add_by_ref(m, zero_page, now);
>      }
>  }
>  
> @@ -838,7 +838,7 @@ static void
> main_channel_marshall_agent_data(RedChannelClient *rcc,
>                                               RedAgentDataPipeItem
> *item)
>  {
>      red_channel_client_init_send_data(rcc,
> SPICE_MSG_MAIN_AGENT_DATA, &item->base);
> -    spice_marshaller_add_ref(m, item->data, item->len);
> +    spice_marshaller_add_by_ref(m, item->data, item->len);
>  }
>  
>  static void
> main_channel_marshall_migrate_data_item(RedChannelClient *rcc,
> diff --git a/server/sound.c b/server/sound.c
> index 534f23a..310ff6e 100644
> --- a/server/sound.c
> +++ b/server/sound.c
> @@ -806,8 +806,9 @@ static int
> snd_playback_send_write(PlaybackChannelClient *playback_client)
>      spice_marshall_msg_playback_data(m, &msg);
>  
>      if (playback_client->mode == SPICE_AUDIO_DATA_MODE_RAW) {
> -        spice_marshaller_add_ref(m, (uint8_t *)frame->samples,
> -                                 snd_codec_frame_size(playback_clie
> nt->codec) * sizeof(frame->samples[0]));
> +        spice_marshaller_add_by_ref(m, (uint8_t *)frame->samples,
> +                                    snd_codec_frame_size(playback_c
> lient->codec) *
> +                                    sizeof(frame->samples[0]));
>      }
>      else {
>          int n = sizeof(playback_client->encode_buf);
> @@ -818,7 +819,7 @@ static int
> snd_playback_send_write(PlaybackChannelClient *playback_client)
>              snd_disconnect_channel(client);
>              return FALSE;
>          }
> -        spice_marshaller_add_ref(m, playback_client->encode_buf,
> n);
> +        spice_marshaller_add_by_ref(m, playback_client->encode_buf, 
> n);
>      }
>  
>      return snd_begin_send_message(client);
> diff --git a/server/spicevmc.c b/server/spicevmc.c
> index 039a50a..765d287 100644
> --- a/server/spicevmc.c
> +++ b/server/spicevmc.c
> @@ -645,7 +645,7 @@ static void
> spicevmc_red_channel_send_data(RedChannelClient *rcc,
>          };
>          spice_marshall_SpiceMsgCompressedData(m, &compressed_msg);
>      }
> -    spice_marshaller_add_ref(m, i->buf, i->buf_used);
> +    spice_marshaller_add_by_ref(m, i->buf, i->buf_used);
>  }
>  
>  static void spicevmc_red_channel_send_migrate_data(RedChannelClient
> *rcc,
> diff --git a/spice-common b/spice-common
> index 6b409c4..adb36c6 160000
> --- a/spice-common
> +++ b/spice-common
> @@ -1 +1 @@
> -Subproject commit 6b409c4a7979f043a997ae762f16c6edec68345e
> +Subproject commit adb36c6185a363c3f5775559fb1dbfba1cdccaf4


More information about the Spice-devel mailing list