diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2019-02-22 09:44:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-22 09:44:59 +0100 |
| commit | 60fe9321ac8b3b7a7f9ba9ddd515bdf515ea8457 (patch) | |
| tree | 94b3c7be9e61ebbc3d5c92772094ffe9b0ae7c0f /core/error_macros.h | |
| parent | 8b231b96e347b677ea4189784c960bc4517b8e6a (diff) | |
| parent | 7de7f0ef178d2800f1ca70c15e8aff8aeb16bb8d (diff) | |
Merge pull request #26099 from marxin/fix-Wtype-limits-warnings
Fix all -Wtype-limits warnings.
Diffstat (limited to 'core/error_macros.h')
| -rw-r--r-- | core/error_macros.h | 14 |
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. */ |