diff options
author | Richard Mudgett <rmudgett@digium.com> | 2015-06-30 11:17:25 -0500 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2015-07-06 16:10:57 -0500 |
commit | 030e8339dde26e4307366acf23633448b45b7043 (patch) | |
tree | 9d9e59c331b5161272ff51fbd95e9423bef7bdaf /res/res_pjsip_mwi.c | |
parent | 453d7b8d699443e494ae1442a9c8810f20435346 (diff) |
res_pjsip_mwi.c: Use safer loop coding in mwi_subscription_mailboxes_str().
Change-Id: I6f39d809a6d1b47b35bb32b298f5a12f35d6f907
Diffstat (limited to 'res/res_pjsip_mwi.c')
-rw-r--r-- | res/res_pjsip_mwi.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/res/res_pjsip_mwi.c b/res/res_pjsip_mwi.c index 4e7301070..9d39c6a62 100644 --- a/res/res_pjsip_mwi.c +++ b/res/res_pjsip_mwi.c @@ -751,16 +751,16 @@ static void *mwi_get_notify_data(struct ast_sip_subscription *sub) 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 serialized_cleanup(void *userdata) 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); |