mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-33439 Fix build with libxml2 2.12
libxml2 2.12.0 made `xmlGetLastError()` return `const` pointer:61034116d0
Clang 16 does not like this: error: assigning to 'xmlErrorPtr' (aka '_xmlError *') from 'const xmlError *' (aka 'const _xmlError *') discards qualifiers error: cannot initialize a variable of type 'xmlErrorPtr' (aka '_xmlError *') with an rvalue of type 'const xmlError *' (aka 'const _xmlError *') Let’s update the variables to `const`. For older versions, it will be automatically converted. But then `xmlResetError(xmlError*)` will not like the `const` pointer: error: no matching function for call to 'xmlResetError' note: candidate function not viable: 1st argument ('const xmlError *' (aka 'const _xmlError *')) would lose const qualifier Let’s replace it with `xmlResetLastError()`. ALso remove `LIBXMLDOC::Xerr` protected member property. It was introduced in65b0e5455b
along with the `xmlResetError` calls. It does not appear to be used for anything.
This commit is contained in:
@@ -93,7 +93,6 @@ class LIBXMLDOC : public XMLDOCUMENT {
|
|||||||
xmlXPathContextPtr Ctxp;
|
xmlXPathContextPtr Ctxp;
|
||||||
xmlXPathObjectPtr Xop;
|
xmlXPathObjectPtr Xop;
|
||||||
xmlXPathObjectPtr NlXop;
|
xmlXPathObjectPtr NlXop;
|
||||||
xmlErrorPtr Xerr;
|
|
||||||
char *Buf; // Temporary
|
char *Buf; // Temporary
|
||||||
bool Nofreelist;
|
bool Nofreelist;
|
||||||
}; // end of class LIBXMLDOC
|
}; // end of class LIBXMLDOC
|
||||||
@@ -327,7 +326,6 @@ LIBXMLDOC::LIBXMLDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp)
|
|||||||
Ctxp = NULL;
|
Ctxp = NULL;
|
||||||
Xop = NULL;
|
Xop = NULL;
|
||||||
NlXop = NULL;
|
NlXop = NULL;
|
||||||
Xerr = NULL;
|
|
||||||
Buf = NULL;
|
Buf = NULL;
|
||||||
Nofreelist = false;
|
Nofreelist = false;
|
||||||
} // end of LIBXMLDOC constructor
|
} // end of LIBXMLDOC constructor
|
||||||
@@ -365,8 +363,8 @@ bool LIBXMLDOC::ParseFile(PGLOBAL g, char *fn)
|
|||||||
Encoding = (char*)Docp->encoding;
|
Encoding = (char*)Docp->encoding;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else if ((Xerr = xmlGetLastError()))
|
} else if (xmlGetLastError())
|
||||||
xmlResetError(Xerr);
|
xmlResetLastError();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} // end of ParseFile
|
} // end of ParseFile
|
||||||
@@ -505,9 +503,9 @@ int LIBXMLDOC::DumpDoc(PGLOBAL g, char *ofn)
|
|||||||
#if 1
|
#if 1
|
||||||
// This function does not crash (
|
// This function does not crash (
|
||||||
if (xmlSaveFormatFileEnc((const char *)ofn, Docp, Encoding, 0) < 0) {
|
if (xmlSaveFormatFileEnc((const char *)ofn, Docp, Encoding, 0) < 0) {
|
||||||
xmlErrorPtr err = xmlGetLastError();
|
const xmlError *err = xmlGetLastError();
|
||||||
strcpy(g->Message, (err) ? err->message : "Error saving XML doc");
|
strcpy(g->Message, (err) ? err->message : "Error saving XML doc");
|
||||||
xmlResetError(Xerr);
|
xmlResetLastError();
|
||||||
rc = -1;
|
rc = -1;
|
||||||
} // endif Save
|
} // endif Save
|
||||||
// rc = xmlDocDump(of, Docp);
|
// rc = xmlDocDump(of, Docp);
|
||||||
@@ -546,8 +544,8 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp)
|
|||||||
if (Nlist) {
|
if (Nlist) {
|
||||||
xmlXPathFreeNodeSet(Nlist);
|
xmlXPathFreeNodeSet(Nlist);
|
||||||
|
|
||||||
if ((Xerr = xmlGetLastError()))
|
if (xmlGetLastError())
|
||||||
xmlResetError(Xerr);
|
xmlResetLastError();
|
||||||
|
|
||||||
Nlist = NULL;
|
Nlist = NULL;
|
||||||
} // endif Nlist
|
} // endif Nlist
|
||||||
@@ -555,8 +553,8 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp)
|
|||||||
if (Xop) {
|
if (Xop) {
|
||||||
xmlXPathFreeObject(Xop);
|
xmlXPathFreeObject(Xop);
|
||||||
|
|
||||||
if ((Xerr = xmlGetLastError()))
|
if (xmlGetLastError())
|
||||||
xmlResetError(Xerr);
|
xmlResetLastError();
|
||||||
|
|
||||||
Xop = NULL;
|
Xop = NULL;
|
||||||
} // endif Xop
|
} // endif Xop
|
||||||
@@ -564,8 +562,8 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp)
|
|||||||
if (NlXop) {
|
if (NlXop) {
|
||||||
xmlXPathFreeObject(NlXop);
|
xmlXPathFreeObject(NlXop);
|
||||||
|
|
||||||
if ((Xerr = xmlGetLastError()))
|
if (xmlGetLastError())
|
||||||
xmlResetError(Xerr);
|
xmlResetLastError();
|
||||||
|
|
||||||
NlXop = NULL;
|
NlXop = NULL;
|
||||||
} // endif NlXop
|
} // endif NlXop
|
||||||
@@ -573,8 +571,8 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp)
|
|||||||
if (Ctxp) {
|
if (Ctxp) {
|
||||||
xmlXPathFreeContext(Ctxp);
|
xmlXPathFreeContext(Ctxp);
|
||||||
|
|
||||||
if ((Xerr = xmlGetLastError()))
|
if (xmlGetLastError())
|
||||||
xmlResetError(Xerr);
|
xmlResetLastError();
|
||||||
|
|
||||||
Ctxp = NULL;
|
Ctxp = NULL;
|
||||||
} // endif Ctxp
|
} // endif Ctxp
|
||||||
@@ -590,6 +588,7 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp)
|
|||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp)
|
xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp)
|
||||||
{
|
{
|
||||||
|
const xmlError *xerr;
|
||||||
xmlNodeSetPtr nl;
|
xmlNodeSetPtr nl;
|
||||||
|
|
||||||
if (trace(1))
|
if (trace(1))
|
||||||
@@ -649,11 +648,11 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp)
|
|||||||
} else
|
} else
|
||||||
xmlXPathFreeObject(Xop); // Caused node not found
|
xmlXPathFreeObject(Xop); // Caused node not found
|
||||||
|
|
||||||
if ((Xerr = xmlGetLastError())) {
|
if ((xerr = xmlGetLastError())) {
|
||||||
strcpy(g->Message, Xerr->message);
|
strcpy(g->Message, xerr->message);
|
||||||
xmlResetError(Xerr);
|
xmlResetLastError();
|
||||||
return NULL;
|
return NULL;
|
||||||
} // endif Xerr
|
} // endif xerr
|
||||||
|
|
||||||
} // endif Xop
|
} // endif Xop
|
||||||
|
|
||||||
@@ -1079,7 +1078,7 @@ void XML2NODE::AddText(PGLOBAL g, PCSZ txtp)
|
|||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
void XML2NODE::DeleteChild(PGLOBAL g, PXNODE dnp)
|
void XML2NODE::DeleteChild(PGLOBAL g, PXNODE dnp)
|
||||||
{
|
{
|
||||||
xmlErrorPtr xerr;
|
const xmlError *xerr;
|
||||||
|
|
||||||
if (trace(1))
|
if (trace(1))
|
||||||
htrc("DeleteChild: node=%p\n", dnp);
|
htrc("DeleteChild: node=%p\n", dnp);
|
||||||
@@ -1122,7 +1121,7 @@ err:
|
|||||||
if (trace(1))
|
if (trace(1))
|
||||||
htrc("DeleteChild: errmsg=%-.256s\n", xerr->message);
|
htrc("DeleteChild: errmsg=%-.256s\n", xerr->message);
|
||||||
|
|
||||||
xmlResetError(xerr);
|
xmlResetLastError();
|
||||||
} // end of DeleteChild
|
} // end of DeleteChild
|
||||||
|
|
||||||
/* -------------------- class XML2NODELIST ---------------------- */
|
/* -------------------- class XML2NODELIST ---------------------- */
|
||||||
|
Reference in New Issue
Block a user