summaryrefslogtreecommitdiff
path: root/tests/test_cel.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2013-12-20 20:00:50 +0000
committerRichard Mudgett <rmudgett@digium.com>2013-12-20 20:00:50 +0000
commit72c282cc66d7e12cd17d0eee90e066d9ebfb1243 (patch)
tree58107b777c3f75160878837662fbaf825163556b /tests/test_cel.c
parentc2fd2ac823d89283a0e9a0a9e8d36c92fba25c27 (diff)
ao2_iterator: Mini-audit of the ao2_iterator loops in the new code files.
* Fixed several places where ao2_iterator_destroy() was not called. * Fixed several iterator loop object variable reference problems. * Fixed res_parking AMI actions returning non-zero. Only the AMI logoff action can return non-zero. Review: https://reviewboard.asterisk.org/r/3087/ ........ Merged revisions 404434 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404436 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'tests/test_cel.c')
-rw-r--r--tests/test_cel.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/tests/test_cel.c b/tests/test_cel.c
index 62a3288e0..f509cc5d3 100644
--- a/tests/test_cel.c
+++ b/tests/test_cel.c
@@ -1906,8 +1906,10 @@ static int dump_event(struct ast_test *test, struct ast_event *event)
static int check_events(struct ast_test *test, struct ao2_container *local_expected, struct ao2_container *local_received)
{
- struct ao2_iterator expected_it, received_it;
- struct ast_event *rx_event, *ex_event;
+ struct ao2_iterator received_it;
+ struct ao2_iterator expected_it;
+ RAII_VAR(struct ast_event *, rx_event, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_event *, ex_event, NULL, ao2_cleanup);
int debug = 0;
if (ao2_container_count(local_expected) != ao2_container_count(local_received)) {
@@ -1918,12 +1920,14 @@ static int check_events(struct ast_test *test, struct ao2_container *local_expec
debug = 1;
}
- expected_it = ao2_iterator_init(local_expected, 0);
received_it = ao2_iterator_init(local_received, 0);
+ expected_it = ao2_iterator_init(local_expected, 0);
rx_event = ao2_iterator_next(&received_it);
ex_event = ao2_iterator_next(&expected_it);
while (rx_event && ex_event) {
if (!events_are_equal(test, rx_event, ex_event)) {
+ ao2_iterator_destroy(&received_it);
+ ao2_iterator_destroy(&expected_it);
ast_test_status_update(test, "Received event:\n");
dump_event(test, rx_event);
ast_test_status_update(test, "Expected event:\n");
@@ -1931,7 +1935,9 @@ static int check_events(struct ast_test *test, struct ao2_container *local_expec
return -1;
}
if (debug) {
- ast_test_status_update(test, "Compared events successfully%s\n", ast_event_get_type(ex_event) == AST_EVENT_CUSTOM ? " (wildcard match)" : "");
+ ast_test_status_update(test, "Compared events successfully%s\n",
+ ast_event_get_type(ex_event) == AST_EVENT_CUSTOM
+ ? " (wildcard match)" : "");
dump_event(test, rx_event);
}
ao2_cleanup(rx_event);
@@ -1939,17 +1945,17 @@ static int check_events(struct ast_test *test, struct ao2_container *local_expec
rx_event = ao2_iterator_next(&received_it);
ex_event = ao2_iterator_next(&expected_it);
}
+ ao2_iterator_destroy(&received_it);
+ ao2_iterator_destroy(&expected_it);
if (rx_event) {
ast_test_status_update(test, "Received event:\n");
dump_event(test, rx_event);
- ao2_cleanup(rx_event);
return -1;
}
if (ex_event) {
ast_test_status_update(test, "Expected event:\n");
dump_event(test, ex_event);
- ao2_cleanup(ex_event);
return -1;
}
return 0;