summaryrefslogtreecommitdiffstats
path: root/core/error_macros.h
diff options
context:
space:
mode:
authormarxin <mliska@suse.cz>2019-02-20 21:59:03 +0100
committermarxin <mliska@suse.cz>2019-02-21 19:34:35 +0100
commit7de7f0ef178d2800f1ca70c15e8aff8aeb16bb8d (patch)
treee4d933f2c7ea2259b2821b2601aba224d38184f6 /core/error_macros.h
parenta01dca79e2f7b7cb221a4c416cade4fad2941446 (diff)
downloadredot-engine-7de7f0ef178d2800f1ca70c15e8aff8aeb16bb8d.tar.gz
Fix all -Wtype-limits warnings.
Diffstat (limited to 'core/error_macros.h')
-rw-r--r--core/error_macros.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/error_macros.h b/core/error_macros.h
index 60a0e8a7dc..3aa8ed4596 100644
--- a/core/error_macros.h
+++ b/core/error_macros.h
@@ -154,6 +154,20 @@ extern bool _err_error_exists;
_err_error_exists = false; \
} while (0); // (*)
+/** An index has failed if m_index >=m_size, the function exists.
+* This function returns an error value, if returning Error, please select the most
+* appropriate error condition from error_macros.h
+*/
+
+#define ERR_FAIL_UNSIGNED_INDEX_V(m_index, m_size, m_retval) \
+ do { \
+ if (unlikely((m_index) >= (m_size))) { \
+ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \
+ return m_retval; \
+ } else \
+ _err_error_exists = false; \
+ } while (0); // (*)
+
/** Use this one if there is no sensible fallback, that is, the error is unrecoverable.
* We'll return a null reference and try to keep running.
*/