[Clang] Use const pointer to eliminate warning with libxml 2.12.0 (#76719)

Currently, if `CLANG_HAVE_LIBXML` is defined, and the version of libxml2
is above 2.12.0, there will be two warnings when building clang.

warning: initializing 'xmlErrorPtr' (aka 'struct _xmlError *') with an
expression of type 'const xmlError *' (aka 'const struct _xmlError *')
discards qualifiers

Since this commit

45470611b0,
libxml2 makes cmlGetLastError return a const error. This patch follows
libxml2. Making the result a const pointer should be compatible with
versions before 2.12.0.

Tested on ArchLinux with libxml2 2.12.3 installed.
This commit is contained in:
FantasqueX 2024-01-21 17:34:29 +08:00 committed by GitHub
parent 62bf7710ff
commit f9e2e85b07
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -707,7 +707,7 @@ static void ValidateCommentXML(const char *Str, const char *CommentSchemaFile) {
Doc = xmlParseDoc((const xmlChar *) Str);
if (!Doc) {
xmlErrorPtr Error = xmlGetLastError();
const xmlError *Error = xmlGetLastError();
printf(" CommentXMLInvalid [not well-formed XML: %s]", Error->message);
return;
}
@ -717,7 +717,7 @@ static void ValidateCommentXML(const char *Str, const char *CommentSchemaFile) {
if (!status)
printf(" CommentXMLValid");
else if (status > 0) {
xmlErrorPtr Error = xmlGetLastError();
const xmlError *Error = xmlGetLastError();
printf(" CommentXMLInvalid [not valid XML: %s]", Error->message);
} else
printf(" libXMLError");