From 46a4543d9d852dc0b299edfdc8dae2f8d5d38af1 Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Mon, 26 Sep 2016 12:25:42 +0100 Subject: [PATCH] Reuse VD_AGENT_HAS_CAPABILITY macro for bit array Signed-off-by: Frediano Ziglio Acked-by: Pavel Grunt --- server/red-channel.c | 10 ---------- server/red-channel.h | 5 ++++- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/server/red-channel.c b/server/red-channel.c index 927e6e97..af49824d 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 def5de09..fc59deec 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;