Add bt_common_abort() and use it instead of abort() directly
[babeltrace.git] / src / plugins / ctf / common / bfcr / bfcr.c
index fc9b6699797f3e9719b8c4cfd64ceaa85d74d7c3..a95079e154d5dbf15bb3e7db27a8b6eab222e6e3 100644 (file)
@@ -116,8 +116,8 @@ struct bt_bfcr {
         * classes for which the common boundary is not the boundary of
         * a byte cannot have different byte orders.
         *
-        * This is set to -1 on reset and when the last basic field class
-        * was a string class.
+        * This is set to CTF_BYTE_ORDER_UNKNOWN on reset and when the last
+        * basic field class was a string class.
         */
        enum ctf_byte_order last_bo;
 
@@ -240,8 +240,8 @@ int stack_push(struct stack *stack, struct ctf_field_class *base_class,
        struct stack_entry *entry;
        struct bt_bfcr *bfcr;
 
-       BT_ASSERT(stack);
-       BT_ASSERT(base_class);
+       BT_ASSERT_DBG(stack);
+       BT_ASSERT_DBG(base_class);
        bfcr = stack->bfcr;
        BT_COMP_LOGT("Pushing field class on stack: stack-addr=%p, "
                "fc-addr=%p, fc-type=%d, base-length=%zu, "
@@ -293,7 +293,7 @@ int64_t get_compound_field_class_length(struct bt_bfcr *bfcr,
                        bfcr->user.data);
                break;
        default:
-               abort();
+               bt_common_abort();
        }
 
        return length;
@@ -322,7 +322,7 @@ end:
 static inline
 unsigned int stack_size(struct stack *stack)
 {
-       BT_ASSERT(stack);
+       BT_ASSERT_DBG(stack);
        return stack->size;
 }
 
@@ -331,8 +331,8 @@ void stack_pop(struct stack *stack)
 {
        struct bt_bfcr *bfcr;
 
-       BT_ASSERT(stack);
-       BT_ASSERT(stack_size(stack));
+       BT_ASSERT_DBG(stack);
+       BT_ASSERT_DBG(stack_size(stack));
        bfcr = stack->bfcr;
        BT_COMP_LOGT("Popping from stack: "
                "stack-addr=%p, stack-size-before=%u, stack-size-after=%u",
@@ -349,15 +349,15 @@ bool stack_empty(struct stack *stack)
 static
 void stack_clear(struct stack *stack)
 {
-       BT_ASSERT(stack);
+       BT_ASSERT_DBG(stack);
        stack->size = 0;
 }
 
 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);
 }
@@ -476,7 +476,7 @@ void read_unsigned_bitfield(struct bt_bfcr *bfcr, const uint8_t *buf, size_t at,
                bt_bitfield_read_le(buf, uint8_t, at, field_size, v);
                break;
        default:
-               abort();
+               bt_common_abort();
        }
 
        BT_COMP_LOGT("Read unsigned bit array: cur=%zu, size=%u, "
@@ -495,7 +495,7 @@ void read_signed_bitfield(struct bt_bfcr *bfcr, const uint8_t *buf, size_t at,
                bt_bitfield_read_le(buf, uint8_t, at, field_size, v);
                break;
        default:
-               abort();
+               bt_common_abort();
        }
 
        BT_COMP_LOGT("Read signed bit array: cur=%zu, size=%u, "
@@ -517,12 +517,12 @@ enum bt_bfcr_status validate_contiguous_bo(struct bt_bfcr *bfcr,
        }
 
        /* Always valid if last byte order is unknown */
-       if (bfcr->last_bo == -1) {
+       if (bfcr->last_bo == CTF_BYTE_ORDER_UNKNOWN) {
                goto end;
        }
 
        /* Always valid if next byte order is unknown */
-       if (next_bo == -1) {
+       if (next_bo == CTF_BYTE_ORDER_UNKNOWN) {
                goto end;
        }
 
@@ -562,7 +562,7 @@ enum bt_bfcr_status read_basic_float_and_call_cb(struct bt_bfcr *bfcr,
        enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
        struct ctf_field_class_float *fc = (void *) bfcr->cur_basic_field_class;
 
-       BT_ASSERT(fc);
+       BT_ASSERT_DBG(fc);
        field_size = fc->base.size;
        bo = fc->base.byte_order;
        bfcr->cur_bo = bo;
@@ -594,7 +594,7 @@ enum bt_bfcr_status read_basic_float_and_call_cb(struct bt_bfcr *bfcr,
        }
        default:
                /* Only 32-bit and 64-bit fields are supported currently */
-               abort();
+               bt_common_abort();
        }
 
        BT_COMP_LOGT("Read floating point number value: bfcr=%p, cur=%zu, val=%f",
@@ -754,7 +754,7 @@ enum bt_bfcr_status read_bit_array_class_and_call_begin(struct bt_bfcr *bfcr,
 
        if (fc->size <= available) {
                /* We have all the bits; decode and set now */
-               BT_ASSERT(bfcr->buf.addr);
+               BT_ASSERT_DBG(bfcr->buf.addr);
                status = read_basic_and_call_cb(bfcr, bfcr->buf.addr,
                        buf_at_from_addr(bfcr));
                if (status != BT_BFCR_STATUS_OK) {
@@ -837,10 +837,10 @@ enum bt_bfcr_status read_basic_string_class_and_call(
                goto end;
        }
 
-       BT_ASSERT(buf_at_from_addr(bfcr) % 8 == 0);
+       BT_ASSERT_DBG(buf_at_from_addr(bfcr) % 8 == 0);
        available_bytes = BITS_TO_BYTES_FLOOR(available_bits(bfcr));
        buf_at_bytes = BITS_TO_BYTES_FLOOR(buf_at_from_addr(bfcr));
-       BT_ASSERT(bfcr->buf.addr);
+       BT_ASSERT_DBG(bfcr->buf.addr);
        first_chr = &bfcr->buf.addr[buf_at_bytes];
        result = memchr(first_chr, '\0', available_bytes);
 
@@ -934,7 +934,7 @@ enum bt_bfcr_status read_basic_begin_state(struct bt_bfcr *bfcr)
 {
        enum bt_bfcr_status status;
 
-       BT_ASSERT(bfcr->cur_basic_field_class);
+       BT_ASSERT_DBG(bfcr->cur_basic_field_class);
 
        switch (bfcr->cur_basic_field_class->type) {
        case CTF_FIELD_CLASS_TYPE_INT:
@@ -948,7 +948,7 @@ enum bt_bfcr_status read_basic_begin_state(struct bt_bfcr *bfcr)
                status = read_basic_string_class_and_call(bfcr, true);
                break;
        default:
-               abort();
+               bt_common_abort();
        }
 
        return status;
@@ -959,7 +959,7 @@ enum bt_bfcr_status read_basic_continue_state(struct bt_bfcr *bfcr)
 {
        enum bt_bfcr_status status;
 
-       BT_ASSERT(bfcr->cur_basic_field_class);
+       BT_ASSERT_DBG(bfcr->cur_basic_field_class);
 
        switch (bfcr->cur_basic_field_class->type) {
        case CTF_FIELD_CLASS_TYPE_INT:
@@ -973,7 +973,7 @@ enum bt_bfcr_status read_basic_continue_state(struct bt_bfcr *bfcr)
                status = read_basic_string_class_and_call(bfcr, false);
                break;
        default:
-               abort();
+               bt_common_abort();
        }
 
        return status;
@@ -1003,7 +1003,7 @@ enum bt_bfcr_status align_class_state(struct bt_bfcr *bfcr,
         * 0 means "undefined" for variants; what we really want is 1
         * (always aligned)
         */
-       BT_ASSERT(field_alignment >= 1);
+       BT_ASSERT_DBG(field_alignment >= 1);
 
        /* Compute how many bits we need to skip */
        skip_bits = bits_to_skip_to_align_to(bfcr, (size_t) field_alignment);
@@ -1241,7 +1241,7 @@ void reset(struct bt_bfcr *bfcr)
        stack_clear(bfcr->stack);
        stitch_reset(bfcr);
        bfcr->buf.addr = NULL;
-       bfcr->last_bo = -1;
+       bfcr->last_bo = CTF_BYTE_ORDER_UNKNOWN;
 }
 
 static
@@ -1260,8 +1260,8 @@ size_t bt_bfcr_start(struct bt_bfcr *bfcr,
        size_t offset, size_t packet_offset, size_t sz,
        enum bt_bfcr_status *status)
 {
-       BT_ASSERT(bfcr);
-       BT_ASSERT(BYTES_TO_BITS(sz) >= offset);
+       BT_ASSERT_DBG(bfcr);
+       BT_ASSERT_DBG(BYTES_TO_BITS(sz) >= offset);
        reset(bfcr);
        bfcr->buf.addr = buf;
        bfcr->buf.offset = offset;
@@ -1330,9 +1330,9 @@ BT_HIDDEN
 size_t bt_bfcr_continue(struct bt_bfcr *bfcr, const uint8_t *buf, size_t sz,
                enum bt_bfcr_status *status)
 {
-       BT_ASSERT(bfcr);
-       BT_ASSERT(buf);
-       BT_ASSERT(sz > 0);
+       BT_ASSERT_DBG(bfcr);
+       BT_ASSERT_DBG(buf);
+       BT_ASSERT_DBG(sz > 0);
        bfcr->buf.addr = buf;
        bfcr->buf.offset = 0;
        bfcr->buf.at = 0;
@@ -1363,7 +1363,7 @@ BT_HIDDEN
 void bt_bfcr_set_unsigned_int_cb(struct bt_bfcr *bfcr,
                bt_bfcr_unsigned_int_cb_func cb)
 {
-       BT_ASSERT(bfcr);
-       BT_ASSERT(cb);
+       BT_ASSERT_DBG(bfcr);
+       BT_ASSERT_DBG(cb);
        bfcr->user.cbs.classes.unsigned_int = cb;
 }
This page took 0.026783 seconds and 4 git commands to generate.