From 4f8677cee29a9595ba8403ef29764df792679c3c Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Tue, 17 Nov 2020 10:23:33 +0100 Subject: [PATCH] domain_capabilities: Introduce VIR_DOMAIN_CAPS_ENUM_IS_SET This is a convenient macro for querying whether particular domain caps enum value is set or not. Signed-off-by: Michal Privoznik Reviewed-by: Cole Robinson --- src/conf/domain_capabilities.c | 2 +- src/conf/domain_capabilities.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 8a690a57a3..8130311590 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -287,7 +287,7 @@ virDomainCapsEnumFormat(virBufferPtr buf, for (i = 0; i < sizeof(capsEnum->values) * CHAR_BIT; i++) { const char *val; - if (!(capsEnum->values & (1 << i))) + if (!VIR_DOMAIN_CAPS_ENUM_IS_SET(*capsEnum, i)) continue; if ((val = (valToStr)(i))) diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index 4ae6f0fbb1..f177af1744 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -214,6 +214,8 @@ virDomainCapsCPUModelPtr virDomainCapsCPUModelsGet(virDomainCapsCPUModelsPtr cpuModels, const char *name); +#define VIR_DOMAIN_CAPS_ENUM_IS_SET(capsEnum, value) \ + ((capsEnum).values & (1 << value)) #define VIR_DOMAIN_CAPS_ENUM_SET(capsEnum, ...) \ do { \