From 1d658f0d954078e0f75b672178c9a82855a4b69e Mon Sep 17 00:00:00 2001 From: Albert Hung Date: Fri, 15 Mar 2024 14:51:11 +0800 Subject: [PATCH 1/2] Fix format error of TIXML_SNPRINTF The format "%x" is treated as an unsigned int by the GCC compiler. Use static_cast to cast the error to an unsigned int to match the "%x" type. Additionally, replace int(error) with static_cast(error) to avoid the old-style cast warning. --- tinyxml2.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index c5c48701..31a174b9 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -2518,7 +2518,8 @@ void XMLDocument::SetError( XMLError error, int lineNum, const char* format, ... char* buffer = new char[BUFFER_SIZE]; TIXMLASSERT(sizeof(error) <= sizeof(int)); - TIXML_SNPRINTF(buffer, BUFFER_SIZE, "Error=%s ErrorID=%d (0x%x) Line number=%d", ErrorIDToName(error), int(error), int(error), lineNum); + TIXML_SNPRINTF(buffer, BUFFER_SIZE, "Error=%s ErrorID=%d (0x%x) Line number=%d", + ErrorIDToName(error), static_cast(error), static_cast(error), lineNum); if (format) { size_t len = strlen(buffer); From c33aae04d9fa56fb7adaeabddb4cea01d52ef413 Mon Sep 17 00:00:00 2001 From: Lee Thomason Date: Sat, 20 Apr 2024 19:44:22 -0700 Subject: [PATCH 2/2] kick the system --- tinyxml2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 31a174b9..14a053ad 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -2509,7 +2509,7 @@ void XMLDocument::ClearError() { void XMLDocument::SetError( XMLError error, int lineNum, const char* format, ... ) { - TIXMLASSERT( error >= 0 && error < XML_ERROR_COUNT ); + TIXMLASSERT(error >= 0 && error < XML_ERROR_COUNT); _errorID = error; _errorLineNum = lineNum; _errorStr.Reset();