[Spice-devel] [PATCH 04/18] Reuse VD_AGENT_HAS_CAPABILITY macro for bit array

Pavel Grunt pgrunt at redhat.com
Mon Sep 26 08:36:03 UTC 2016


Hi,

does it make a sense to keep the function (or is it to avoid the
header inclusion)? What about using the macro directly ?

Pavel

On Mon, 2016-09-26 at 09:12 +0100, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/red-channel.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/server/red-channel.c b/server/red-channel.c
> index 927e6e9..27c8632 100644
> --- a/server/red-channel.c
> +++ b/server/red-channel.c
> @@ -331,12 +331,7 @@ void red_channel_register_client_cbs(RedChannel
> *channel, const ClientCbs *clien
>  
>  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;
> +    return VD_AGENT_HAS_CAPABILITY(caps, num_caps, cap);
>  }
>  
>  static void add_capability(uint32_t **caps, int *num_caps, uint32_t
> cap)
> 


More information about the Spice-devel mailing list