[Spice-devel] [PATCH spice v2 1/3] Allow to compile without RED_STATISTICS

Pavel Grunt pgrunt at redhat.com
Tue Nov 1 11:02:43 UTC 2016


---
v2: applied Frediano's suggestions
---
 server/dcc-send.c            |  2 +-
 server/main-channel-client.c |  3 +++
 server/red-channel.c         | 11 ++++++-----
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/server/dcc-send.c b/server/dcc-send.c
index 01722c5..5f9ea45 100644
--- a/server/dcc-send.c
+++ b/server/dcc-send.c
@@ -185,7 +185,7 @@ static void red_display_add_image_to_pixmap_cache(RedChannelClient *rcc,
                                                   SpiceImage *image, SpiceImage *io_image,
                                                   int is_lossy)
 {
-    DisplayChannel *display_channel =
+    DisplayChannel *display_channel G_GNUC_UNUSED =
         DISPLAY_CHANNEL(red_channel_client_get_channel(rcc));
     DisplayChannelClient *dcc = DISPLAY_CHANNEL_CLIENT(rcc);
 
diff --git a/server/main-channel-client.c b/server/main-channel-client.c
index 836c50e..f933717 100644
--- a/server/main-channel-client.c
+++ b/server/main-channel-client.c
@@ -161,7 +161,10 @@ static void main_channel_client_set_property(GObject *object,
     }
 }
 
+#ifdef RED_STATISTICS
 static void ping_timer_cb(void *opaque);
+#endif
+
 static void main_channel_client_constructed(GObject *object)
 {
     G_OBJECT_CLASS(main_channel_client_parent_class)->constructed(object);
diff --git a/server/red-channel.c b/server/red-channel.c
index 8f9ae6c..bb896c7 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -209,12 +209,14 @@ static void red_channel_client_default_peer_on_error(RedChannelClient *rcc)
 
 static void red_channel_on_output(void *opaque, int n)
 {
-    RedChannelClient *rcc = opaque;
-    RedChannel *self = red_channel_client_get_channel(rcc);
+    RedChannelClient *rcc G_GNUC_UNUSED;
+    RedChannel *self G_GNUC_UNUSED;
 
     red_channel_client_on_output(opaque, n);
-
+#ifdef RED_STATISTICS
+    self = red_channel_client_get_channel((RedChannelClient *)opaque);
     stat_inc_counter(self->priv->reds, self->priv->out_bytes_counter, n);
+#endif
 }
 
 static void
@@ -336,7 +338,6 @@ red_channel_init(RedChannel *self)
 
     red_channel_set_common_cap(self, SPICE_COMMON_CAP_MINI_HEADER);
     self->priv->thread_id = pthread_self();
-    self->priv->out_bytes_counter = 0;
 
     // TODO: send incoming_cb as parameters instead of duplicating?
     self->priv->incoming_cb.on_error =
@@ -436,9 +437,9 @@ int red_channel_is_waiting_for_migrate_data(RedChannel *channel)
 void red_channel_set_stat_node(RedChannel *channel, StatNodeRef stat)
 {
     spice_return_if_fail(channel != NULL);
+#ifdef RED_STATISTICS
     spice_return_if_fail(channel->priv->stat == 0);
 
-#ifdef RED_STATISTICS
     channel->priv->stat = stat;
     channel->priv->out_bytes_counter =
         stat_add_counter(channel->priv->reds, stat, "out_bytes", TRUE);
-- 
2.10.1



More information about the Spice-devel mailing list