ctf: rename bt_msg_iter::msg_iter to self_msg_iter
[babeltrace.git] / src / plugins / ctf / fs-src / data-stream-file.c
index 6ddb8a34d0f861c921cde8fe3c50161e818a0902..20b60cce70792475e78af132c3c4fee0e549f2c1 100644 (file)
@@ -31,7 +31,6 @@
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
-#include <stdbool.h>
 #include <glib.h>
 #include <inttypes.h>
 #include "compat/mman.h"
@@ -48,7 +47,7 @@
 static inline
 size_t remaining_mmap_bytes(struct ctf_fs_ds_file *ds_file)
 {
-       BT_ASSERT(ds_file->mmap_len >= ds_file->request_offset);
+       BT_ASSERT_DBG(ds_file->mmap_len >= ds_file->request_offset);
        return ds_file->mmap_len - ds_file->request_offset;
 }
 
@@ -251,7 +250,7 @@ enum bt_msg_iter_medium_status medop_seek(enum bt_msg_iter_seek_whence whence,
 
 map_requested_offset:
        offset_in_mapping = offset %
-               bt_common_get_page_size(ds_file->log_level);
+               bt_mmap_get_offset_align_size(ds_file->log_level);
 
        ds_file->mmap_offset = offset - offset_in_mapping;
        ds_file->request_offset = offset_in_mapping;
@@ -448,8 +447,11 @@ struct ctf_fs_ds_index *build_index_from_idx_file(
                total_packets_size += packet_size;
                file_pos += file_index_entry_size;
 
-               g_ptr_array_add(index->entries, index_entry);
                prev_index_entry = index_entry;
+
+               /* Give ownership of `index_entry` to `index->entries`. */
+               g_ptr_array_add(index->entries, index_entry);
+               index_entry = NULL;
        }
 
        /* Validate that the index addresses the complete stream. */
@@ -547,7 +549,7 @@ struct ctf_fs_ds_index *build_index_from_stream_file(
                goto error;
        }
 
-       do {
+       while (true) {
                off_t current_packet_size_bytes;
                struct ctf_fs_ds_index_entry *index_entry;
                struct bt_msg_iter_packet_properties props;
@@ -617,11 +619,6 @@ struct ctf_fs_ds_index *build_index_from_stream_file(
                        "next-packet-offset=%jd",
                        (intmax_t) (current_packet_offset_bytes - current_packet_size_bytes),
                        (intmax_t) current_packet_offset_bytes);
-
-       } while (iter_status == BT_MSG_ITER_STATUS_OK);
-
-       if (iter_status != BT_MSG_ITER_STATUS_OK) {
-               goto error;
        }
 
 end:
@@ -642,7 +639,7 @@ struct ctf_fs_ds_file *ctf_fs_ds_file_create(
                bt_logging_level log_level)
 {
        int ret;
-       const size_t page_size = bt_common_get_page_size(log_level);
+       const size_t offset_align = bt_mmap_get_offset_align_size(log_level);
        struct ctf_fs_ds_file *ds_file = g_new0(struct ctf_fs_ds_file, 1);
 
        if (!ds_file) {
@@ -651,7 +648,7 @@ struct ctf_fs_ds_file *ctf_fs_ds_file_create(
 
        ds_file->log_level = log_level;
        ds_file->self_comp = ctf_fs_trace->self_comp;
-       ds_file->pc_msg_iter = pc_msg_iter;
+       ds_file->self_msg_iter = pc_msg_iter;
        ds_file->file = ctf_fs_file_create(log_level, ds_file->self_comp);
        if (!ds_file->file) {
                goto error;
@@ -672,7 +669,7 @@ struct ctf_fs_ds_file *ctf_fs_ds_file_create(
                goto error;
        }
 
-       ds_file->mmap_max_len = page_size * 2048;
+       ds_file->mmap_max_len = offset_align * 2048;
 
        goto end;
 
@@ -758,7 +755,7 @@ bt_component_class_message_iterator_next_method_status ctf_fs_ds_file_next(
        bt_component_class_message_iterator_next_method_status status;
 
        msg_iter_status = bt_msg_iter_get_next_message(
-               ds_file->msg_iter, ds_file->pc_msg_iter, msg);
+               ds_file->msg_iter, ds_file->self_msg_iter, msg);
 
        switch (msg_iter_status) {
        case BT_MSG_ITER_STATUS_EOF:
@@ -773,7 +770,7 @@ bt_component_class_message_iterator_next_method_status ctf_fs_ds_file_next(
                 * medium-specific; there is nothing for the user to do
                 * and it should have been handled upstream.
                 */
-               abort();
+               bt_common_abort();
        case BT_MSG_ITER_STATUS_INVAL:
        case BT_MSG_ITER_STATUS_ERROR:
        default:
This page took 0.025779 seconds and 4 git commands to generate.