virXMLParseHelper: Store XML parsing flags in a variable

The virXMLParseHelper() can work in two modes: either it parses a
file or a string. Either way, the same set of flags is specified
in call of corresponding function. Save flags in a local variable
instead.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik 2023-11-18 04:17:47 +01:00
parent 7a5f232be2
commit 1beb69df87

View File

@ -1136,6 +1136,7 @@ virXMLParseHelper(int domcode,
g_autoptr(xmlDoc) xml = NULL;
xmlNodePtr rootnode;
const char *docname;
const int parseFlags = XML_PARSE_NONET | XML_PARSE_NOWARNING;
if (filename)
docname = filename;
@ -1154,13 +1155,9 @@ virXMLParseHelper(int domcode,
pctxt->sax->error = catchXMLError;
if (filename) {
xml = xmlCtxtReadFile(pctxt, filename, NULL,
XML_PARSE_NONET |
XML_PARSE_NOWARNING);
xml = xmlCtxtReadFile(pctxt, filename, NULL, parseFlags);
} else {
xml = xmlCtxtReadDoc(pctxt, BAD_CAST xmlStr, url, NULL,
XML_PARSE_NONET |
XML_PARSE_NOWARNING);
xml = xmlCtxtReadDoc(pctxt, BAD_CAST xmlStr, url, NULL, parseFlags);
}
if (!xml) {