[Spice-devel] [PATCH spice-server 1/2] red-channel: Initialize statistic node correctly

Frediano Ziglio fziglio at redhat.com
Mon Mar 6 18:22:10 UTC 2017


The default memset(0) on the node does not init it correctly.
Do so to avoid other nodes/counters appended to unwanted nodes.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/red-channel.c | 2 ++
 server/stat.h        | 8 ++++++++
 2 files changed, 10 insertions(+)

diff --git a/server/red-channel.c b/server/red-channel.c
index 8ae6ece..8206f4c 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -300,6 +300,8 @@ red_channel_init(RedChannel *self)
     self->priv->client_cbs.connect = red_channel_client_default_connect;
     self->priv->client_cbs.disconnect = red_channel_client_default_disconnect;
     self->priv->client_cbs.migrate = red_channel_client_default_migrate;
+
+    stat_init_node_invalid(&self->priv->stat);
 }
 
 
diff --git a/server/stat.h b/server/stat.h
index 5255efa..980fb07 100644
--- a/server/stat.h
+++ b/server/stat.h
@@ -70,6 +70,14 @@ stat_remove_counter(SpiceServer *reds, RedStatCounter *counter)
 #endif /* RED_STATISTICS */
 
 static inline void
+stat_init_node_invalid(RedStatNode *node)
+{
+#ifdef RED_STATISTICS
+    node->ref = INVALID_STAT_REF;
+#endif
+}
+
+static inline void
 stat_inc_counter(RedStatCounter counter, uint64_t value)
 {
 #ifdef RED_STATISTICS
-- 
2.9.3



More information about the Spice-devel mailing list