]> xenbits.xensource.com Git - libvirt.git/commitdiff
util/virxml: use xmlCtxtGetLastError when applicable
authorJakub Palacky <jpalacky@redhat.com>
Thu, 12 Sep 2024 11:47:21 +0000 (13:47 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 12 Sep 2024 12:52:55 +0000 (14:52 +0200)
xmlParserCtxt->lastError was deprecated in libxml2 v2.13.0-103-g1228b4e0
xmlCtxtGetLastError(xmlParserCtxt) should be used instead

Signed-off-by: Jakub Palacky <jpalacky@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virxml.c

index a7b75fd7b386e4804710f7fc74e2b98ee741acfe..51173303fee989978341fc1be6f5a36faeee6c98 100644 (file)
@@ -1029,14 +1029,15 @@ catchXMLError(void *ctx, const char *msg G_GNUC_UNUSED, ...)
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     g_autofree char *contextstr = NULL;
     g_autofree char *pointerstr = NULL;
-
+    const xmlError *lastError = xmlCtxtGetLastError(ctxt);
 
     /* conditions for error printing */
     if (!ctxt ||
         (virGetLastErrorCode()) ||
         ctxt->input == NULL ||
-        ctxt->lastError.level != XML_ERR_FATAL ||
-        ctxt->lastError.message == NULL)
+        lastError == NULL ||
+        lastError->level != XML_ERR_FATAL ||
+        lastError->message == NULL)
         return;
 
     if (ctxt->_private)
@@ -1078,19 +1079,19 @@ catchXMLError(void *ctx, const char *msg G_GNUC_UNUSED, ...)
 
     pointerstr = virBufferContentAndReset(&buf);
 
-    if (ctxt->lastError.file) {
+    if (lastError->file) {
         virGenericReportError(domcode, VIR_ERR_XML_DETAIL,
                               _("%1$s:%2$d: %3$s%4$s\n%5$s"),
-                              ctxt->lastError.file,
-                              ctxt->lastError.line,
-                              ctxt->lastError.message,
+                              lastError->file,
+                              lastError->line,
+                              lastError->message,
                               contextstr,
                               pointerstr);
     } else {
         virGenericReportError(domcode, VIR_ERR_XML_DETAIL,
                               _("at line %1$d: %2$s%3$s\n%4$s"),
-                              ctxt->lastError.line,
-                              ctxt->lastError.message,
+                              lastError->line,
+                              lastError->message,
                               contextstr,
                               pointerstr);
     }