mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-05 13:17:51 +03:00
test: testOpenDefault: introduce cleanup path
The two code paths have some cleanup in common so lets refactor it. Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com> Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
d1c89c9b2d
commit
d8a24044b7
@ -1297,6 +1297,7 @@ testOpenFromFile(virConnectPtr conn, const char *file)
|
||||
static int
|
||||
testOpenDefault(virConnectPtr conn)
|
||||
{
|
||||
int ret = VIR_DRV_OPEN_ERROR;
|
||||
testDriverPtr privconn = NULL;
|
||||
xmlDocPtr doc = NULL;
|
||||
xmlXPathContextPtr ctxt = NULL;
|
||||
@ -1345,21 +1346,18 @@ 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;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user