[asterisk-commits] res pjsip mwi.c: Use safer loop coding in mwi subscription m... (asterisk[13])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 7 20:38:42 CDT 2015


Matt Jordan has submitted this change and it was merged.

Change subject: res_pjsip_mwi.c: Use safer loop coding in mwi_subscription_mailboxes_str().
......................................................................


res_pjsip_mwi.c: Use safer loop coding in mwi_subscription_mailboxes_str().

Change-Id: I6f39d809a6d1b47b35bb32b298f5a12f35d6f907
---
M res/res_pjsip_mwi.c
1 file changed, 8 insertions(+), 6 deletions(-)

Approvals:
  Mark Michelson: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Matt Jordan: Looks good to me, approved



diff --git a/res/res_pjsip_mwi.c b/res/res_pjsip_mwi.c
index 17b07e1..6ca6cce 100644
--- a/res/res_pjsip_mwi.c
+++ b/res/res_pjsip_mwi.c
@@ -751,16 +751,16 @@
 static void mwi_subscription_mailboxes_str(struct ao2_container *stasis_subs,
 					   struct ast_str **str)
 {
-	int num = ao2_container_count(stasis_subs);
-
+	int is_first = 1;
 	struct mwi_stasis_subscription *node;
 	struct ao2_iterator i = ao2_iterator_init(stasis_subs, 0);
 
 	while ((node = ao2_iterator_next(&i))) {
-		if (--num) {
-			ast_str_append(str, 0, "%s,", node->mailbox);
-		} else {
+		if (is_first) {
+			is_first = 0;
 			ast_str_append(str, 0, "%s", node->mailbox);
+		} else {
+			ast_str_append(str, 0, ",%s", node->mailbox);
 		}
 		ao2_ref(node, -1);
 	}
@@ -815,7 +815,9 @@
 static int send_notify(void *obj, void *arg, int flags)
 {
 	struct mwi_subscription *mwi_sub = obj;
-	struct ast_taskprocessor *serializer = mwi_sub->is_solicited ? ast_sip_subscription_get_serializer(mwi_sub->sip_sub) : NULL;
+	struct ast_taskprocessor *serializer = mwi_sub->is_solicited
+		? ast_sip_subscription_get_serializer(mwi_sub->sip_sub)
+		: NULL;
 
 	if (ast_sip_push_task(serializer, serialized_notify, ao2_bump(mwi_sub))) {
 		ao2_ref(mwi_sub, -1);

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6f39d809a6d1b47b35bb32b298f5a12f35d6f907
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>



More information about the asterisk-commits mailing list