Skip to content

Commit

Permalink
fix compile error with MSVC 17.12
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo82148 committed Dec 24, 2024
1 parent 65be13c commit 362a463
Show file tree
Hide file tree
Showing 2 changed files with 160 additions and 0 deletions.
80 changes: 80 additions & 0 deletions patches/mariadb/11.6.2/fix-compile-error-with-msvc17.12.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
From 8a3c53f32be6e45eb6c487593b6dce9e1a45dbbc Mon Sep 17 00:00:00 2001
From: Vladislav Vaintroub <vvaintroub@gmail.com>
Date: Wed, 13 Nov 2024 23:07:02 +0100
Subject: [PATCH] Connect engine - fix compiler error with MSVC 17.12

error C2664: 'bool TestHr(PGLOBAL,HRESULT)': cannot convert argument 2
from 'MSXML2::IXMLDOMNodePtr' to 'HRESULT'

Prior to 17.12, there was a code-analysis warning C6216 at the affected
places (compiler generated cast between semantically different integral
types).
---
storage/connect/domdoc.cpp | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/storage/connect/domdoc.cpp b/storage/connect/domdoc.cpp
index 268ad771ef949..b881a10628edc 100644
--- a/storage/connect/domdoc.cpp
+++ b/storage/connect/domdoc.cpp
@@ -165,7 +165,8 @@ bool DOMDOC::NewDoc(PGLOBAL g, PCSZ ver)

sprintf(buf, "version=\"%s\" encoding=\"%s\"", ver, Encoding);
pip = Docp->createProcessingInstruction("xml", buf);
- return(TestHr(g, Docp->appendChild(pip)));
+ Docp->appendChild(pip);
+ return false;
} // end of NewDoc

/******************************************************************/
@@ -173,7 +174,7 @@ bool DOMDOC::NewDoc(PGLOBAL g, PCSZ ver)
/******************************************************************/
void DOMDOC::AddComment(PGLOBAL g, char *com)
{
- TestHr(g, Docp->appendChild(Docp->createComment(com)));
+ Docp->appendChild(Docp->createComment(com));
} // end of AddComment

/******************************************************************/
@@ -196,9 +197,9 @@ PXNODE DOMDOC::NewRoot(PGLOBAL g, char *name)
{
MSXML2::IXMLDOMElementPtr ep = Docp->createElement(name);

- if (ep == NULL || TestHr(g, Docp->appendChild(ep)))
+ if (ep == NULL)
return NULL;
-
+ Docp->appendChild(ep);
return new(g) DOMNODE(this, ep);
} // end of NewRoot

@@ -552,9 +553,9 @@ PXNODE DOMNODE::AddChildNode(PGLOBAL g, PCSZ name, PXNODE np)
_bstr_t pfx = ep->prefix;
_bstr_t uri = ep->namespaceURI;

- if (ep == NULL || TestHr(g, Nodep->appendChild(ep)))
+ if (ep == NULL)
return NULL;
-
+ Nodep->appendChild(ep);
if (np)
((PDOMNODE)np)->Nodep = ep;
else
@@ -593,7 +594,7 @@ void DOMNODE::AddText(PGLOBAL g, PCSZ txtp)
MSXML2::IXMLDOMTextPtr tp= Docp->createTextNode((_bstr_t)txtp);

if (tp != NULL)
- TestHr(g, Nodep->appendChild(tp));
+ Nodep->appendChild(tp);

} // end of AddText

