No functional change intended. This change makes the refactoring to automatic mutex management easier to follow. Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx> --- src/ch/ch_conf.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/ch/ch_conf.c b/src/ch/ch_conf.c index be12934dcd..cdf69e3e70 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; } -- 2.31.1