From: Tim Wiederhake Date: Fri, 4 Feb 2022 15:11:49 +0000 (+0100) Subject: ch: Prepare virCHDriverGetCapabilities for automatic mutex management X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=0a6ff46c9e4e5ba1964dac09aaf3730f012251bf;p=libvirt.git ch: Prepare virCHDriverGetCapabilities for automatic mutex management No functional change intended. This change makes the refactoring to automatic mutex management easier to follow. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- diff --git a/src/ch/ch_conf.c b/src/ch/ch_conf.c index 88a23a59cd..f865d93681 100644 --- a/src/ch/ch_conf.c +++ b/src/ch/ch_conf.c @@ -87,21 +87,22 @@ virCaps *virCHDriverCapsInit(void) virCaps *virCHDriverGetCapabilities(virCHDriver *driver, bool refresh) { - virCaps *ret; - if (refresh) { - virCaps *caps = NULL; - if ((caps = virCHDriverCapsInit()) == NULL) - return NULL; + virCaps *ret = NULL; + virCaps *caps = NULL; - chDriverLock(driver); + if (refresh && !(caps = virCHDriverCapsInit())) + return NULL; + + chDriverLock(driver); + + if (refresh) { virObjectUnref(driver->caps); driver->caps = caps; - } else { - chDriverLock(driver); } ret = virObjectRef(driver->caps); chDriverUnlock(driver); + return ret; }