@@ -602,7 +603,7 @@ void DOMNODE::AddText(PGLOBAL g, PCSZ txtp)
/******************************************************************/
void DOMNODE::DeleteChild(PGLOBAL g, PXNODE dnp)
{
- TestHr(g, Nodep->removeChild(((PDOMNODE)dnp)->Nodep));
+ Nodep->removeChild(((PDOMNODE)dnp)->Nodep);
// ((PDOMNODE)dnp)->Nodep->Release(); bad idea, causes a crash
Delete(dnp);
} // end of DeleteChild
80 changes: 80 additions & 0 deletions patches/mariadb/11.7.1/fix-compile-error-with-msvc17.12.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
From 8a3c53f32be6e45eb6c487593b6dce9e1a45dbbc Mon Sep 17 00:00:00 2001
From: Vladislav Vaintroub <vvaintroub@gmail.com>
Date: Wed, 13 Nov 2024 23:07:02 +0100
Subject: [PATCH] Connect engine - fix compiler error with MSVC 17.12

error C2664: 'bool TestHr(PGLOBAL,HRESULT)': cannot convert argument 2
from 'MSXML2::IXMLDOMNodePtr' to 'HRESULT'

Prior to 17.12, there was a code-analysis warning C6216 at the affected
places (compiler generated cast between semantically different integral
types).
---
storage/connect/domdoc.cpp | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/storage/connect/domdoc.cpp b/storage/connect/domdoc.cpp
index 268ad771ef949..b881a10628edc 100644
--- a/storage/connect/domdoc.cpp
+++ b/storage/connect/domdoc.cpp
@@ -165,7 +165,8 @@ bool DOMDOC::NewDoc(PGLOBAL g, PCSZ ver)

sprintf(buf, "version=\"%s\" encoding=\"%s\"", ver, Encoding);
pip = Docp->createProcessingInstruction("xml", buf);
- return(TestHr(g, Docp->appendChild(pip)));
+ Docp->appendChild(pip);
+ return false;
} // end of NewDoc

/******************************************************************/
@@ -173,7 +174,7 @@ bool DOMDOC::NewDoc(PGLOBAL g, PCSZ ver)
/******************************************************************/
void DOMDOC::AddComment(PGLOBAL g, char *com)
{
- TestHr(g, Docp->appendChild(Docp->createComment(com)));
+ Docp->appendChild(Docp->createComment(com));
} // end of AddComment

/******************************************************************/
@@ -196,9 +197,9 @@ PXNODE DOMDOC::NewRoot(PGLOBAL g, char *name)
{
MSXML2::IXMLDOMElementPtr ep = Docp->createElement(name);

- if (ep == NULL || TestHr(g, Docp->appendChild(ep)))
+ if (ep == NULL)
return NULL;
-
+ Docp->appendChild(ep);
return new(g) DOMNODE(this, ep);
} // end of NewRoot

@@ -552,9 +553,9 @@ PXNODE DOMNODE::AddChildNode(PGLOBAL g, PCSZ name, PXNODE np)
_bstr_t pfx = ep->prefix;
_bstr_t uri = ep->namespaceURI;

- if (ep == NULL || TestHr(g, Nodep->appendChild(ep)))
+ if (ep == NULL)
return NULL;
-
+ Nodep->appendChild(ep);
if (np)
((PDOMNODE)np)->Nodep = ep;
else
@@ -593,7 +594,7 @@ void DOMNODE::AddText(PGLOBAL g, PCSZ txtp)
MSXML2::IXMLDOMTextPtr tp= Docp->createTextNode((_bstr_t)txtp);

if (tp != NULL)
- TestHr(g, Nodep->appendChild(tp));
+ Nodep->appendChild(tp);

} // end of AddText

@@ -602,7 +603,7 @@ void DOMNODE::AddText(PGLOBAL g, PCSZ txtp)
/******************************************************************/
void DOMNODE::DeleteChild(PGLOBAL g, PXNODE dnp)
{
- TestHr(g, Nodep->removeChild(((PDOMNODE)dnp)->Nodep));
+ Nodep->removeChild(((PDOMNODE)dnp)->Nodep);
// ((PDOMNODE)dnp)->Nodep->Release(); bad idea, causes a crash
Delete(dnp);
} // end of DeleteChild

0 comments on commit 362a463

Please sign in to comment.