git: 17271d3143c9 - main - emulators/virtualbox-ose{,-nox11}{,-legacy}: Fix build with libxml2 2.12.6+

From: Vladimir Druzenko <vvd_at_FreeBSD.org>
Date: Thu, 22 May 2025 17:15:01 UTC
The branch main has been updated by vvd:

URL: https://cgit.FreeBSD.org/ports/commit/?id=17271d3143c9325720511ee9a4508085b8f18e39

commit 17271d3143c9325720511ee9a4508085b8f18e39
Author:     Vladimir Druzenko <vvd@FreeBSD.org>
AuthorDate: 2025-05-22 16:48:40 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2025-05-22 17:14:52 +0000

    emulators/virtualbox-ose{,-nox11}{,-legacy}: Fix build with libxml2 2.12.6+
    
    Patch ported from VirtualBox 7.x.
    
    PR:     279958
---
 .../files/patch-src_VBox_Runtime_r3_xml.cpp        | 53 ++++++++++++++++++++++
 .../files/patch-src_VBox_Runtime_r3_xml.cpp        | 53 ++++++++++++++++++++++
 2 files changed, 106 insertions(+)

diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r3_xml.cpp b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r3_xml.cpp
new file mode 100644
index 000000000000..ae097a96d33c
--- /dev/null
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Runtime_r3_xml.cpp
@@ -0,0 +1,53 @@
+--- src/VBox/Runtime/r3/xml.cpp.orig	2020-07-09 16:57:46 UTC
++++ src/VBox/Runtime/r3/xml.cpp
+@@ -1837,12 +1837,20 @@ static void xmlParserBaseGenericError(void *pCtx, cons
+     va_end(args);
+ }
+ 
++#if LIBXML_VERSION >= 21206
++static void xmlStructuredErrorFunc(void *userData, const xmlError *error)  RT_NOTHROW_DEF
++{
++    NOREF(userData);
++    NOREF(error);
++}
++#else
+ static void xmlParserBaseStructuredError(void *pCtx, xmlErrorPtr error)
+ {
+     NOREF(pCtx);
+     /* we expect that there is always a trailing NL */
+     LogRel(("XML error at '%s' line %d: %s", error->file, error->line, error->message));
+ }
++#endif
+ 
+ XmlParserBase::XmlParserBase()
+ {
+@@ -1851,7 +1859,11 @@ XmlParserBase::XmlParserBase()
+         throw std::bad_alloc();
+     /* per-thread so it must be here */
+     xmlSetGenericErrorFunc(NULL, xmlParserBaseGenericError);
++#if LIBXML_VERSION >= 21206
++    xmlSetStructuredErrorFunc(NULL, xmlStructuredErrorFunc);
++#else
+     xmlSetStructuredErrorFunc(NULL, xmlParserBaseStructuredError);
++#endif
+ }
+ 
+ XmlParserBase::~XmlParserBase()
+@@ -1912,7 +1924,7 @@ void XmlMemParser::read(const void *pvBuf, size_t cbSi
+                                                   pcszFilename,
+                                                   NULL,       // encoding = auto
+                                                   options)))
+-        throw XmlError(xmlCtxtGetLastError(m_ctxt));
++        throw XmlError((xmlErrorPtr)xmlCtxtGetLastError(m_ctxt));
+ 
+     doc.refreshInternals();
+ }
+@@ -2172,7 +2184,7 @@ void XmlFileParser::read(const RTCString &strFilename,
+                                               pcszFilename,
+                                               NULL,       // encoding = auto
+                                               options)))
+-        throw XmlError(xmlCtxtGetLastError(m_ctxt));
++        throw XmlError((xmlErrorPtr)xmlCtxtGetLastError(m_ctxt));
+ 
+     doc.refreshInternals();
+ }
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r3_xml.cpp b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r3_xml.cpp
new file mode 100644
index 000000000000..7be568f82f37
--- /dev/null
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_Runtime_r3_xml.cpp
@@ -0,0 +1,53 @@
+--- src/VBox/Runtime/r3/xml.cpp.orig	2024-01-11 12:26:05 UTC
++++ src/VBox/Runtime/r3/xml.cpp
+@@ -1837,12 +1837,20 @@ static void xmlParserBaseGenericError(void *pCtx, cons
+     va_end(args);
+ }
+ 
++#if LIBXML_VERSION >= 21206
++static void xmlStructuredErrorFunc(void *userData, const xmlError *error)  RT_NOTHROW_DEF
++{
++    NOREF(userData);
++    NOREF(error);
++}
++#else
+ static void xmlParserBaseStructuredError(void *pCtx, xmlErrorPtr error)
+ {
+     NOREF(pCtx);
+     /* we expect that there is always a trailing NL */
+     LogRel(("XML error at '%s' line %d: %s", error->file, error->line, error->message));
+ }
++#endif
+ 
+ XmlParserBase::XmlParserBase()
+ {
+@@ -1851,7 +1859,11 @@ XmlParserBase::XmlParserBase()
+         throw std::bad_alloc();
+     /* per-thread so it must be here */
+     xmlSetGenericErrorFunc(NULL, xmlParserBaseGenericError);
++#if LIBXML_VERSION >= 21206
++    xmlSetStructuredErrorFunc(NULL, xmlStructuredErrorFunc);
++#else
+     xmlSetStructuredErrorFunc(NULL, xmlParserBaseStructuredError);
++#endif
+ }
+ 
+ XmlParserBase::~XmlParserBase()
+@@ -1912,7 +1924,7 @@ void XmlMemParser::read(const void *pvBuf, size_t cbSi
+                                                   pcszFilename,
+                                                   NULL,       // encoding = auto
+                                                   options)))
+-        throw XmlError(xmlCtxtGetLastError(m_ctxt));
++        throw XmlError((xmlErrorPtr)xmlCtxtGetLastError(m_ctxt));
+ 
+     doc.refreshInternals();
+ }
+@@ -2172,7 +2184,7 @@ void XmlFileParser::read(const RTCString &strFilename,
+                                               pcszFilename,
+                                               NULL,       // encoding = auto
+                                               options)))
+-        throw XmlError(xmlCtxtGetLastError(m_ctxt));
++        throw XmlError((xmlErrorPtr)xmlCtxtGetLastError(m_ctxt));
+ 
+     doc.refreshInternals();
+ }