[Spice-devel] [PATCH v2] Reuse VD_AGENT_HAS_CAPABILITY macro for bit array

Pavel Grunt pgrunt at redhat.com
Mon Sep 26 11:50:00 UTC 2016


On Mon, 2016-09-26 at 12:27 +0100, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Pavel Grunt <pgrunt at redhat.com>
> ---
>  server/red-channel.c | 10 ----------
>  server/red-channel.h |  5 ++++-
>  2 files changed, 4 insertions(+), 11 deletions(-)
> 
> Changes since v1:
> - make test_capability function inline
> 
> diff --git a/server/red-channel.c b/server/red-channel.c
> index 927e6e9..af49824 100644
> --- a/server/red-channel.c
> +++ b/server/red-channel.c
> @@ -329,16 +329,6 @@ void red_channel_register_client_cbs(RedChannel
> *channel, const ClientCbs *clien
>      channel->data = cbs_data;
>  }
>  
> -int test_capability(const uint32_t *caps, int num_caps, uint32_t
> cap)
> -{
> -    uint32_t index = cap / 32;
> -    if (num_caps < index + 1) {
> -        return FALSE;
> -    }
> -
> -    return (caps[index] & (1 << (cap % 32))) != 0;
> -}
> -
>  static void add_capability(uint32_t **caps, int *num_caps, uint32_t
> cap)
>  {
>      int nbefore, n;
> diff --git a/server/red-channel.h b/server/red-channel.h
> index def5de0..fc59dee 100644
> --- a/server/red-channel.h
> +++ b/server/red-channel.h
> @@ -189,7 +189,10 @@ typedef struct RedChannelCapabilities {
>      uint32_t *caps;
>  } RedChannelCapabilities;
>  
> -int test_capability(const uint32_t *caps, int num_caps, uint32_t
> cap);
> +static inline gboolean test_capability(const uint32_t *caps, int
> num_caps, uint32_t cap)
> +{
> +    return VD_AGENT_HAS_CAPABILITY(caps, num_caps, cap);
> +}
>  
>  typedef struct RedChannelClientLatencyMonitor {
>      int state;
> 


More information about the Spice-devel mailing list