提交 d8a24044 编写于 作者: M Marc Hartmayer 提交者: John Ferlan

test: testOpenDefault: introduce cleanup path

The two code paths have some cleanup in common so lets refactor it.
Signed-off-by: NMarc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: NBoris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 d1c89c9b
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册