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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2017-03-06 at 18:22 +0000, Frediano Ziglio wrote:
> The default memset(0) on the node does not init it correctly.
yeah, nice catch, INVALID_STAT_REF = ~0

> Do so to avoid other nodes/counters appended to unwanted nodes.
> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  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)
maybe 'invalidate' instead of 'invalid', or _set_invalid

Also the argument can be marked as unused
> +{
> +#ifdef RED_STATISTICS
> +    node->ref = INVALID_STAT_REF;
> +#endif
> +}
> +
> +static inline void
>  stat_inc_counter(RedStatCounter counter, uint64_t value)
>  {
>  #ifdef RED_STATISTICS

What about using / improving stat_init_node or stat_remove_node

Wouldn't be easier to change the INVALID_STAT_REF define ?


Thanks,
Pavel

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]