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

Frediano Ziglio fziglio at redhat.com
Thu Oct 27 10:09:33 UTC 2016


> 
> On Wed, 2016-10-26 at 10:54 -0400, Frediano Ziglio wrote:
> > Looks like we are working on similar stuff!
> 
> 
> > 
> > > 
> > > ---
> > >  server/dcc-send.c            | 2 +-
> > >  server/main-channel-client.c | 2 +-
> > >  server/red-channel.c         | 6 ++----
> > >  3 files changed, 4 insertions(+), 6 deletions(-)
> > > 
> > > diff --git a/server/dcc-send.c b/server/dcc-send.c
> > > index ef67f97..54844cf 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..0c8a3a4 100644
> > > --- a/server/main-channel-client.c
> > > +++ b/server/main-channel-client.c
> > > @@ -161,11 +161,11 @@ static void
> > > main_channel_client_set_property(GObject
> > > *object,
> > >      }
> > >  }
> > >  
> > > -static void ping_timer_cb(void *opaque);
> > >  static void main_channel_client_constructed(GObject *object)
> > >  {
> > >      G_OBJECT_CLASS(main_channel_client_parent_class)-
> > > >constructed(object);
> > >  #ifdef RED_STATISTICS
> > > +    static void ping_timer_cb(void *opaque);
> > >      MainChannelClient *self = MAIN_CHANNEL_CLIENT(object);
> > >      RedsState *reds =
> > >          red_channel_get_server(red_channel_client_get_channel(RED
> > > _CHANNEL_CLIENT(object)));
> > 
> > I think this does not compile or cause a warning+error on rhel6.
> ok, i will fix it
> > 
> > > diff --git a/server/red-channel.c b/server/red-channel.c
> > > index 3b14fbf..12bf941 100644
> > > --- a/server/red-channel.c
> > > +++ b/server/red-channel.c
> > > @@ -104,10 +104,8 @@ struct RedChannelPrivate
> > >      // from Channel -> need to protect!
> > >      pthread_t thread_id;
> > >      RedsState *reds;
> > > -#ifdef RED_STATISTICS
> > >      StatNodeRef stat;
> > >      uint64_t *out_bytes_counter;
> > > -#endif
> > >  };
> > >  
> > >  enum {
> > 
> > This is weird, you should not need this.
> they have to be declared since they are used:
> out_bytes_counter is set in red_channel_init
> red_channel_set_stat_node checks  'stat'
> 
> of course these can be avoided by putting ifdefs where needed, but I
> though the intention was to avoid doing that
> 
> > 
> > > @@ -210,7 +208,7 @@ 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);
> > > +    RedChannel *self G_GNUC_UNUSED =
> > > red_channel_client_get_channel(rcc);
> > >  
> > >      red_channel_client_on_output(opaque, n);
> > >  
> > 
> > I would also use the initialization.
> 
> What do you mean ?
> 
> > 
> > > @@ -336,7 +334,7 @@ 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;
> > > +    self->priv->out_bytes_counter = NULL;
> > >  
> > >      // TODO: send incoming_cb as parameters instead of
> > > duplicating?
> > >      self->priv->incoming_cb.on_error =
> > 
> > Actually this could even be removed as structure is zeroed at
> > initialization but surely NULL is better then 0.
> ok
> 
> Pavel
> 
> > 
> > Frediano
> 

diff --git a/server/dcc-send.c b/server/dcc-send.c
index ef67f97..54844cf 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 3b14fbf..5595d86 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -209,12 +209,13 @@ 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);
-
     red_channel_client_on_output(opaque, n);
 
+#ifdef RED_STATISTICS
+    RedChannelClient *rcc = opaque;
+    RedChannel *self = red_channel_client_get_channel(rcc);
     stat_inc_counter(self->priv->reds, self->priv->out_bytes_counter, n);
+#endif
 }
 
 static void
@@ -336,7 +337,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 +436,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);
-    spice_return_if_fail(channel->priv->stat == 0);
 
 #ifdef RED_STATISTICS
+    spice_return_if_fail(channel->priv->stat == 0);
     channel->priv->stat = stat;
     channel->priv->out_bytes_counter =
         stat_add_counter(channel->priv->reds, stat, "out_bytes", TRUE);



Frediano


More information about the Spice-devel mailing list