[Spice-devel] [PATCH 04/18] Reuse VD_AGENT_HAS_CAPABILITY macro for bit array
Frediano Ziglio
fziglio at redhat.com
Mon Sep 26 09:18:08 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
>
The macro could be misleading as it refers to the agent.
Also macro could have side effects and usually are less type safe..
But a simple inline function as
static inline gboolean test_capability(const uint32_t *caps, int num_caps, uint32_t cap)
{
return VD_AGENT_HAS_CAPABILITY(caps, num_caps, cap);
}
could work too. I don't think header inclusion is a bit problem in red-channel.h.
Frediano
> 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