diff options
author | Corey Farrell <git@cfware.com> | 2016-07-18 23:46:19 -0400 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2016-07-19 22:45:10 -0500 |
commit | 8f6e9ffcc6231cfd4ae6c0a8b6e1d11beb59dc58 (patch) | |
tree | c8fbcec636d9768af4aef932844c21d7c36c6464 /include/asterisk/utils.h | |
parent | 333a0fed33dccc5ae676dd78ef2e6e5331fbe1e1 (diff) |
Add conditional support for noreturn functions.
This adds support for tagging functions with the noreturn attribute.
If DO_CRASH is enabled then ast_do_crash never returns. If AST_DEVMODE
and DO_CRASH are enabled then failed assertions never return. This can
resolve a large number of false positives with static analyzers.
ASTERISK-26220 #close
Change-Id: Icfb61e5fe54574eced4c3e88b317244f467ec753
Diffstat (limited to 'include/asterisk/utils.h')
-rw-r--r-- | include/asterisk/utils.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h index c7a473732..c311e9cd5 100644 --- a/include/asterisk/utils.h +++ b/include/asterisk/utils.h @@ -843,9 +843,14 @@ struct ast_http_digest { */ int ast_parse_digest(const char *digest, struct ast_http_digest *d, int request, int pedantic); +#ifdef DO_CRASH +#define DO_CRASH_NORETURN attribute_noreturn +#else +#define DO_CRASH_NORETURN +#endif #ifdef AST_DEVMODE -void __ast_assert_failed(int condition, const char *condition_str, const char *file, int line, const char *function); +void DO_CRASH_NORETURN __ast_assert_failed(int condition, const char *condition_str, const char *file, int line, const char *function); #define ast_assert(a) _ast_assert(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__) static void force_inline _ast_assert(int condition, const char *condition_str, const char *file, int line, const char *function) { @@ -864,7 +869,7 @@ static void force_inline _ast_assert(int condition, const char *condition_str, c * * \return Nothing */ -void ast_do_crash(void); +void DO_CRASH_NORETURN ast_do_crash(void); #include "asterisk/strings.h" |