summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-05-04 17:40:40 +0300
committerAndrei Karas <akaras@inbox.ru>2016-05-04 17:40:40 +0300
commit62813629db182aa7098c6ab6fe63c304c2c729b0 (patch)
tree8a9463be90ae072e83e4adab80c424d8b419b5bb
parentd0da3a7489670a202901ac32ca6e4bffb16d485b (diff)
downloadmv-62813629db182aa7098c6ab6fe63c304c2c729b0.tar.gz
mv-62813629db182aa7098c6ab6fe63c304c2c729b0.tar.bz2
mv-62813629db182aa7098c6ab6fe63c304c2c729b0.tar.xz
mv-62813629db182aa7098c6ab6fe63c304c2c729b0.zip
Move most checkutils functions into macroses.
-rw-r--r--src/utils/checkutils.cpp50
-rw-r--r--src/utils/checkutils.h38
2 files changed, 10 insertions, 78 deletions
diff --git a/src/utils/checkutils.cpp b/src/utils/checkutils.cpp
index 3161c8f46..5efda43f5 100644
--- a/src/utils/checkutils.cpp
+++ b/src/utils/checkutils.cpp
@@ -30,56 +30,6 @@
#include "debug.h"
-bool reportFalseReal(const bool val,
- const char *const text,
- const char *const file,
- const unsigned line,
- const char *const func)
-{
- if (!val)
- reportStack(file, line, func, "Detected false value", text);
- return val;
-}
-
-bool reportTrueReal(const bool val,
- const char *const text,
- const char *const file,
- const unsigned line,
- const char *const func)
-{
- if (val)
- reportStack(file, line, func, "Detected true value", text);
- return val;
-}
-
-bool failFalseReal(const bool val,
- const char *const text,
- const char *const file,
- const unsigned line,
- const char *const func)
-{
- if (!val)
- {
- reportStack(file, line, func, "Detected false value", text);
- throw new std::exception;
- }
- return val;
-}
-
-bool failTrueReal(const bool val,
- const char *const text,
- const char *const file,
- const unsigned line,
- const char *const func)
-{
- if (val)
- {
- reportStack(file, line, func, "Detected true value", text);
- throw new std::exception;
- }
- return val;
-}
-
void reportStack(const char *const file,
const unsigned int line,
const char *const func,
diff --git a/src/utils/checkutils.h b/src/utils/checkutils.h
index 713ac305f..9617ca140 100644
--- a/src/utils/checkutils.h
+++ b/src/utils/checkutils.h
@@ -24,16 +24,22 @@
#ifdef ENABLE_ASSERTS
#define reportFalse(val) \
- reportFalseReal(val, #val, __FILE__, __LINE__, __func__)
+ (val ? true : (reportStack(__FILE__, __LINE__, __func__, \
+ "Detected false value", #val), false))
#define reportTrue(val) \
- reportTrueReal(val, #val, __FILE__, __LINE__, __func__)
+ (val ? (reportStack(__FILE__, __LINE__, __func__, \
+ "Detected false value", #val), true) : false)
#define failFalse(val) \
- failFalseReal(val, #val, __FILE__, __LINE__, __func__)
+ (val ? true : (reportStack(__FILE__, __LINE__, __func__, \
+ "Detected false value", #val), \
+ throw new std::exception(), false))
#define failTrue(val) \
- failTrueReal(val, #val, __FILE__, __LINE__, __func__)
+ (val ? (reportStack(__FILE__, __LINE__, __func__, \
+ "Detected false value", #val), \
+ throw new std::exception(), true) : false)
#define returnFalseV(val) \
if (!val) \
@@ -67,30 +73,6 @@
return ret; \
}
-bool reportFalseReal(const bool val,
- const char *const text,
- const char *const file,
- const unsigned line,
- const char *const func);
-
-bool reportTrueReal(const bool val,
- const char *const text,
- const char *const file,
- const unsigned line,
- const char *const func);
-
-bool failFalseReal(const bool val,
- const char *const text,
- const char *const file,
- const unsigned line,
- const char *const func);
-
-bool failTrueReal(const bool val,
- const char *const text,
- const char *const file,
- const unsigned line,
- const char *const func);
-
void reportStack(const char *const file,
const unsigned int line,
const char *const func,