Merge pull request #330634 from r-ryantm/auto-update/circumflex
[NixPkgs.git] / pkgs / servers / sql / mariadb / patch / 0001-Fix-build-with-libxml2-2.12.patch
bloba12dfb73d09de75c43ba3a409b81b1d5e2e79502
1 From 1f1ee5d3776af7ef56ffa3f4dcd22532c2c86c74 Mon Sep 17 00:00:00 2001
2 From: Jan Tojnar <jtojnar@gmail.com>
3 Date: Sun, 7 Jan 2024 10:19:54 +0100
4 Subject: [PATCH] Fix build with libxml2 2.12
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 libxml2 2.12.0 made `xmlGetLastError()` return `const` pointer:
11 https://gitlab.gnome.org/GNOME/libxml2/-/commit/61034116d0a3c8b295c6137956adc3ae55720711
13 Clang 16 does not like this:
15 error: assigning to 'xmlErrorPtr' (aka '_xmlError *') from 'const xmlError *' (aka 'const _xmlError *') discards qualifiers
16 error: cannot initialize a variable of type 'xmlErrorPtr' (aka '_xmlError *') with an rvalue of type 'const xmlError *' (aka 'const _xmlError *')
18 Let’s update the variables to `const`.
19 For older versions, it will be automatically converted.
21 But then `xmlResetError(xmlError*)` will not like the `const` pointer:
23 error: no matching function for call to 'xmlResetError'
24 note: candidate function not viable: 1st argument ('const xmlError *' (aka 'const _xmlError *')) would lose const qualifier
26 Let’s replace it with `xmlResetLastError()`.
28 ALso remove `LIBXMLDOC::Xerr` protected member property.
29 It was introduced in 65b0e5455b547a3d574fa77b34cce23ae3bea0a0
30 along with the `xmlResetError` calls.
31 It does not appear to be used for anything.
32 ---
33 storage/connect/libdoc.cpp | 39 +++++++++++++++++++-------------------
34 1 file changed, 19 insertions(+), 20 deletions(-)
36 diff --git a/storage/connect/libdoc.cpp b/storage/connect/libdoc.cpp
37 index e414aa88355..10edcbc3ffa 100644
38 --- a/storage/connect/libdoc.cpp
39 +++ b/storage/connect/libdoc.cpp
40 @@ -93,7 +93,6 @@ class LIBXMLDOC : public XMLDOCUMENT {
41 xmlXPathContextPtr Ctxp;
42 xmlXPathObjectPtr Xop;
43 xmlXPathObjectPtr NlXop;
44 - xmlErrorPtr Xerr;
45 char *Buf; // Temporary
46 bool Nofreelist;
47 }; // end of class LIBXMLDOC
48 @@ -327,7 +326,6 @@ LIBXMLDOC::LIBXMLDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp)
49 Ctxp = NULL;
50 Xop = NULL;
51 NlXop = NULL;
52 - Xerr = NULL;
53 Buf = NULL;
54 Nofreelist = false;
55 } // end of LIBXMLDOC constructor
56 @@ -365,8 +363,8 @@ bool LIBXMLDOC::ParseFile(PGLOBAL g, char *fn)
57 Encoding = (char*)Docp->encoding;
59 return false;
60 - } else if ((Xerr = xmlGetLastError()))
61 - xmlResetError(Xerr);
62 + } else if (xmlGetLastError())
63 + xmlResetLastError();
65 return true;
66 } // end of ParseFile
67 @@ -505,9 +503,9 @@ int LIBXMLDOC::DumpDoc(PGLOBAL g, char *ofn)
68 #if 1
69 // This function does not crash (
70 if (xmlSaveFormatFileEnc((const char *)ofn, Docp, Encoding, 0) < 0) {
71 - xmlErrorPtr err = xmlGetLastError();
72 + const xmlError *err = xmlGetLastError();
73 strcpy(g->Message, (err) ? err->message : "Error saving XML doc");
74 - xmlResetError(Xerr);
75 + xmlResetLastError();
76 rc = -1;
77 } // endif Save
78 // rc = xmlDocDump(of, Docp);
79 @@ -546,8 +544,8 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp)
80 if (Nlist) {
81 xmlXPathFreeNodeSet(Nlist);
83 - if ((Xerr = xmlGetLastError()))
84 - xmlResetError(Xerr);
85 + if (xmlGetLastError())
86 + xmlResetLastError();
88 Nlist = NULL;
89 } // endif Nlist
90 @@ -555,8 +553,8 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp)
91 if (Xop) {
92 xmlXPathFreeObject(Xop);
94 - if ((Xerr = xmlGetLastError()))
95 - xmlResetError(Xerr);
96 + if (xmlGetLastError())
97 + xmlResetLastError();
99 Xop = NULL;
100 } // endif Xop
101 @@ -564,8 +562,8 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp)
102 if (NlXop) {
103 xmlXPathFreeObject(NlXop);
105 - if ((Xerr = xmlGetLastError()))
106 - xmlResetError(Xerr);
107 + if (xmlGetLastError())
108 + xmlResetLastError();
110 NlXop = NULL;
111 } // endif NlXop
112 @@ -573,8 +571,8 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp)
113 if (Ctxp) {
114 xmlXPathFreeContext(Ctxp);
116 - if ((Xerr = xmlGetLastError()))
117 - xmlResetError(Xerr);
118 + if (xmlGetLastError())
119 + xmlResetLastError();
121 Ctxp = NULL;
122 } // endif Ctxp
123 @@ -590,6 +588,7 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp)
124 /******************************************************************/
125 xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp)
127 + const xmlError *xerr;
128 xmlNodeSetPtr nl;
130 if (trace(1))
131 @@ -649,11 +648,11 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp)
132 } else
133 xmlXPathFreeObject(Xop); // Caused node not found
135 - if ((Xerr = xmlGetLastError())) {
136 - strcpy(g->Message, Xerr->message);
137 - xmlResetError(Xerr);
138 + if ((xerr = xmlGetLastError())) {
139 + strcpy(g->Message, xerr->message);
140 + xmlResetLastError();
141 return NULL;
142 - } // endif Xerr
143 + } // endif xerr
145 } // endif Xop
147 @@ -1079,7 +1078,7 @@ void XML2NODE::AddText(PGLOBAL g, PCSZ txtp)
148 /******************************************************************/
149 void XML2NODE::DeleteChild(PGLOBAL g, PXNODE dnp)
151 - xmlErrorPtr xerr;
152 + const xmlError *xerr;
154 if (trace(1))
155 htrc("DeleteChild: node=%p\n", dnp);
156 @@ -1122,7 +1121,7 @@ void XML2NODE::DeleteChild(PGLOBAL g, PXNODE dnp)
157 if (trace(1))
158 htrc("DeleteChild: errmsg=%-.256s\n", xerr->message);
160 - xmlResetError(xerr);
161 + xmlResetLastError();
162 } // end of DeleteChild
164 /* -------------------- class XML2NODELIST ---------------------- */
166 2.42.0