1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 07:59:00 +00:00

hyperv: use GLib auto-cleanup in hypervCreateInvokeXmlDoc

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
Matt Coleman 2021-01-21 13:51:33 -05:00 committed by Laine Stump
parent 57d668447b
commit cc7a4b0139

View File

@ -398,38 +398,27 @@ hypervGetCimTypeInfo(hypervCimTypePtr typemap, const char *name,
static int
hypervCreateInvokeXmlDoc(hypervInvokeParamsListPtr params, WsXmlDocH *docRoot)
{
int result = -1;
char *method = NULL;
g_autofree char *method = g_strdup_printf("%s_INPUT", params->method);
g_auto(WsXmlDocH) invokeXmlDocRoot = ws_xml_create_doc(NULL, method);
WsXmlNodeH xmlNodeMethod = NULL;
method = g_strdup_printf("%s_INPUT", params->method);
*docRoot = ws_xml_create_doc(NULL, method);
if (*docRoot == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not instantiate XML document"));
goto cleanup;
if (!invokeXmlDocRoot) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not instantiate XML document"));
return -1;
}
xmlNodeMethod = xml_parser_get_root(*docRoot);
if (xmlNodeMethod == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not get root node of XML document"));
goto cleanup;
xmlNodeMethod = xml_parser_get_root(invokeXmlDocRoot);
if (!xmlNodeMethod) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not get root node of XML document"));
return -1;
}
/* add resource URI as namespace */
ws_xml_set_ns(xmlNodeMethod, params->resourceUri, "p");
result = 0;
*docRoot = g_steal_pointer(&invokeXmlDocRoot);
cleanup:
if (result < 0 && *docRoot != NULL) {
ws_xml_destroy_doc(*docRoot);
*docRoot = NULL;
}
VIR_FREE(method);
return result;
return 0;
}