提交 269d9c1a 编写于 作者: J John Ferlan

conf: Rework virDomainKeyWrapDefParseXML

Rewrite the code to make usage of some VIR_AUTOFREE logic.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
Reviewed-by: NErik Skultety <eskultet@redhat.com>
上级 226d069e
......@@ -1170,31 +1170,25 @@ static int
virDomainKeyWrapDefParseXML(virDomainDefPtr def, xmlXPathContextPtr ctxt)
{
size_t i;
int ret = -1;
int n;
VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
VIR_AUTOFREE(virDomainKeyWrapDefPtr) keywrap = NULL;
if ((n = virXPathNodeSet("./keywrap/cipher", ctxt, &nodes)) < 0)
return n;
if (VIR_ALLOC(def->keywrap) < 0)
goto cleanup;
if (VIR_ALLOC(keywrap) < 0)
return -1;
for (i = 0; i < n; i++) {
if (virDomainKeyWrapCipherDefParseXML(def->keywrap, nodes[i]) < 0)
goto cleanup;
if (virDomainKeyWrapCipherDefParseXML(keywrap, nodes[i]) < 0)
return -1;
}
if (!def->keywrap->aes &&
!def->keywrap->dea)
VIR_FREE(def->keywrap);
if (keywrap->aes || keywrap->dea)
VIR_STEAL_PTR(def->keywrap, keywrap);
ret = 0;
cleanup:
if (ret < 0)
VIR_FREE(def->keywrap);
return ret;
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册