Fix type-limits warnings, uint can't be < 0
[babeltrace.git] / plugins / ctf / common / msg-iter / msg-iter.c
index 7077d2e7360cb4739a3129508bd06aae49dd0ac6..22ebc55f090e80bd1cbb3290fadc24f276a5f4e0 100644 (file)
@@ -969,14 +969,8 @@ enum bt_msg_iter_status set_current_packet_content_sizes(
 
        if (notit->cur_exp_packet_total_size == -1) {
                if (notit->cur_exp_packet_content_size != -1) {
-                       BT_LOGW("Content size is set, but packet size is not: "
-                               "notit-addr=%p, packet-context-field-addr=%p, "
-                               "packet-size=%" PRId64 ", content-size=%" PRId64,
-                               notit, notit->dscopes.stream_packet_context,
-                               notit->cur_exp_packet_total_size,
-                               notit->cur_exp_packet_content_size);
-                       status = BT_MSG_ITER_STATUS_ERROR;
-                       goto end;
+                       notit->cur_exp_packet_total_size =
+                               notit->cur_exp_packet_content_size;
                }
        } else {
                if (notit->cur_exp_packet_content_size == -1) {
@@ -985,6 +979,11 @@ enum bt_msg_iter_status set_current_packet_content_sizes(
                }
        }
 
+       BT_ASSERT((notit->cur_exp_packet_total_size >= 0 &&
+               notit->cur_exp_packet_content_size >= 0) ||
+               (notit->cur_exp_packet_total_size < 0 &&
+               notit->cur_exp_packet_content_size < 0));
+
        if (notit->cur_exp_packet_content_size >
                        notit->cur_exp_packet_total_size) {
                BT_LOGW("Invalid packet or content size: "
@@ -2289,11 +2288,23 @@ int64_t bfcr_get_sequence_length_cb(struct ctf_field_class *fc, void *data)
                seq_fc->stored_length_index);
        seq_field = stack_top(notit->stack)->base;
        BT_ASSERT(seq_field);
-       ret = bt_field_dynamic_array_set_length(seq_field, (uint64_t) length);
-       if (ret) {
-               BT_LOGE("Cannot set dynamic array field's length field: "
-                       "notit-addr=%p, field-addr=%p, "
-                       "length=%" PRIu64, notit, seq_field, length);
+
+       /*
+        * bfcr_get_sequence_length_cb() also gets called back for a
+        * text sequence, but the destination field is a string field.
+        * Only set the field's sequence length if the destination field
+        * is a sequence field.
+        */
+       if (!seq_fc->base.is_text) {
+               BT_ASSERT(bt_field_get_class_type(seq_field) ==
+                       BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY);
+               ret = bt_field_dynamic_array_set_length(seq_field,
+                       (uint64_t) length);
+               if (ret) {
+                       BT_LOGE("Cannot set dynamic array field's length field: "
+                               "notit-addr=%p, field-addr=%p, "
+                               "length=%" PRIu64, notit, seq_field, length);
+               }
        }
 
        return length;
@@ -2942,7 +2953,6 @@ end:
        ret = set_current_packet_content_sizes(notit);
        if (ret) {
                status = BT_MSG_ITER_STATUS_ERROR;
-               goto end;
        }
 
        return status;
@@ -3011,7 +3021,6 @@ enum bt_msg_iter_status bt_msg_iter_get_packet_properties(
        props->exp_packet_total_size = notit->cur_exp_packet_total_size;
        props->exp_packet_content_size = notit->cur_exp_packet_content_size;
        props->stream_class_id = (uint64_t) notit->cur_stream_class_id;
-       BT_ASSERT(props->stream_class_id >= 0);
        props->data_stream_id = notit->cur_data_stream_id;
        props->snapshots.discarded_events = notit->snapshots.discarded_events;
        props->snapshots.packets = notit->snapshots.packets;
This page took 0.026508 seconds and 4 git commands to generate.