[Asterisk-code-review] utils: Add ast assert else (asterisk[master])

George Joseph asteriskteam at digium.com
Fri Apr 13 15:21:18 CDT 2018


George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/8780


Change subject: utils:  Add ast_assert_else
......................................................................

utils:  Add ast_assert_else

Similar to pjproject's PJ_ASSERT_ macros, this one will do the
following...

If the assert passes... NoOp
If the assert fails and AST_DEVMODE is defined, execute ast_assert().
If the assert fails and AST_DEVMODE is not defined, execute the
supplied statement.

Change-Id: I0003844affeab550d5ff5bca7aa7cf8a559b873e
---
M include/asterisk/utils.h
1 file changed, 7 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/80/8780/1

diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h
index 4da7fa4..20ff4a7 100644
--- a/include/asterisk/utils.h
+++ b/include/asterisk/utils.h
@@ -578,6 +578,10 @@
 
 #ifdef AST_DEVMODE
 #define ast_assert(a) _ast_assert(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ast_assert_else(a, _else) if (__builtin_expect(!(a), 1)) { \
+	ast_assert(a); \
+	_else; \
+}
 static void force_inline _ast_assert(int condition, const char *condition_str, const char *file, int line, const char *function)
 {
 	if (__builtin_expect(!condition, 1)) {
@@ -586,6 +590,9 @@
 }
 #else
 #define ast_assert(a)
+#define ast_assert_else(a, _else) if (__builtin_expect(!(a), 1)) { \
+	_else; \
+}
 #endif
 
 /*!

-- 
To view, visit https://gerrit.asterisk.org/8780
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0003844affeab550d5ff5bca7aa7cf8a559b873e
Gerrit-Change-Number: 8780
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180413/b53a142b/attachment.html>


More information about the asterisk-code-review mailing list