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

Richard Mudgett asteriskteam at digium.com
Fri Apr 13 17:40:45 CDT 2018


Richard Mudgett has posted comments on this change. ( https://gerrit.asterisk.org/8778 )

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


Patch Set 2: Code-Review-1

(1 comment)

https://gerrit.asterisk.org/#/c/8778/2/include/asterisk/utils.h
File include/asterisk/utils.h:

https://gerrit.asterisk.org/#/c/8778/2/include/asterisk/utils.h@863
PS2, Line 863: #define ast_assert_else(a, _else) if (__builtin_expect(!(a), 1)) { \
             : 	_ast_assert(0, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
             : 	_else; \
             : }
You wanted examples.  Here are some horrid code examples pulled from asterisk code that currently do ast_assert(0) that you are inviting with this patch:

ast_assert_else(conf, return -1);

ast_assert_else(event, return);

Yes the below will compile as ast_assert_else() is currently defined.  Note there is no semicolon on the end of the ast_assert_else() line.

ast_assert_else(cdr, ({ ast_log(AST_LOG_WARNING, "No CDR for channel %s\n", caller ? caller->name : peer->name); return; }))
else if (new_snapshot) {
}

ast_assert_else(!cdr_object_format_property(it_cdr, cdr_readonly_vars[i], workspace, sizeof(workspace)), continue);

ast_assert_else(orig->v_table && orig->v_table->alloc_empty_clone_debug, return NULL);

ast_assert_else(is_ao2_object(self) && self->v_table, ({prnt(where, "Invalid container\n"); return; }));



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

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: comment
Gerrit-Change-Id: I0003844affeab550d5ff5bca7aa7cf8a559b873e
Gerrit-Change-Number: 8778
Gerrit-PatchSet: 2
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-Comment-Date: Fri, 13 Apr 2018 22:40:45 +0000
Gerrit-HasComments: Yes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180413/6700a741/attachment-0001.html>


More information about the asterisk-code-review mailing list