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

Submitted by Frediano Ziglio on Dec. 8, 2016, 12:34 p.m.

Details

Message ID 20161208123404.30755-1-fziglio@redhat.com
State Accepted
Headers show
Series "Marshaller: rename _add_ref() to _add_by_ref()" ( rev: 3 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio Dec. 8, 2016, 12:34 p.m.
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@redhat.com>
---
 server/char-device.c         | 16 ++++++++--------
 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 +-
 7 files changed, 25 insertions(+), 24 deletions(-)

Changes since v1:
- added 2 missing renames (strangely were not triggering any
  warnings/errors).

Patch hide | download patch | download mbox

diff --git a/server/char-device.c b/server/char-device.c
index 45ce548..c40ed65 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -893,10 +893,10 @@  void red_char_device_migrate_data_marshall(RedCharDevice *dev,
     if (dev->priv->cur_write_buf) {
         uint32_t buf_remaining = dev->priv->cur_write_buf->buf + dev->priv->cur_write_buf->buf_used -
                                  dev->priv->cur_write_buf_pos;
-        spice_marshaller_add_ref_full(m2, dev->priv->cur_write_buf_pos, buf_remaining,
-                                      migrate_data_marshaller_write_buffer_free,
-                                      red_char_device_write_buffer_ref(dev->priv->cur_write_buf)
-                                      );
+        spice_marshaller_add_by_ref_full(m2, dev->priv->cur_write_buf_pos, buf_remaining,
+                                         migrate_data_marshaller_write_buffer_free,
+                                         red_char_device_write_buffer_ref(dev->priv->cur_write_buf)
+                                         );
         *write_to_dev_size_ptr += buf_remaining;
         if (dev->priv->cur_write_buf->origin == WRITE_BUFFER_ORIGIN_CLIENT) {
             spice_assert(dev->priv->cur_write_buf->client == dev_client->client);
@@ -907,10 +907,10 @@  void red_char_device_migrate_data_marshall(RedCharDevice *dev,
     for (item = g_queue_peek_tail_link(&dev->priv->write_queue); item != NULL; item = item->prev) {
         RedCharDeviceWriteBuffer *write_buf = item->data;
 
-        spice_marshaller_add_ref_full(m2, write_buf->buf, write_buf->buf_used,
-                                      migrate_data_marshaller_write_buffer_free,
-                                      red_char_device_write_buffer_ref(write_buf)
-                                      );
+        spice_marshaller_add_by_ref_full(m2, write_buf->buf, write_buf->buf_used,
+                                         migrate_data_marshaller_write_buffer_free,
+                                         red_char_device_write_buffer_ref(write_buf)
+                                         );
         *write_to_dev_size_ptr += write_buf->buf_used;
         if (write_buf->origin == WRITE_BUFFER_ORIGIN_CLIENT) {
             spice_assert(write_buf->client == dev_client->client);
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_free, 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_marshaller, &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_buffer, 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_client->codec) * sizeof(frame->samples[0]));
+        spice_marshaller_add_by_ref(m, (uint8_t *)frame->samples,
+                                    snd_codec_frame_size(playback_client->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