summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorMarcel Admiraal <madmiraal@users.noreply.github.com>2019-11-07 10:37:44 +0100
committerMarcel Admiraal <madmiraal@users.noreply.github.com>2020-02-05 11:19:12 +0100
commit6d69cd40bd43c744fd402507a02d42d328266dc8 (patch)
tree688f46e43730a2175f5d0c09a18aefbcfe47ef7e /core
parentf0db13502aa455f7bef320261ea3929589fcc6d9 (diff)
Add do..while(0) wrappers to macros without one.
- Add do..while(0) wrapper to ERR_FAIL_NULL macros. - Add do..while(0) wrapper to ERR_FAIL_COND macros. - Add do..while(0) wrapper to ERR_CONTINUE macros. - Add do..while(0) wrapper to ERR_BREAK macros. - Add do..while(0) wrapper to CRASH_COND macros. - Add do..while(0) wrapper to ERR_FAIL macros. - Add do..while(0) wrapper to ERR_PRINT macros. - Add do..while(0) wrapper to WARN_PRINT macros. - Add do..while(0) wrapper to WARN_DEPRECATED macros. - Add do..while(0) wrapper to CRASH_NOW macros.
Diffstat (limited to 'core')
-rw-r--r--core/error_macros.h158
-rw-r--r--core/math/bsp_tree.cpp2
2 files changed, 80 insertions, 80 deletions
diff --git a/core/error_macros.h b/core/error_macros.h
index afbf76c47d..0fe3a5d796 100644
--- a/core/error_macros.h
+++ b/core/error_macros.h
@@ -230,38 +230,38 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
// The current function returns.
#define ERR_FAIL_NULL(m_param) \
- { \
+ do { \
if (unlikely(!m_param)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null."); \
return; \
} \
- }
+ } while (0)
#define ERR_FAIL_NULL_MSG(m_param, m_msg) \
- { \
+ do { \
if (unlikely(!m_param)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null.", DEBUG_STR(m_msg)); \
return; \
} \
- }
+ } while (0)
// The current function returns m_retval.
#define ERR_FAIL_NULL_V(m_param, m_retval) \
- { \
+ do { \
if (unlikely(!m_param)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null."); \
return m_retval; \
} \
- }
+ } while (0)
#define ERR_FAIL_NULL_V_MSG(m_param, m_retval, m_msg) \
- { \
+ do { \
if (unlikely(!m_param)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null.", DEBUG_STR(m_msg)); \
return m_retval; \
} \
- }
+ } while (0)
// Error condition macros.
// Ensures that `m_cond` is not true.
@@ -269,193 +269,193 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
// The current function returns.
#define ERR_FAIL_COND(m_cond) \
- { \
+ do { \
if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true."); \
return; \
} \
- }
+ } while (0)
#define ERR_FAIL_COND_MSG(m_cond, m_msg) \
- { \
+ do { \
if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true.", DEBUG_STR(m_msg)); \
return; \
} \
- }
+ } while (0)
// The current function returns m_retval.
#define ERR_FAIL_COND_V(m_cond, m_retval) \
- { \
+ do { \
if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. returned: " _STR(m_retval)); \
return m_retval; \
} \
- }
+ } while (0)
#define ERR_FAIL_COND_V_MSG(m_cond, m_retval, m_msg) \
- { \
+ do { \
if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. returned: " _STR(m_retval), DEBUG_STR(m_msg)); \
return m_retval; \
} \
- }
+ } while (0)
// The current loop continues.
-#define ERR_CONTINUE(m_cond) \
- { \
- if (unlikely(m_cond)) { \
+#define ERR_CONTINUE(m_cond) \
+ do { \
+ if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Continuing."); \
- continue; \
- } \
- }
+ continue; \
+ } \
+ } while (0)
-#define ERR_CONTINUE_MSG(m_cond, m_msg) \
- { \
- if (unlikely(m_cond)) { \
+#define ERR_CONTINUE_MSG(m_cond, m_msg) \
+ do { \
+ if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Continuing.", DEBUG_STR(m_msg)); \
- continue; \
- } \
- }
+ continue; \
+ } \
+ } while (0)
// The current loop breaks.
-#define ERR_BREAK(m_cond) \
- { \
- if (unlikely(m_cond)) { \
+#define ERR_BREAK(m_cond) \
+ do { \
+ if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Breaking."); \
- break; \
- } \
- }
+ break; \
+ } \
+ } while (0)
-#define ERR_BREAK_MSG(m_cond, m_msg) \
- { \
- if (unlikely(m_cond)) { \
+#define ERR_BREAK_MSG(m_cond, m_msg) \
+ do { \
+ if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Breaking.", DEBUG_STR(m_msg)); \
- break; \
- } \
- }
+ break; \
+ } \
+ } while (0)
// Only use CRASH macros if there is no sensible fallback, that is, the error is unrecoverable.
#define CRASH_COND(m_cond) \
- { \
+ do { \
if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Condition \"" _STR(m_cond) "\" is true."); \
GENERATE_TRAP(); \
} \
- }
+ } while (0)
#define CRASH_COND_MSG(m_cond, m_msg) \
- { \
+ do { \
if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Condition \"" _STR(m_cond) "\" is true.", DEBUG_STR(m_msg)); \
GENERATE_TRAP(); \
} \
- }
+ } while (0)
// Generic error macros.
// The current function returns.
#define ERR_FAIL() \
- { \
+ do { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/Function Failed."); \
return; \
- }
+ } while (0)
#define ERR_FAIL_MSG(m_msg) \
- { \
+ do { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/Function Failed.", DEBUG_STR(m_msg)); \
return; \
- }
+ } while (0)
// The current function returns m_retval.
#define ERR_FAIL_V(m_retval) \
- { \
+ do { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/Function Failed, returning: " __STR(m_value)); \
return m_retval; \
- }
+ } while (0)
#define ERR_FAIL_V_MSG(m_value, m_msg) \
- { \
+ do { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/Function Failed, returning: " __STR(m_value), DEBUG_STR(m_msg)); \
return m_value; \
- }
+ } while (0)
// Print error message macros.
#define ERR_PRINT(m_msg) \
- { \
+ do { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, DEBUG_STR(m_msg)); \
- }
+ } while (0)
// Only prints the error message once.
#define ERR_PRINT_ONCE(m_msg) \
- { \
+ do { \
static bool first_print = true; \
if (first_print) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, DEBUG_STR(m_msg)); \
first_print = false; \
} \
- }
+ } while (0)
// Print warning message macros.
// To warn about deprecated usage, use `WARN_DEPRECATED` or `WARN_DEPRECATED_MSG` instead.
#define WARN_PRINT(m_msg) \
- { \
+ do { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, DEBUG_STR(m_msg), ERR_HANDLER_WARNING); \
- }
+ } while (0)
// Only prints the warning message once.
#define WARN_PRINT_ONCE(m_msg) \
- { \
+ do { \
static bool first_print = true; \
if (first_print) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, DEBUG_STR(m_msg), ERR_HANDLER_WARNING); \
first_print = false; \
} \
- }
+ } while (0)
// Print deprecated warning message macros.
// Only prints the warning message once.
-#define WARN_DEPRECATED \
- { \
- static volatile bool warning_shown = false; \
- if (!warning_shown) { \
+#define WARN_DEPRECATED \
+ do { \
+ static volatile bool warning_shown = false; \
+ if (!warning_shown) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "This method has been deprecated and will be removed in the future.", ERR_HANDLER_WARNING); \
- warning_shown = true; \
- } \
- }
-
-#define WARN_DEPRECATED_MSG(m_msg) \
- { \
- static volatile bool warning_shown = false; \
- if (!warning_shown) { \
+ warning_shown = true; \
+ } \
+ } while (0)
+
+#define WARN_DEPRECATED_MSG(m_msg) \
+ do { \
+ static volatile bool warning_shown = false; \
+ if (!warning_shown) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "This method has been deprecated and will be removed in the future.", DEBUG_STR(m_msg), ERR_HANDLER_WARNING); \
- warning_shown = true; \
- } \
- }
+ warning_shown = true; \
+ } \
+ } while (0)
// Only use CRASH macros if there is no sensible fallback, that is, the error is unrecoverable.
#define CRASH_NOW() \
- { \
+ do { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Method/Function Failed."); \
GENERATE_TRAP(); \
- }
+ } while (0)
#define CRASH_NOW_MSG(m_msg) \
- { \
+ do { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Method/Function Failed.", DEBUG_STR(m_msg)); \
GENERATE_TRAP(); \
- }
+ } while (0)
#endif
diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp
index f155d626d7..7ad907db97 100644
--- a/core/math/bsp_tree.cpp
+++ b/core/math/bsp_tree.cpp
@@ -341,7 +341,7 @@ static int _bsp_create_node(const Face3 *p_faces, const Vector<int> &p_indices,
ERR_FAIL_COND_V(p_nodes.size() == BSP_Tree::MAX_NODES, -1);
// should not reach here
- ERR_FAIL_COND_V(p_indices.size() == 0, -1)
+ ERR_FAIL_COND_V(p_indices.size() == 0, -1);
int ic = p_indices.size();
const int *indices = p_indices.ptr();