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

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


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


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/07/6707/1

diff --git a/main/cdr.c b/main/cdr.c
index 4bcfc05..f313f0b 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -1626,11 +1626,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 */
@@ -1826,10 +1824,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/6707
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib0c53cdf5048227842846e0df9d2c19117c45618
Gerrit-Change-Number: 6707
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/1d587199/attachment.html>


More information about the asterisk-code-review mailing list