mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-22 12:52:33 +00:00
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
This commit is contained in:
@@ -103,6 +103,9 @@
|
||||
/* Define to 1 if your GCC C compiler supports the 'may_alias' attribute. */
|
||||
#undef HAVE_ATTRIBUTE_may_alias
|
||||
|
||||
/* Define to 1 if your GCC C compiler supports the 'noreturn' attribute. */
|
||||
#undef HAVE_ATTRIBUTE_noreturn
|
||||
|
||||
/* Define to 1 if your GCC C compiler supports the 'pure' attribute. */
|
||||
#undef HAVE_ATTRIBUTE_pure
|
||||
|
||||
|
@@ -77,6 +77,12 @@
|
||||
#define attribute_may_alias
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ATTRIBUTE_noreturn
|
||||
#define attribute_noreturn __attribute__((noreturn))
|
||||
#else
|
||||
#define attribute_noreturn
|
||||
#endif
|
||||
|
||||
/* Some older version of GNU gcc (3.3.5 on OpenBSD 4.3 for example) dont like 'NULL' as sentinel */
|
||||
#define SENTINEL ((char *)NULL)
|
||||
|
||||
|
@@ -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"
|
||||
|
||||
|
Reference in New Issue
Block a user