summaryrefslogtreecommitdiff
blob: 654436a65d99c7f9258c20b176be679ce0b117f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From 56acbe8a0765a02418f80fb3599b3cf7160ef446 Mon Sep 17 00:00:00 2001
Message-ID: <56acbe8a0765a02418f80fb3599b3cf7160ef446.1701156704.git.mprivozn@redhat.com>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Sat, 25 Nov 2023 07:13:33 +0100
Subject: [glib PATCH 1/2] Make xmlError structs constant

In libxml2 commits v2.12.0~14 and v2.12.0~77 the API changed so
that:

1) xmlGetLastError() returns pointer to a constant xmlError
   struct, and

2) xmlSetStructuredErrorFunc() changed the signature of callback
   (gvir_xml_structured_error_nop()), it too is passed pointer to
   a constant xmlError struct.

But of course, older libxml2 expects different callback
signature. Therefore, we need to typecast it anyway.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 libvirt-gconfig/libvirt-gconfig-helpers.c | 2 +-
 libvirt-gconfig/libvirt-gconfig-object.c  | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-helpers.c b/libvirt-gconfig/libvirt-gconfig-helpers.c
index e8f9664..37075e3 100644
--- a/libvirt-gconfig/libvirt-gconfig-helpers.c
+++ b/libvirt-gconfig/libvirt-gconfig-helpers.c
@@ -41,7 +41,7 @@ static GError *gvir_config_error_new_literal(GQuark domain,
                                              gint code,
                                              const gchar *message)
 {
-    xmlErrorPtr xerr = xmlGetLastError();
+    const xmlError *xerr = xmlGetLastError();
 
     if (!xerr)
         return NULL;
diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c
index eb8763e..1fcc667 100644
--- a/libvirt-gconfig/libvirt-gconfig-object.c
+++ b/libvirt-gconfig/libvirt-gconfig-object.c
@@ -59,7 +59,7 @@ static void gvir_xml_generic_error_nop(void *userData G_GNUC_UNUSED,
 }
 
 static void gvir_xml_structured_error_nop(void *userData G_GNUC_UNUSED,
-                                          xmlErrorPtr error G_GNUC_UNUSED)
+                                          const xmlError *error G_GNUC_UNUSED)
 {
 }
 
@@ -197,7 +197,8 @@ void gvir_config_object_validate(GVirConfigObject *config,
     priv = config->priv;
 
     xmlSetGenericErrorFunc(NULL, gvir_xml_generic_error_nop);
-    xmlSetStructuredErrorFunc(NULL, gvir_xml_structured_error_nop);
+    /* Drop this typecast when >=libxml2-2.12.0 is required */
+    xmlSetStructuredErrorFunc(NULL, (xmlStructuredErrorFunc) gvir_xml_structured_error_nop);
 
     if (!priv->node) {
         gvir_config_set_error_literal(err,
-- 
2.41.0