diff options
author | Tilghman Lesher <tilghman@meg.abyt.es> | 2008-05-15 22:05:47 +0000 |
---|---|---|
committer | Tilghman Lesher <tilghman@meg.abyt.es> | 2008-05-15 22:05:47 +0000 |
commit | 5168282ba1030064777679caaca672787e743975 (patch) | |
tree | 15393f4e2dffa9a3089f997f959ad956f2d3e4af /include/asterisk/strings.h | |
parent | f97d547aba49d353f35f96f235f6c0cc3a9879f9 (diff) |
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
Diffstat (limited to 'include/asterisk/strings.h')
-rw-r--r-- | include/asterisk/strings.h | 15 |
1 files changed, 15 insertions, 0 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. |