summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/utils/checkutils.cpp9
-rw-r--r--src/utils/checkutils.h28
-rw-r--r--src/utils/xml/libxml.cpp7
-rw-r--r--src/utils/xml/pugixml.cpp5
4 files changed, 29 insertions, 20 deletions
diff --git a/src/utils/checkutils.cpp b/src/utils/checkutils.cpp
index 661e3efa2..7148b0ed0 100644
--- a/src/utils/checkutils.cpp
+++ b/src/utils/checkutils.cpp
@@ -54,16 +54,11 @@ void reportAssertStack(const char *const file,
void reportLogStack(const char *const file,
const unsigned int line,
- const char *const func,
- const char *const name,
- const char *const text)
+ const char *const func)
{
- logger->log("--- Assert: %s --------------------------------------------",
- name);
- logger->log("%s:%u: '%s' in function `%s'",
+ logger->assertLog("%s:%u: in function `%s'",
file,
line,
- text,
func);
#ifndef ANDROID
#if defined __linux__ || defined __linux
diff --git a/src/utils/checkutils.h b/src/utils/checkutils.h
index 7316264b2..18f958d8d 100644
--- a/src/utils/checkutils.h
+++ b/src/utils/checkutils.h
@@ -31,9 +31,12 @@
(val ? (reportAssertStack(__FILE__, __LINE__, __func__, \
"Detected false value", #val), true) : false)
-#define reportAlwaysReal(val) \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Always assert", val);
+#define reportAlwaysReal(...) \
+ { \
+ logger->assertLog( \
+ __VA_ARGS__); \
+ reportLogStack(__FILE__, __LINE__, __func__); \
+ }
#define returnFalseVReal(val) \
if (!val) \
@@ -141,10 +144,11 @@
throw new std::exception(); \
}
-#define failAlways(val) \
+#define failAlways(...) \
{ \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected false value", val); \
+ logger->assertLog( \
+ __VA_ARGS__); \
+ reportLogStack(__FILE__, __LINE__, __func__); \
throw new std::exception(); \
}
@@ -156,9 +160,7 @@ void reportAssertStack(const char *const file,
void reportLogStack(const char *const file,
const unsigned int line,
- const char *const func,
- const char *const name,
- const char *const text);
+ const char *const func);
void reportStack();
@@ -167,7 +169,7 @@ void reportStack();
#define reportFalseReal(val) (val)
#define reportTrueReal(val) (val)
-#define reportAlwaysReal(val) ;
+#define reportAlwaysReal(...) ;
#define returnFalseVReal(val) \
if (!val) \
@@ -220,14 +222,14 @@ void reportStack();
if ((val) == nullptr) \
return ret;
-#define failAlways(val) ;
+#define failAlways(...) ;
#endif // ENABLE_ASSERTS
#ifdef UNITTESTS
#define reportFalse(val) failFalse(val)
#define reportTrue(val) failTrue(val)
-#define reportAlways(val) failAlways(val)
+#define reportAlways(...) failAlways(__VA_ARGS__)
#define returnFalseV(val) returnFailFalseV(val)
#define returnTrueV(val) returnFailTrueV(val)
#define returnFalse(ret, val) returnFailFalse(ret, val)
@@ -237,7 +239,7 @@ void reportStack();
#else // UNITTESTS
#define reportFalse(val) reportFalseReal(val)
#define reportTrue(val) reportTrueReal(val)
-#define reportAlways(val) reportAlwaysReal(val)
+#define reportAlways(...) reportAlwaysReal(__VA_ARGS__)
#define returnFalseV(val) returnFalseVReal(val)
#define returnTrueV(val) returnTrueVReal(val)
#define returnFalse(ret, val) returnFalseReal(ret, val)
diff --git a/src/utils/xml/libxml.cpp b/src/utils/xml/libxml.cpp
index 46d184067..b03a32211 100644
--- a/src/utils/xml/libxml.cpp
+++ b/src/utils/xml/libxml.cpp
@@ -26,6 +26,7 @@
#include "logger.h"
+#include "utils/checkutils.h"
#include "utils/fuzzer.h"
#include "utils/physfstools.h"
#include "utils/stringutils.h"
@@ -112,6 +113,7 @@ namespace XML
if (size < 0)
{
logger->log("Error loading XML file %s", filename.c_str());
+ reportAlways("Error loading XML file %s", filename.c_str());
}
else
{
@@ -124,6 +126,7 @@ namespace XML
else
{
logger->log("Error loading XML file %s", filename.c_str());
+ reportAlways("Error loading XML file %s", filename.c_str());
}
}
@@ -133,11 +136,15 @@ namespace XML
free(data);
if (!mDoc)
+ {
logger->log("Error parsing XML file %s", filename.c_str());
+ reportAlways("Error parsing XML file %s", filename.c_str());
+ }
}
else if (skipError == SkipError_false)
{
logger->log("Error loading %s", filename.c_str());
+ reportAlways("Error loading XML file %s", filename.c_str());
}
mIsValid = valid;
BLOCK_END("XML::Document::Document")
diff --git a/src/utils/xml/pugixml.cpp b/src/utils/xml/pugixml.cpp
index 0f01c7f10..62aa68cba 100644
--- a/src/utils/xml/pugixml.cpp
+++ b/src/utils/xml/pugixml.cpp
@@ -26,6 +26,7 @@
#include "logger.h"
+#include "utils/checkutils.h"
#include "utils/delete2.h"
#include "utils/fuzzer.h"
#include "utils/physfstools.h"
@@ -88,6 +89,8 @@ namespace XML
if (size < 0)
{
logger->log("Error loading XML file %s", filename.c_str());
+ reportAlways("Error loading XML file %s",
+ filename.c_str());
}
else
{
@@ -100,6 +103,7 @@ namespace XML
else
{
logger->log("Error loading XML file %s", filename.c_str());
+ reportAlways("Error loading XML file %s", filename.c_str());
}
}
@@ -126,6 +130,7 @@ namespace XML
else if (skipError == SkipError_false)
{
logger->log("Error loading %s", filename.c_str());
+ reportAlways("Error loading %s", filename.c_str());
}
mIsValid = valid;
BLOCK_END("XML::Document::Document")