[Asterisk-code-review] cdr.c: Replace redundant check with an ast assert() (asterisk[15])

Richard Mudgett asteriskteam at digium.com
Mon Oct 9 13:34:20 CDT 2017


Richard Mudgett has uploaded this change for review. ( https://gerrit.asterisk.org/6708


Change subject: cdr.c: Replace redundant check with an ast_assert()
......................................................................

cdr.c: Replace redundant check with an ast_assert()

The only caller of cdr_object_fn_table.process_party_b() explicitly does
the check before calling.

Change-Id: Ib0c53cdf5048227842846e0df9d2c19117c45618
---
M main/cdr.c
1 file changed, 5 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/08/6708/1

diff --git a/main/cdr.c b/main/cdr.c
index 1817e80..0703f9e 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -1623,11 +1623,9 @@
 static void dial_state_process_party_b(struct cdr_object *cdr, struct ast_channel_snapshot *snapshot)
 {
 	ast_assert(snapshot != NULL);
+	ast_assert(cdr->party_b.snapshot
+		&& !strcasecmp(cdr->party_b.snapshot->name, snapshot->name));
 
-	if (!cdr->party_b.snapshot
-		|| strcasecmp(cdr->party_b.snapshot->name, snapshot->name)) {
-		return;
-	}
 	cdr_object_swap_snapshot(&cdr->party_b, snapshot);
 
 	/* If party B hangs up, finalize this CDR */
@@ -1823,10 +1821,9 @@
 
 static void bridge_state_process_party_b(struct cdr_object *cdr, struct ast_channel_snapshot *snapshot)
 {
-	if (!cdr->party_b.snapshot
-		|| strcasecmp(cdr->party_b.snapshot->name, snapshot->name)) {
-		return;
-	}
+	ast_assert(cdr->party_b.snapshot
+		&& !strcasecmp(cdr->party_b.snapshot->name, snapshot->name));
+
 	cdr_object_swap_snapshot(&cdr->party_b, snapshot);
 
 	/* If party B hangs up, finalize this CDR */

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

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib0c53cdf5048227842846e0df9d2c19117c45618
Gerrit-Change-Number: 6708
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171009/0df3663d/attachment.html>


More information about the asterisk-code-review mailing list