Add an extra check in ast_strlen_zero, and make ast_assert() not print the
file, line, and function name twice. (Closes issue #12650) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@116694 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
parent
f97d547aba
commit
5168282ba1
|
@ -29,10 +29,25 @@
|
||||||
|
|
||||||
/* You may see casts in this header that may seem useless but they ensure this file is C++ clean */
|
/* You may see casts in this header that may seem useless but they ensure this file is C++ clean */
|
||||||
|
|
||||||
|
#ifdef AST_DEVMODE
|
||||||
|
#define ast_strlen_zero(foo) _ast_strlen_zero(foo, __FILE__, __PRETTY_FUNCTION__, __LINE__)
|
||||||
|
static force_inline int _ast_strlen_zero(const char *s, const char *file, const char *function, int line)
|
||||||
|
{
|
||||||
|
if (!s || (*s == '\0')) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (!strcmp(s, "(null)")) {
|
||||||
|
ast_log(__LOG_WARNING, file, line, function, "Possible programming error: \"(null)\" is not NULL!\n");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
static force_inline int ast_strlen_zero(const char *s)
|
static force_inline int ast_strlen_zero(const char *s)
|
||||||
{
|
{
|
||||||
return (!s || (*s == '\0'));
|
return (!s || (*s == '\0'));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*! \brief returns the equivalent of logic or for strings:
|
/*! \brief returns the equivalent of logic or for strings:
|
||||||
* first one if not empty, otherwise second one.
|
* first one if not empty, otherwise second one.
|
||||||
|
|
|
@ -662,8 +662,8 @@ static void force_inline _ast_assert(int condition, const char *condition_str,
|
||||||
if (__builtin_expect(!condition, 1)) {
|
if (__builtin_expect(!condition, 1)) {
|
||||||
/* Attempt to put it into the logger, but hope that at least someone saw the
|
/* Attempt to put it into the logger, but hope that at least someone saw the
|
||||||
* message on stderr ... */
|
* message on stderr ... */
|
||||||
ast_log(LOG_ERROR, "FRACK!, Failed assertion %s (%d) at line %d in %s of %s\n",
|
ast_log(__LOG_ERROR, file, line, function, "FRACK!, Failed assertion %s (%d)\n",
|
||||||
condition_str, condition, line, function, file);
|
condition_str, condition);
|
||||||
fprintf(stderr, "FRACK!, Failed assertion %s (%d) at line %d in %s of %s\n",
|
fprintf(stderr, "FRACK!, Failed assertion %s (%d) at line %d in %s of %s\n",
|
||||||
condition_str, condition, line, function, file);
|
condition_str, condition, line, function, file);
|
||||||
/* Give the logger a chance to get the message out, just in case we abort(), or
|
/* Give the logger a chance to get the message out, just in case we abort(), or
|
||||||
|
|
Loading…
Reference in New Issue