Cleanup: ctf: msg-iter.c: rename `ret` to `status`
[babeltrace.git] / src / plugins / ctf / common / msg-iter / msg-iter.c
index fff6cc305e24bba5aed106196809e8810d173bb0..f941970db67c3fdbc92866c8889d4a78979efdc5 100644 (file)
@@ -369,7 +369,7 @@ void stack_destroy(struct stack *stack)
 {
        struct bt_msg_iter *notit;
 
-       BT_ASSERT(stack);
+       BT_ASSERT_DBG(stack);
        notit = stack->notit;
        BT_COMP_LOGD("Destroying stack: addr=%p", stack);
 
@@ -386,9 +386,9 @@ void stack_push(struct stack *stack, bt_field *base)
        struct stack_entry *entry;
        struct bt_msg_iter *notit;
 
-       BT_ASSERT(stack);
+       BT_ASSERT_DBG(stack);
        notit = stack->notit;
-       BT_ASSERT(base);
+       BT_ASSERT_DBG(base);
        BT_COMP_LOGT("Pushing base field on stack: stack-addr=%p, "
                "stack-size-before=%zu, stack-size-after=%zu",
                stack, stack->size, stack->size + 1);
@@ -406,7 +406,7 @@ void stack_push(struct stack *stack, bt_field *base)
 static inline
 unsigned int stack_size(struct stack *stack)
 {
-       BT_ASSERT(stack);
+       BT_ASSERT_DBG(stack);
        return stack->size;
 }
 
@@ -415,8 +415,8 @@ void stack_pop(struct stack *stack)
 {
        struct bt_msg_iter *notit;
 
-       BT_ASSERT(stack);
-       BT_ASSERT(stack_size(stack));
+       BT_ASSERT_DBG(stack);
+       BT_ASSERT_DBG(stack_size(stack));
        notit = stack->notit;
        BT_COMP_LOGT("Popping from stack: "
                "stack-addr=%p, stack-size-before=%zu, stack-size-after=%zu",
@@ -427,8 +427,8 @@ void stack_pop(struct stack *stack)
 static inline
 struct stack_entry *stack_top(struct stack *stack)
 {
-       BT_ASSERT(stack);
-       BT_ASSERT(stack_size(stack));
+       BT_ASSERT_DBG(stack);
+       BT_ASSERT_DBG(stack_size(stack));
        return &g_array_index(stack->entries, struct stack_entry,
                stack->size - 1);
 }
@@ -442,7 +442,7 @@ bool stack_empty(struct stack *stack)
 static
 void stack_clear(struct stack *stack)
 {
-       BT_ASSERT(stack);
+       BT_ASSERT_DBG(stack);
        stack->size = 0;
 }
 
@@ -765,19 +765,19 @@ enum bt_msg_iter_status read_packet_header_begin_state(
                struct bt_msg_iter *notit)
 {
        struct ctf_field_class *packet_header_fc = NULL;
-       enum bt_msg_iter_status ret = BT_MSG_ITER_STATUS_OK;
+       enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK;
 
        /*
         * Make sure at least one bit is available for this packet. An
         * empty packet is impossible. If we reach the end of the medium
         * at this point, then it's considered the end of the stream.
         */
-       ret = buf_ensure_available_bits(notit);
-       switch (ret) {
+       status = buf_ensure_available_bits(notit);
+       switch (status) {
        case BT_MSG_ITER_STATUS_OK:
                break;
        case BT_MSG_ITER_STATUS_EOF:
-               ret = BT_MSG_ITER_STATUS_OK;
+               status = BT_MSG_ITER_STATUS_OK;
                notit->state = STATE_CHECK_EMIT_MSG_STREAM_END;
                goto end;
        default:
@@ -797,10 +797,10 @@ enum bt_msg_iter_status read_packet_header_begin_state(
        BT_COMP_LOGD("Decoding packet header field:"
                "notit-addr=%p, trace-class-addr=%p, fc-addr=%p",
                notit, notit->meta.tc, packet_header_fc);
-       ret = read_dscope_begin_state(notit, packet_header_fc,
+       status = read_dscope_begin_state(notit, packet_header_fc,
                STATE_AFTER_TRACE_PACKET_HEADER,
                STATE_DSCOPE_TRACE_PACKET_HEADER_CONTINUE, NULL);
-       if (ret < 0) {
+       if (status < 0) {
                BT_COMP_LOGW("Cannot decode packet header field: "
                        "notit-addr=%p, trace-class-addr=%p, "
                        "fc-addr=%p",
@@ -808,7 +808,7 @@ enum bt_msg_iter_status read_packet_header_begin_state(
        }
 
 end:
-       return ret;
+       return status;
 }
 
 static
@@ -924,8 +924,6 @@ enum bt_msg_iter_status set_current_packet(struct bt_msg_iter *notit)
        enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK;
        bt_packet *packet = NULL;
 
-       BT_COMP_LOGD("Creating packet for packet message: "
-               "notit-addr=%p", notit);
        BT_COMP_LOGD("Creating packet from stream: "
                "notit-addr=%p, stream-addr=%p, "
                "stream-class-addr=%p, "
@@ -1263,15 +1261,15 @@ enum bt_msg_iter_status set_current_event_message(
        enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK;
        bt_message *msg = NULL;
 
-       BT_ASSERT(notit->meta.ec);
-       BT_ASSERT(notit->packet);
+       BT_ASSERT_DBG(notit->meta.ec);
+       BT_ASSERT_DBG(notit->packet);
        BT_COMP_LOGD("Creating event message from event class and packet: "
                "notit-addr=%p, ec-addr=%p, ec-name=\"%s\", packet-addr=%p",
                notit, notit->meta.ec,
                notit->meta.ec->name->str,
                notit->packet);
-       BT_ASSERT(notit->msg_iter);
-       BT_ASSERT(notit->meta.sc);
+       BT_ASSERT_DBG(notit->msg_iter);
+       BT_ASSERT_DBG(notit->meta.sc);
 
        if (bt_stream_class_borrow_default_clock_class(notit->meta.sc->ir_sc)) {
                msg = bt_message_event_create_with_packet_and_default_clock_snapshot(
@@ -1325,7 +1323,7 @@ enum bt_msg_iter_status after_event_header_state(
 
        notit->event = bt_message_event_borrow_event(
                notit->event_msg);
-       BT_ASSERT(notit->event);
+       BT_ASSERT_DBG(notit->event);
 
 next_state:
        notit->state = STATE_DSCOPE_EVENT_COMMON_CONTEXT_BEGIN;
@@ -1348,11 +1346,11 @@ enum bt_msg_iter_status read_event_common_context_begin_state(
        }
 
        if (event_common_context_fc->in_ir && !notit->dry_run) {
-               BT_ASSERT(!notit->dscopes.event_common_context);
+               BT_ASSERT_DBG(!notit->dscopes.event_common_context);
                notit->dscopes.event_common_context =
                        bt_event_borrow_common_context_field(
                                notit->event);
-               BT_ASSERT(notit->dscopes.event_common_context);
+               BT_ASSERT_DBG(notit->dscopes.event_common_context);
        }
 
        BT_COMP_LOGT("Decoding event common context field: "
@@ -1401,11 +1399,11 @@ enum bt_msg_iter_status read_event_spec_context_begin_state(
        }
 
        if (event_spec_context_fc->in_ir && !notit->dry_run) {
-               BT_ASSERT(!notit->dscopes.event_spec_context);
+               BT_ASSERT_DBG(!notit->dscopes.event_spec_context);
                notit->dscopes.event_spec_context =
                        bt_event_borrow_specific_context_field(
                                notit->event);
-               BT_ASSERT(notit->dscopes.event_spec_context);
+               BT_ASSERT_DBG(notit->dscopes.event_spec_context);
        }
 
        BT_COMP_LOGT("Decoding event specific context field: "
@@ -1457,11 +1455,11 @@ enum bt_msg_iter_status read_event_payload_begin_state(
        }
 
        if (event_payload_fc->in_ir && !notit->dry_run) {
-               BT_ASSERT(!notit->dscopes.event_payload);
+               BT_ASSERT_DBG(!notit->dscopes.event_payload);
                notit->dscopes.event_payload =
                        bt_event_borrow_payload_field(
                                notit->event);
-               BT_ASSERT(notit->dscopes.event_payload);
+               BT_ASSERT_DBG(notit->dscopes.event_payload);
        }
 
        BT_COMP_LOGT("Decoding event payload field: "
@@ -1838,16 +1836,16 @@ bt_field *borrow_next_field(struct bt_msg_iter *notit)
        bt_field_class_type base_fc_type;
        size_t index;
 
-       BT_ASSERT(!stack_empty(notit->stack));
+       BT_ASSERT_DBG(!stack_empty(notit->stack));
        index = stack_top(notit->stack)->index;
        base_field = stack_top(notit->stack)->base;
-       BT_ASSERT(base_field);
+       BT_ASSERT_DBG(base_field);
        base_fc = bt_field_borrow_class_const(base_field);
-       BT_ASSERT(base_fc);
+       BT_ASSERT_DBG(base_fc);
        base_fc_type = bt_field_class_get_type(base_fc);
 
        if (base_fc_type == BT_FIELD_CLASS_TYPE_STRUCTURE) {
-               BT_ASSERT(index <
+               BT_ASSERT_DBG(index <
                        bt_field_class_structure_get_member_count(
                                bt_field_borrow_class_const(
                                                base_field)));
@@ -1856,19 +1854,19 @@ bt_field *borrow_next_field(struct bt_msg_iter *notit)
                                base_field, index);
        } else if (bt_field_class_type_is(base_fc_type,
                        BT_FIELD_CLASS_TYPE_ARRAY)) {
-               BT_ASSERT(index < bt_field_array_get_length(base_field));
+               BT_ASSERT_DBG(index < bt_field_array_get_length(base_field));
                next_field = bt_field_array_borrow_element_field_by_index(
                        base_field, index);
        } else if (bt_field_class_type_is(base_fc_type,
                        BT_FIELD_CLASS_TYPE_VARIANT)) {
-               BT_ASSERT(index == 0);
+               BT_ASSERT_DBG(index == 0);
                next_field = bt_field_variant_borrow_selected_option_field(
                        base_field);
        } else {
                abort();
        }
 
-       BT_ASSERT(next_field);
+       BT_ASSERT_DBG(next_field);
        return next_field;
 }
 
@@ -1879,7 +1877,7 @@ void update_default_clock(struct bt_msg_iter *notit, uint64_t new_val,
        uint64_t new_val_mask;
        uint64_t cur_value_masked;
 
-       BT_ASSERT(new_val_size > 0);
+       BT_ASSERT_DBG(new_val_size > 0);
 
        /*
         * Special case for a 64-bit new value, which is the limit
@@ -1988,9 +1986,9 @@ update_def_clock:
        }
 
        field = borrow_next_field(notit);
-       BT_ASSERT(field);
-       BT_ASSERT(bt_field_borrow_class_const(field) == fc->ir_fc);
-       BT_ASSERT(bt_field_class_type_is(bt_field_get_class_type(field),
+       BT_ASSERT_DBG(field);
+       BT_ASSERT_DBG(bt_field_borrow_class_const(field) == fc->ir_fc);
+       BT_ASSERT_DBG(bt_field_class_type_is(bt_field_get_class_type(field),
                BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER));
        bt_field_integer_unsigned_set_value(field, value);
        stack_top(notit->stack)->index++;
@@ -2014,9 +2012,9 @@ enum bt_bfcr_status bfcr_unsigned_int_char_cb(uint64_t value,
                "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
                "fc-type=%d, fc-in-ir=%d, value=%" PRIu64,
                notit, notit->bfcr, fc, fc->type, fc->in_ir, value);
-       BT_ASSERT(int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE);
-       BT_ASSERT(!int_fc->mapped_clock_class);
-       BT_ASSERT(int_fc->storing_index < 0);
+       BT_ASSERT_DBG(int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE);
+       BT_ASSERT_DBG(!int_fc->mapped_clock_class);
+       BT_ASSERT_DBG(int_fc->storing_index < 0);
 
        if (G_UNLIKELY(!fc->in_ir || notit->dry_run)) {
                goto end;
@@ -2032,7 +2030,7 @@ enum bt_bfcr_status bfcr_unsigned_int_char_cb(uint64_t value,
        }
 
        string_field = stack_top(notit->stack)->base;
-       BT_ASSERT(bt_field_get_class_type(string_field) ==
+       BT_ASSERT_DBG(bt_field_get_class_type(string_field) ==
                BT_FIELD_CLASS_TYPE_STRING);
 
        /* Append character */
@@ -2063,7 +2061,7 @@ enum bt_bfcr_status bfcr_signed_int_cb(int64_t value,
                "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
                "fc-type=%d, fc-in-ir=%d, value=%" PRId64,
                notit, notit->bfcr, fc, fc->type, fc->in_ir, value);
-       BT_ASSERT(int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE);
+       BT_ASSERT_DBG(int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE);
 
        if (G_UNLIKELY(int_fc->storing_index >= 0)) {
                g_array_index(notit->stored_values, uint64_t,
@@ -2075,9 +2073,9 @@ enum bt_bfcr_status bfcr_signed_int_cb(int64_t value,
        }
 
        field = borrow_next_field(notit);
-       BT_ASSERT(field);
-       BT_ASSERT(bt_field_borrow_class_const(field) == fc->ir_fc);
-       BT_ASSERT(bt_field_class_type_is(bt_field_get_class_type(field),
+       BT_ASSERT_DBG(field);
+       BT_ASSERT_DBG(bt_field_borrow_class_const(field) == fc->ir_fc);
+       BT_ASSERT_DBG(bt_field_class_type_is(bt_field_get_class_type(field),
                BT_FIELD_CLASS_TYPE_SIGNED_INTEGER));
        bt_field_integer_signed_set_value(field, value);
        stack_top(notit->stack)->index++;
@@ -2093,6 +2091,7 @@ enum bt_bfcr_status bfcr_floating_point_cb(double value,
        enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
        bt_field *field = NULL;
        struct bt_msg_iter *notit = data;
+       bt_field_class_type type;
 
        BT_COMP_LOGT("Floating point number function called from BFCR: "
                "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
@@ -2104,10 +2103,10 @@ enum bt_bfcr_status bfcr_floating_point_cb(double value,
        }
 
        field = borrow_next_field(notit);
-       bt_field_class_type type = bt_field_get_class_type(field);
-       BT_ASSERT(field);
-       BT_ASSERT(bt_field_borrow_class_const(field) == fc->ir_fc);
-       BT_ASSERT(bt_field_class_type_is(type, BT_FIELD_CLASS_TYPE_REAL));
+       type = bt_field_get_class_type(field);
+       BT_ASSERT_DBG(field);
+       BT_ASSERT_DBG(bt_field_borrow_class_const(field) == fc->ir_fc);
+       BT_ASSERT_DBG(bt_field_class_type_is(type, BT_FIELD_CLASS_TYPE_REAL));
 
        if (type == BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL) {
                bt_field_real_single_precision_set_value(field, (float) value);
@@ -2137,9 +2136,9 @@ enum bt_bfcr_status bfcr_string_begin_cb(
        }
 
        field = borrow_next_field(notit);
-       BT_ASSERT(field);
-       BT_ASSERT(bt_field_borrow_class_const(field) == fc->ir_fc);
-       BT_ASSERT(bt_field_get_class_type(field) ==
+       BT_ASSERT_DBG(field);
+       BT_ASSERT_DBG(bt_field_borrow_class_const(field) == fc->ir_fc);
+       BT_ASSERT_DBG(bt_field_get_class_type(field) ==
                  BT_FIELD_CLASS_TYPE_STRING);
        bt_field_string_clear(field);
 
@@ -2174,7 +2173,7 @@ enum bt_bfcr_status bfcr_string_cb(const char *value,
        }
 
        field = stack_top(notit->stack)->base;
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
 
        /* Append current substring */
        ret = bt_field_string_append_with_length(field, value, len);
@@ -2215,6 +2214,7 @@ end:
        return BT_BFCR_STATUS_OK;
 }
 
+static
 enum bt_bfcr_status bfcr_compound_begin_cb(
                struct ctf_field_class *fc, void *data)
 {
@@ -2236,12 +2236,12 @@ enum bt_bfcr_status bfcr_compound_begin_cb(
                field = notit->cur_dscope_field;
        } else {
                field = borrow_next_field(notit);
-               BT_ASSERT(field);
+               BT_ASSERT_DBG(field);
        }
 
        /* Push field */
-       BT_ASSERT(field);
-       BT_ASSERT(bt_field_borrow_class_const(field) == fc->ir_fc);
+       BT_ASSERT_DBG(field);
+       BT_ASSERT_DBG(bt_field_borrow_class_const(field) == fc->ir_fc);
        stack_push(notit->stack, field);
 
        /*
@@ -2253,7 +2253,7 @@ enum bt_bfcr_status bfcr_compound_begin_cb(
                struct ctf_field_class_array_base *array_fc = (void *) fc;
 
                if (array_fc->is_text) {
-                       BT_ASSERT(bt_field_get_class_type(field) ==
+                       BT_ASSERT_DBG(bt_field_get_class_type(field) ==
                                  BT_FIELD_CLASS_TYPE_STRING);
                        notit->done_filling_string = false;
                        bt_field_string_clear(field);
@@ -2266,6 +2266,7 @@ end:
        return BT_BFCR_STATUS_OK;
 }
 
+static
 enum bt_bfcr_status bfcr_compound_end_cb(
                struct ctf_field_class *fc, void *data)
 {
@@ -2280,8 +2281,8 @@ enum bt_bfcr_status bfcr_compound_end_cb(
                goto end;
        }
 
-       BT_ASSERT(!stack_empty(notit->stack));
-       BT_ASSERT(bt_field_borrow_class_const(stack_top(notit->stack)->base) ==
+       BT_ASSERT_DBG(!stack_empty(notit->stack));
+       BT_ASSERT_DBG(bt_field_borrow_class_const(stack_top(notit->stack)->base) ==
                fc->ir_fc);
 
        /*
@@ -2293,7 +2294,7 @@ enum bt_bfcr_status bfcr_compound_end_cb(
                struct ctf_field_class_array_base *array_fc = (void *) fc;
 
                if (array_fc->is_text) {
-                       BT_ASSERT(bt_field_get_class_type(
+                       BT_ASSERT_DBG(bt_field_get_class_type(
                                stack_top(notit->stack)->base) ==
                                BT_FIELD_CLASS_TYPE_STRING);
                        bt_bfcr_set_unsigned_int_cb(notit->bfcr,
@@ -2330,7 +2331,7 @@ int64_t bfcr_get_sequence_length_cb(struct ctf_field_class *fc, void *data)
        }
 
        seq_field = stack_top(notit->stack)->base;
-       BT_ASSERT(seq_field);
+       BT_ASSERT_DBG(seq_field);
 
        /*
         * bfcr_get_sequence_length_cb() also gets called back for a
@@ -2339,7 +2340,7 @@ int64_t bfcr_get_sequence_length_cb(struct ctf_field_class *fc, void *data)
         * is a sequence field.
         */
        if (!seq_fc->base.is_text) {
-               BT_ASSERT(bt_field_class_type_is(
+               BT_ASSERT_DBG(bt_field_class_type_is(
                        bt_field_get_class_type(seq_field),
                                BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY));
                ret = bt_field_array_dynamic_set_length(seq_field,
@@ -2435,55 +2436,54 @@ end:
 }
 
 static
-void create_msg_stream_beginning(struct bt_msg_iter *notit,
-               bt_message **message)
+bt_message *create_msg_stream_beginning(struct bt_msg_iter *notit)
 {
-       bt_message *ret = NULL;
+       bt_message *msg;
 
        BT_ASSERT(notit->stream);
        BT_ASSERT(notit->msg_iter);
-       ret = bt_message_stream_beginning_create(notit->msg_iter,
+       msg = bt_message_stream_beginning_create(notit->msg_iter,
                notit->stream);
-       if (!ret) {
+       if (!msg) {
                BT_COMP_LOGE("Cannot create stream beginning message: "
                        "notit-addr=%p, stream-addr=%p",
                        notit, notit->stream);
-               return;
        }
 
-       *message = ret;
+       return msg;
 }
 
 static
-void create_msg_stream_end(struct bt_msg_iter *notit, bt_message **message)
+bt_message *create_msg_stream_end(struct bt_msg_iter *notit)
 {
-       bt_message *ret;
+       bt_message *msg;
 
        if (!notit->stream) {
                BT_COMP_LOGE("Cannot create stream for stream message: "
                        "notit-addr=%p", notit);
-               return;
+               msg = NULL;
+               goto end;
        }
 
        BT_ASSERT(notit->msg_iter);
-       ret = bt_message_stream_end_create(notit->msg_iter,
+       msg = bt_message_stream_end_create(notit->msg_iter,
                notit->stream);
-       if (!ret) {
+       if (!msg) {
                BT_COMP_LOGE("Cannot create stream end message: "
                        "notit-addr=%p, stream-addr=%p",
                        notit, notit->stream);
-               return;
        }
 
-       *message = ret;
+end:
+       return msg;
 }
 
 static
-void create_msg_packet_beginning(struct bt_msg_iter *notit,
-               bt_message **message, bool use_default_cs)
+bt_message *create_msg_packet_beginning(struct bt_msg_iter *notit,
+               bool use_default_cs)
 {
        int ret;
-       bt_message *msg = NULL;
+       bt_message *msg;
        const bt_stream_class *sc = notit->meta.sc->ir_sc;
 
        BT_ASSERT(notit->packet);
@@ -2493,6 +2493,7 @@ void create_msg_packet_beginning(struct bt_msg_iter *notit,
                ret = bt_packet_move_context_field(
                        notit->packet, notit->packet_context_field);
                if (ret) {
+                       msg = NULL;
                        goto end;
                }
 
@@ -2539,15 +2540,12 @@ void create_msg_packet_beginning(struct bt_msg_iter *notit,
                goto end;
        }
 
-       *message = msg;
-
 end:
-       return;
+       return msg;
 }
 
 static
-void emit_delayed_packet_beg_msg(struct bt_msg_iter *notit,
-               bt_message **message)
+bt_message *emit_delayed_packet_beg_msg(struct bt_msg_iter *notit)
 {
        bool packet_beg_ts_need_fix_up;
 
@@ -2563,20 +2561,19 @@ void emit_delayed_packet_beg_msg(struct bt_msg_iter *notit,
                notit->default_clock_snapshot < notit->snapshots.beginning_clock;
 
        /* create_msg_packet_beginning() logs errors */
-       create_msg_packet_beginning(notit, message, packet_beg_ts_need_fix_up);
-
-       return;
+       return create_msg_packet_beginning(notit, packet_beg_ts_need_fix_up);
 }
 
 
 static
-void create_msg_packet_end(struct bt_msg_iter *notit, bt_message **message)
+bt_message *create_msg_packet_end(struct bt_msg_iter *notit)
 {
        bt_message *msg;
        bool update_default_cs = true;
 
        if (!notit->packet) {
-               return;
+               msg = NULL;
+               goto end;
        }
 
        /*
@@ -2584,10 +2581,10 @@ void create_msg_packet_end(struct bt_msg_iter *notit, bt_message **message)
         * beginning message instead of the packet end message.
         */
        if (G_UNLIKELY(notit->emit_delayed_packet_beginning_msg)) {
-               emit_delayed_packet_beg_msg(notit, message);
+               msg = emit_delayed_packet_beg_msg(notit);
                /* Don't forget to emit the packet end message. */
                notit->state = STATE_EMIT_QUEUED_MSG_PACKET_END;
-               return;
+               goto end;
        }
 
        /* Check if may be affected by lttng-crash timestamp_end quirk. */
@@ -2644,17 +2641,18 @@ void create_msg_packet_end(struct bt_msg_iter *notit, bt_message **message)
                BT_COMP_LOGE("Cannot create packet end message: "
                        "notit-addr=%p, packet-addr=%p",
                        notit, notit->packet);
-               return;
+               goto end;
 
        }
 
        BT_PACKET_PUT_REF_AND_RESET(notit->packet);
-       *message = msg;
+
+end:
+       return msg;
 }
 
 static
-void create_msg_discarded_events(struct bt_msg_iter *notit,
-               bt_message **message)
+bt_message *create_msg_discarded_events(struct bt_msg_iter *notit)
 {
        bt_message *msg;
        uint64_t beginning_raw_value = UINT64_C(-1);
@@ -2692,7 +2690,7 @@ void create_msg_discarded_events(struct bt_msg_iter *notit,
                BT_COMP_LOGE("Cannot create discarded events message: "
                        "notit-addr=%p, stream-addr=%p",
                        notit, notit->stream);
-               return;
+               goto end;
        }
 
        if (notit->prev_packet_snapshots.discarded_events != UINT64_C(-1)) {
@@ -2701,12 +2699,12 @@ void create_msg_discarded_events(struct bt_msg_iter *notit,
                        notit->prev_packet_snapshots.discarded_events);
        }
 
-       *message = msg;
+end:
+       return msg;
 }
 
 static
-void create_msg_discarded_packets(struct bt_msg_iter *notit,
-               bt_message **message)
+bt_message *create_msg_discarded_packets(struct bt_msg_iter *notit)
 {
        bt_message *msg;
 
@@ -2732,13 +2730,15 @@ void create_msg_discarded_packets(struct bt_msg_iter *notit,
                BT_COMP_LOGE("Cannot create discarded packets message: "
                        "notit-addr=%p, stream-addr=%p",
                        notit, notit->stream);
-               return;
+               goto end;
        }
 
        bt_message_discarded_packets_set_count(msg,
                notit->snapshots.packets -
                        notit->prev_packet_snapshots.packets - 1);
-       *message = msg;
+
+end:
+       return msg;
 }
 
 BT_HIDDEN
@@ -2848,8 +2848,8 @@ enum bt_msg_iter_status bt_msg_iter_get_next_message(
 {
        enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK;
 
-       BT_ASSERT(notit);
-       BT_ASSERT(message);
+       BT_ASSERT_DBG(notit);
+       BT_ASSERT_DBG(message);
        notit->msg_iter = msg_iter;
        notit->set_stream = true;
        BT_COMP_LOGD("Getting next message: notit-addr=%p", notit);
@@ -2867,14 +2867,14 @@ enum bt_msg_iter_status bt_msg_iter_get_next_message(
 
                switch (notit->state) {
                case STATE_EMIT_MSG_EVENT:
-                       BT_ASSERT(notit->event_msg);
+                       BT_ASSERT_DBG(notit->event_msg);
 
                        /*
                         * Check if we need to emit the delayed packet
                         * beginning message instead of the event message.
                         */
                        if (G_UNLIKELY(notit->emit_delayed_packet_beginning_msg)) {
-                               emit_delayed_packet_beg_msg(notit, message);
+                               *message = emit_delayed_packet_beg_msg(notit);
                                if (!*message) {
                                        status = BT_MSG_ITER_STATUS_ERROR;
                                }
@@ -2892,7 +2892,7 @@ enum bt_msg_iter_status bt_msg_iter_get_next_message(
                        goto end;
                case STATE_EMIT_MSG_DISCARDED_EVENTS:
                        /* create_msg_discared_events() logs errors */
-                       create_msg_discarded_events(notit, message);
+                       *message = create_msg_discarded_events(notit);
 
                        if (!*message) {
                                status = BT_MSG_ITER_STATUS_ERROR;
@@ -2901,7 +2901,7 @@ enum bt_msg_iter_status bt_msg_iter_get_next_message(
                        goto end;
                case STATE_EMIT_MSG_DISCARDED_PACKETS:
                        /* create_msg_discared_packets() logs errors */
-                       create_msg_discarded_packets(notit, message);
+                       *message = create_msg_discarded_packets(notit);
 
                        if (!*message) {
                                status = BT_MSG_ITER_STATUS_ERROR;
@@ -2925,7 +2925,7 @@ enum bt_msg_iter_status bt_msg_iter_get_next_message(
                                break;
                        } else {
                                /* create_msg_packet_beginning() logs errors */
-                               create_msg_packet_beginning(notit, message, false);
+                               *message = create_msg_packet_beginning(notit, false);
                                if (!*message) {
                                        status = BT_MSG_ITER_STATUS_ERROR;
                                }
@@ -2935,7 +2935,7 @@ enum bt_msg_iter_status bt_msg_iter_get_next_message(
                case STATE_EMIT_MSG_PACKET_END_SINGLE:
                case STATE_EMIT_MSG_PACKET_END_MULTI:
                        /* create_msg_packet_end() logs errors */
-                       create_msg_packet_end(notit, message);
+                       *message = create_msg_packet_end(notit);
 
                        if (!*message) {
                                status = BT_MSG_ITER_STATUS_ERROR;
@@ -2944,7 +2944,7 @@ enum bt_msg_iter_status bt_msg_iter_get_next_message(
                        goto end;
                case STATE_EMIT_MSG_STREAM_BEGINNING:
                        /* create_msg_stream_beginning() logs errors */
-                       create_msg_stream_beginning(notit, message);
+                       *message = create_msg_stream_beginning(notit);
 
                        if (!*message) {
                                status = BT_MSG_ITER_STATUS_ERROR;
@@ -2953,7 +2953,7 @@ enum bt_msg_iter_status bt_msg_iter_get_next_message(
                        goto end;
                case STATE_EMIT_MSG_STREAM_END:
                        /* create_msg_stream_end() logs errors */
-                       create_msg_stream_end(notit, message);
+                       *message = create_msg_stream_end(notit);
 
                        if (!*message) {
                                status = BT_MSG_ITER_STATUS_ERROR;
@@ -2979,7 +2979,7 @@ enum bt_msg_iter_status decode_until_state( struct bt_msg_iter *notit,
 {
        enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK;
 
-       BT_ASSERT(notit);
+       BT_ASSERT_DBG(notit);
        notit->set_stream = false;
 
        do {
@@ -3084,18 +3084,18 @@ BT_HIDDEN
 enum bt_msg_iter_status bt_msg_iter_seek(struct bt_msg_iter *notit,
                off_t offset)
 {
-       enum bt_msg_iter_status ret = BT_MSG_ITER_STATUS_OK;
+       enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK;
        enum bt_msg_iter_medium_status medium_status;
 
        BT_ASSERT(notit);
        if (offset < 0) {
                BT_COMP_LOGE("Cannot seek to negative offset: offset=%jd", (intmax_t) offset);
-               ret = BT_MSG_ITER_STATUS_INVAL;
+               status = BT_MSG_ITER_STATUS_INVAL;
                goto end;
        }
 
        if (!notit->medium.medops.seek) {
-               ret = BT_MSG_ITER_STATUS_UNSUPPORTED;
+               status = BT_MSG_ITER_STATUS_UNSUPPORTED;
                BT_COMP_LOGD("Aborting seek as the iterator's underlying media does not implement seek support.");
                goto end;
        }
@@ -3104,9 +3104,9 @@ enum bt_msg_iter_status bt_msg_iter_seek(struct bt_msg_iter *notit,
                BT_MSG_ITER_SEEK_WHENCE_SET, offset, notit->medium.data);
        if (medium_status != BT_MSG_ITER_MEDIUM_STATUS_OK) {
                if (medium_status == BT_MSG_ITER_MEDIUM_STATUS_EOF) {
-                       ret = BT_MSG_ITER_STATUS_EOF;
+                       status = BT_MSG_ITER_STATUS_EOF;
                } else {
-                       ret = BT_MSG_ITER_STATUS_ERROR;
+                       status = BT_MSG_ITER_STATUS_ERROR;
                        goto end;
                }
        }
@@ -3115,7 +3115,7 @@ enum bt_msg_iter_status bt_msg_iter_seek(struct bt_msg_iter *notit,
        notit->cur_packet_offset = offset;
 
 end:
-       return ret;
+       return status;
 }
 
 static
@@ -3125,8 +3125,8 @@ enum bt_msg_iter_status clock_snapshot_at_msg_iter_state(
 {
        enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK;
 
-       BT_ASSERT(notit);
-       BT_ASSERT(clock_snapshot);
+       BT_ASSERT_DBG(notit);
+       BT_ASSERT_DBG(clock_snapshot);
        status = decode_until_state(notit, target_state_1, target_state_2);
        if (status != BT_MSG_ITER_STATUS_OK) {
                goto end;
@@ -3161,8 +3161,8 @@ enum bt_msg_iter_status bt_msg_iter_get_packet_properties(
 {
        enum bt_msg_iter_status status;
 
-       BT_ASSERT(notit);
-       BT_ASSERT(props);
+       BT_ASSERT_DBG(notit);
+       BT_ASSERT_DBG(props);
        status = read_packet_header_context_fields(notit);
        if (status != BT_MSG_ITER_STATUS_OK) {
                goto end;
This page took 0.039941 seconds and 4 git commands to generate.