mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-30 12:31:16 +00:00
conf: nwfilter: Refactor virNWFilterIncludeParse
Use automatic memory freeing and modern XML parsers to simplify the function. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
9cb4e78ffd
commit
3a5f9a4041
@ -298,7 +298,7 @@ virNWFilterIncludeDefFree(virNWFilterIncludeDef *inc)
|
|||||||
g_free(inc->filterref);
|
g_free(inc->filterref);
|
||||||
g_free(inc);
|
g_free(inc);
|
||||||
}
|
}
|
||||||
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNWFilterIncludeDef, virNWFilterIncludeDefFree);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
virNWFilterEntryFree(virNWFilterEntry *entry)
|
virNWFilterEntryFree(virNWFilterEntry *entry)
|
||||||
@ -2031,27 +2031,15 @@ virNWFilterRuleDetailsParse(xmlNodePtr node,
|
|||||||
static virNWFilterIncludeDef *
|
static virNWFilterIncludeDef *
|
||||||
virNWFilterIncludeParse(xmlNodePtr cur)
|
virNWFilterIncludeParse(xmlNodePtr cur)
|
||||||
{
|
{
|
||||||
virNWFilterIncludeDef *ret;
|
g_autoptr(virNWFilterIncludeDef) ret = g_new0(virNWFilterIncludeDef, 1);
|
||||||
|
|
||||||
ret = g_new0(virNWFilterIncludeDef, 1);
|
if (!(ret->filterref = virXMLPropStringRequired(cur, "filter")))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
ret->filterref = virXMLPropString(cur, "filter");
|
if (!(ret->params = virNWFilterParseParamAttributes(cur)))
|
||||||
if (!ret->filterref) {
|
return NULL;
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
"%s",
|
|
||||||
_("rule node requires action attribute"));
|
|
||||||
goto err_exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret->params = virNWFilterParseParamAttributes(cur);
|
return g_steal_pointer(&ret);
|
||||||
if (!ret->params)
|
|
||||||
goto err_exit;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
err_exit:
|
|
||||||
virNWFilterIncludeDefFree(ret);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user