diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-05-15 22:07:30 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-05-15 22:07:30 +0000 |
commit | 5618e1f6b96ab41bc3f2890e31edf775a5e44896 (patch) | |
tree | 482c3b6a850114b01b39bfa128268359ed0bc69c /include/asterisk | |
parent | 53b73c77ba690ea278d636f2e838bd8c8078fe22 (diff) |
Merged revisions 116694 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r116694 | tilghman | 2008-05-15 17:05:47 -0500 (Thu, 15 May 2008) | 4 lines
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: http://svn.digium.com/svn/asterisk/branches/1.6.0@116695 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include/asterisk')
-rw-r--r-- | include/asterisk/strings.h | 15 | ||||
-rw-r--r-- | include/asterisk/utils.h | 4 |
2 files changed, 17 insertions, 2 deletions
diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h index 226c7bb67..79dac8700 100644 --- a/include/asterisk/strings.h +++ b/include/asterisk/strings.h @@ -29,10 +29,25 @@ /* 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) { return (!s || (*s == '\0')); } +#endif /*! \brief returns the equivalent of logic or for strings: * first one if not empty, otherwise second one. diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h index 0de0727a7..4989b6d88 100644 --- a/include/asterisk/utils.h +++ b/include/asterisk/utils.h @@ -662,8 +662,8 @@ static void force_inline _ast_assert(int condition, const char *condition_str, if (__builtin_expect(!condition, 1)) { /* Attempt to put it into the logger, but hope that at least someone saw the * message on stderr ... */ - ast_log(LOG_ERROR, "FRACK!, Failed assertion %s (%d) at line %d in %s of %s\n", - condition_str, condition, line, function, file); + ast_log(__LOG_ERROR, file, line, function, "FRACK!, Failed assertion %s (%d)\n", + condition_str, condition); fprintf(stderr, "FRACK!, Failed assertion %s (%d) at line %d in %s of %s\n", condition_str, condition, line, function, file); /* Give the logger a chance to get the message out, just in case we abort(), or |