render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From 68a14369033486ad9e02cb144cde2aced7351ce2 Mon Sep 17 00:00:00 2001
From: Michal Privoznik <mprivozn@redhat.com>
Date: Sat, 18 Nov 2023 04:17:47 +0100
Subject: [PATCH 5/8] virXMLParseHelper: Store XML parsing flags in a variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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>
(cherry picked from commit 1beb69df877596fe57efc8d8a117a30a72e5d04e)
---
 src/util/virxml.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/util/virxml.c b/src/util/virxml.c
index 4f215a0e59..027cdb97b9 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -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) {
-- 
2.43.0