diff options
author | Corey Farrell <git@cfware.com> | 2016-09-16 19:54:07 -0400 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2016-09-30 19:25:40 -0400 |
commit | 2a03575c30b96ab23e75822c3b256fa0cb591aaa (patch) | |
tree | de4f50f0fe625ed866efd337b5f60f8c711a1f52 /main/astobj2_container.c | |
parent | 224c2952922d769af2d0e77da5612b8b7a649b42 (diff) |
astobj2: Add backtrace to log_bad_ao2.
* Compile __ast_assert_failed unconditionally.
* Use __ast_assert_failed to log messages from log_bad_ao2
* Remove calls to ast_assert(0) that happen after log_bad_ao2 was run.
Change-Id: I48f1af44b2718ad74a421ff75cb6397b924a9751
Diffstat (limited to 'main/astobj2_container.c')
-rw-r--r-- | main/astobj2_container.c | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/main/astobj2_container.c b/main/astobj2_container.c index c00da9fd4..15fd41286 100644 --- a/main/astobj2_container.c +++ b/main/astobj2_container.c @@ -101,10 +101,13 @@ int __ao2_link(struct ao2_container *self, void *obj_new, int flags, struct ao2_container_node *node; if (!__is_ao2_object(obj_new, file, line, func) - || !__is_ao2_object(self, file, line, func) - || !self->v_table || !self->v_table->new_node || !self->v_table->insert) { + || !__is_ao2_object(self, file, line, func)) { + return 0; + } + + if (!self->v_table || !self->v_table->new_node || !self->v_table->insert) { /* Sanity checks. */ - ast_assert(0); + __ast_assert_failed(0, "invalid container v_table", file, line, func); return 0; } @@ -176,7 +179,6 @@ void *__ao2_unlink(struct ao2_container *c, void *user_data, int flags, { if (!__is_ao2_object(user_data, file, line, func)) { /* Sanity checks. */ - ast_assert(0); return NULL; } @@ -241,10 +243,14 @@ static void *internal_ao2_traverse(struct ao2_container *self, enum search_flags struct ao2_container *multi_container = NULL; struct ao2_iterator *multi_iterator = NULL; - if (!__is_ao2_object(self, file, line, func) || !self->v_table + if (!__is_ao2_object(self, file, line, func)) { + return NULL; + } + + if (!self->v_table || !self->v_table->traverse_first || !self->v_table->traverse_next) { /* Sanity checks. */ - ast_assert(0); + __ast_assert_failed(0, "invalid container v_table", file, line, func); return NULL; } @@ -451,8 +457,7 @@ struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) void ao2_iterator_restart(struct ao2_iterator *iter) { if (!is_ao2_object(iter->c)) { - ast_log(LOG_ERROR, "Iterator container is not valid.\n"); - ast_assert(0); + /* Sanity check. */ return; } @@ -460,12 +465,6 @@ void ao2_iterator_restart(struct ao2_iterator *iter) if (iter->last_node) { enum ao2_lock_req orig_lock; - if (!is_ao2_object(iter->c)) { - /* Sanity check. */ - ast_assert(0); - return; - } - /* * Do a read lock in case the container node unref does not * destroy the node. If the container node is destroyed then @@ -521,10 +520,13 @@ void *__ao2_iterator_next(struct ao2_iterator *iter, struct ao2_container_node *node; void *ret; - if (!__is_ao2_object(iter->c, file, line, func) - || !iter->c->v_table || !iter->c->v_table->iterator_next) { + if (!__is_ao2_object(iter->c, file, line, func)) { + return NULL; + } + + if (!iter->c->v_table || !iter->c->v_table->iterator_next) { /* Sanity checks. */ - ast_assert(0); + __ast_assert_failed(0, "invalid iterator container v_table", file, line, func); return NULL; } @@ -661,12 +663,16 @@ struct ao2_container *__ao2_container_clone(struct ao2_container *orig, enum sea int failed; /* Create the clone container with the same properties as the original. */ - if (!__is_ao2_object(orig, file, line, func) - || !orig->v_table || !orig->v_table->alloc_empty_clone) { + if (!__is_ao2_object(orig, file, line, func)) { + return NULL; + } + + if (!orig->v_table || !orig->v_table->alloc_empty_clone) { /* Sanity checks. */ - ast_assert(0); + __ast_assert_failed(0, "invalid container v_table", file, line, func); return NULL; } + clone = orig->v_table->alloc_empty_clone(orig, tag, file, line, func); if (!clone) { return NULL; |