The two code paths have some cleanup in common so lets refactor it. Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxxxxxxx> Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxxxxxxx> --- src/test/test_driver.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 2773f5c758c8..e7307fddad4a 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1306,6 +1306,7 @@ testOpenFromFile(virConnectPtr conn, const char *file) static int testOpenDefault(virConnectPtr conn) { + int ret; testDriverPtr privconn = NULL; xmlDocPtr doc = NULL; xmlXPathContextPtr ctxt = NULL; @@ -1354,21 +1355,19 @@ testOpenDefault(virConnectPtr conn) goto error; defaultConn = privconn; - + ret = VIR_DRV_OPEN_SUCCESS; + cleanup: + virMutexUnlock(&defaultLock); xmlXPathFreeContext(ctxt); xmlFreeDoc(doc); - virMutexUnlock(&defaultLock); - - return VIR_DRV_OPEN_SUCCESS; + return ret; error: testDriverFree(privconn); - xmlXPathFreeContext(ctxt); - xmlFreeDoc(doc); conn->privateData = NULL; defaultConnections--; - virMutexUnlock(&defaultLock); - return VIR_DRV_OPEN_ERROR; + ret = VIR_DRV_OPEN_ERROR; + goto cleanup; } static int -- 2.13.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list