summaryrefslogtreecommitdiff
blob: 964b2c10b6ec0a57dad347d25f1db996d924ccb6 (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
From 34378a4ac257f2f5fcf364786d1634a8c36b304f Mon Sep 17 00:00:00 2001
Message-ID: <34378a4ac257f2f5fcf364786d1634a8c36b304f.1701158114.git.mprivozn@redhat.com>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Mon, 27 Nov 2023 15:04:43 +0100
Subject: [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
   (validate_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.

Also, drop obviously incorrect @error annotation in
validate_structured_error_nop; the variable is used.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 tools/osinfo-db-validate.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/osinfo-db-validate.c b/tools/osinfo-db-validate.c
index a721b4d..b1434a6 100644
--- a/tools/osinfo-db-validate.c
+++ b/tools/osinfo-db-validate.c
@@ -35,7 +35,7 @@ static void validate_generic_error_nop(void *userData G_GNUC_UNUSED,
 }
 
 static void validate_structured_error_nop(void *userData G_GNUC_UNUSED,
-                                          xmlErrorPtr error G_GNUC_UNUSED)
+                                          const xmlError *error)
 {
     if (error->file)
         g_printerr("%s:%d %s", error->file, error->line, error->message);
@@ -173,7 +173,8 @@ static gboolean validate_files(GFile *schema, gsize nfiles, GFile **files, GErro
     g_autofree gchar *schemapath = NULL;
 
     xmlSetGenericErrorFunc(NULL, validate_generic_error_nop);
-    xmlSetStructuredErrorFunc(NULL, validate_structured_error_nop);
+    /* Drop this typecast when >=libxml2-2.12.0 is required */
+    xmlSetStructuredErrorFunc(NULL, (xmlStructuredErrorFunc) validate_structured_error_nop);
 
     schemapath = g_file_get_path(schema);
     rngParser = xmlRelaxNGNewParserCtxt(schemapath);
-- 
2.41.0