summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-01-22 16:08:34 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-01-22 16:08:34 +0100
commit56fdef281ecc40e8ce10d4e17aa1357b150aca18 (patch)
treed0baa4f300b6fcbff4a4bc52dec2a956d2ac8bdd
parent0440b3cf0e60461d6ecfb9ed2d12b06fe901671c (diff)
parent22c178582631ae8a2b7c60c0bcb0ce4cd9e04de4 (diff)
Merge pull request #71851 from mihe/error-macros
Fix incorrect index error macros
-rw-r--r--core/error/error_macros.cpp4
-rw-r--r--core/error/error_macros.h48
2 files changed, 26 insertions, 26 deletions
diff --git a/core/error/error_macros.cpp b/core/error/error_macros.cpp
index ddfee3fc5d..8376c0aaf8 100644
--- a/core/error/error_macros.cpp
+++ b/core/error/error_macros.cpp
@@ -118,11 +118,11 @@ void _err_print_error(const char *p_function, const char *p_file, int p_line, co
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, const char *p_message, bool p_editor_notify, bool p_fatal) {
String fstr(p_fatal ? "FATAL: " : "");
String err(fstr + "Index " + p_index_str + " = " + itos(p_index) + " is out of bounds (" + p_size_str + " = " + itos(p_size) + ").");
- _err_print_error(p_function, p_file, p_line, err.utf8().get_data(), p_message);
+ _err_print_error(p_function, p_file, p_line, err.utf8().get_data(), p_message, p_editor_notify, ERR_HANDLER_ERROR);
}
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, const String &p_message, bool p_editor_notify, bool p_fatal) {
- _err_print_index_error(p_function, p_file, p_line, p_index, p_size, p_index_str, p_size_str, p_message.utf8().get_data(), p_fatal);
+ _err_print_index_error(p_function, p_file, p_line, p_index, p_size, p_index_str, p_size_str, p_message.utf8().get_data(), p_editor_notify, p_fatal);
}
void _err_flush_stdout() {
diff --git a/core/error/error_macros.h b/core/error/error_macros.h
index 63a2d22416..65804b7796 100644
--- a/core/error/error_macros.h
+++ b/core/error/error_macros.h
@@ -189,12 +189,12 @@ void _err_flush_stdout();
* Ensures an integer index `m_index` is less than `m_size` and greater than or equal to 0.
* If not, the application crashes.
*/
-#define CRASH_BAD_INDEX(m_index, m_size) \
- if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
- _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), "", true); \
- _err_flush_stdout(); \
- GENERATE_TRAP(); \
- } else \
+#define CRASH_BAD_INDEX(m_index, m_size) \
+ if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
+ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), "", false, true); \
+ _err_flush_stdout(); \
+ GENERATE_TRAP(); \
+ } else \
((void)0)
/**
@@ -204,12 +204,12 @@ void _err_flush_stdout();
* Ensures an integer index `m_index` is less than `m_size` and greater than or equal to 0.
* If not, prints `m_msg` and the application crashes.
*/
-#define CRASH_BAD_INDEX_MSG(m_index, m_size, m_msg) \
- if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
- _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg, true); \
- _err_flush_stdout(); \
- GENERATE_TRAP(); \
- } else \
+#define CRASH_BAD_INDEX_MSG(m_index, m_size, m_msg) \
+ if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
+ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg, false, true); \
+ _err_flush_stdout(); \
+ GENERATE_TRAP(); \
+ } else \
((void)0)
// Unsigned integer index out of bounds error macros.
@@ -292,12 +292,12 @@ void _err_flush_stdout();
* Ensures an unsigned integer index `m_index` is less than `m_size`.
* If not, the application crashes.
*/
-#define CRASH_BAD_UNSIGNED_INDEX(m_index, m_size) \
- if (unlikely((m_index) >= (m_size))) { \
- _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), "", true); \
- _err_flush_stdout(); \
- GENERATE_TRAP(); \
- } else \
+#define CRASH_BAD_UNSIGNED_INDEX(m_index, m_size) \
+ if (unlikely((m_index) >= (m_size))) { \
+ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), "", false, true); \
+ _err_flush_stdout(); \
+ GENERATE_TRAP(); \
+ } else \
((void)0)
/**
@@ -307,12 +307,12 @@ void _err_flush_stdout();
* Ensures an unsigned integer index `m_index` is less than `m_size`.
* If not, prints `m_msg` and the application crashes.
*/
-#define CRASH_BAD_UNSIGNED_INDEX_MSG(m_index, m_size, m_msg) \
- if (unlikely((m_index) >= (m_size))) { \
- _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg, true); \
- _err_flush_stdout(); \
- GENERATE_TRAP(); \
- } else \
+#define CRASH_BAD_UNSIGNED_INDEX_MSG(m_index, m_size, m_msg) \
+ if (unlikely((m_index) >= (m_size))) { \
+ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg, false, true); \
+ _err_flush_stdout(); \
+ GENERATE_TRAP(); \
+ } else \
((void)0)
// Null reference error macros.