X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fctf-writer%2Fresolve.c;h=ccb55a24bd9f0767a17c465d79ac75532e667c4c;hb=498e7994d60bd0e9f63c3d5c0fd00eec77ba7c34;hp=0d5e1c5f40dc07470546d7877ff85553f5d8c564;hpb=ef267d12284b855bc52ee429a5dc12da1d1e3b95;p=babeltrace.git diff --git a/src/ctf-writer/resolve.c b/src/ctf-writer/resolve.c index 0d5e1c5f..ccb55a24 100644 --- a/src/ctf-writer/resolve.c +++ b/src/ctf-writer/resolve.c @@ -36,9 +36,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include "common/macros.h" @@ -179,7 +179,7 @@ end: * Checks whether or not `stack` is empty. */ static -bt_bool type_stack_empty(type_stack *stack) +bt_ctf_bool type_stack_empty(type_stack *stack) { return stack->len == 0; } @@ -201,15 +201,10 @@ size_t type_stack_size(type_stack *stack) static struct type_stack_frame *type_stack_peek(type_stack *stack) { - struct type_stack_frame *entry = NULL; + BT_ASSERT(stack); + BT_ASSERT(!type_stack_empty(stack)); - if (!stack || type_stack_empty(stack)) { - goto end; - } - - entry = g_ptr_array_index(stack, stack->len - 1); -end: - return entry; + return g_ptr_array_index(stack, stack->len - 1); } /* @@ -218,19 +213,12 @@ end: * Return value is owned by `stack`. */ static -struct type_stack_frame *type_stack_at(type_stack *stack, - size_t index) +struct type_stack_frame *type_stack_at(type_stack *stack, size_t index) { - struct type_stack_frame *entry = NULL; + BT_ASSERT(stack); + BT_ASSERT(index < stack->len); - if (!stack || index >= stack->len) { - goto end; - } - - entry = g_ptr_array_index(stack, index); - -end: - return entry; + return g_ptr_array_index(stack, index); } /* @@ -259,7 +247,7 @@ static struct bt_ctf_field_type_common *get_type_from_ctx(struct resolve_context *ctx, enum bt_ctf_scope scope) { - BT_ASSERT(scope >= BT_CTF_SCOPE_TRACE_PACKET_HEADER && + BT_ASSERT_DBG(scope >= BT_CTF_SCOPE_TRACE_PACKET_HEADER && scope <= BT_CTF_SCOPE_EVENT_FIELDS); return ctx->scopes[scope - BT_CTF_SCOPE_TRACE_PACKET_HEADER]; @@ -402,7 +390,7 @@ int ptokens_to_field_path(GList *ptokens, struct bt_ctf_field_path *field_path, { int ret = 0; GList *cur_ptoken = ptokens; - bt_bool first_level_done = BT_FALSE; + bt_ctf_bool first_level_done = BT_CTF_FALSE; /* Get our own reference */ bt_ctf_object_get_ref(type); @@ -445,7 +433,7 @@ int ptokens_to_field_path(GList *ptokens, struct bt_ctf_field_path *field_path, /* Next path token */ cur_ptoken = g_list_next(cur_ptoken); - first_level_done = BT_TRUE; + first_level_done = BT_CTF_TRUE; } /* Create new field path entry */ @@ -558,7 +546,7 @@ int relative_ptokens_to_field_path(GList *ptokens, int tail_field_path_len = tail_field_path->indexes->len; - while (BT_TRUE) { + while (BT_CTF_TRUE) { struct bt_ctf_field_type_common *cur_type = type_stack_at(ctx->type_stack, i)->type; int index = type_stack_at( @@ -838,11 +826,11 @@ int get_field_paths_lca_index(struct bt_ctf_field_path *field_path1, /* * Start from both roots and find the first mismatch. */ - BT_ASSERT(field_path1->root == field_path2->root); + BT_ASSERT_DBG(field_path1->root == field_path2->root); field_path1_len = field_path1->indexes->len; field_path2_len = field_path2->indexes->len; - while (BT_TRUE) { + while (BT_CTF_TRUE) { int target_index, ctx_index; if (lca_index == field_path2_len || @@ -987,7 +975,7 @@ int validate_target_field_path(struct bt_ctf_field_path *target_field_path, } break; default: - abort(); + bt_common_abort(); } end: @@ -1024,7 +1012,7 @@ int resolve_sequence_or_variant_type(struct bt_ctf_field_type_common *type, bt_ctf_field_type_common_variant_get_tag_name(type); break; default: - abort(); + bt_common_abort(); } if (!pathstr) { @@ -1099,7 +1087,7 @@ int resolve_sequence_or_variant_type(struct bt_ctf_field_type_common *type, } break; default: - abort(); + bt_common_abort(); } end: @@ -1222,7 +1210,7 @@ int resolve_root_type(enum bt_ctf_scope root_scope, struct resolve_context *ctx) { int ret; - BT_ASSERT(type_stack_size(ctx->type_stack) == 0); + BT_ASSERT_DBG(type_stack_size(ctx->type_stack) == 0); ctx->root_scope = root_scope; ret = resolve_type(get_type_from_ctx(ctx, root_scope), ctx); ctx->root_scope = BT_CTF_SCOPE_UNKNOWN;