src.ctf.fs: use one CTF notif iter per notification iterator
[babeltrace.git] / plugins / ctf / common / notif-iter / notif-iter.c
index 5a7b325518f9e67ee697aff2b0da3e7088f17896..06125b2315e3579bca9455c4b41b3c3ea0af9330 100644 (file)
@@ -143,9 +143,6 @@ struct bt_ctf_notif_iter {
        /* Visit stack */
        struct stack *stack;
 
-       /* Error stream (may be NULL) */
-       FILE *err_stream;
-
        /*
         * Current dynamic scope field pointer.
         *
@@ -1051,7 +1048,9 @@ enum bt_ctf_notif_iter_status set_current_packet_content_sizes(
        struct bt_ctf_field *content_size_field = NULL;
        uint64_t content_size = -1, packet_size = -1;
 
-       assert(notit->dscopes.stream_packet_context);
+       if (!notit->dscopes.stream_packet_context) {
+               goto end;
+       }
 
        packet_size_field = bt_ctf_field_structure_get_field(
                notit->dscopes.stream_packet_context, "packet_size");
@@ -1812,7 +1811,7 @@ enum bt_ctf_btr_status update_clock(struct bt_ctf_notif_iter *notit,
                struct bt_ctf_field *int_field)
 {
        gboolean clock_class_found;
-       uint64_t *clock_state;
+       uint64_t *clock_state = NULL;
        struct bt_ctf_field_type *int_field_type = NULL;
        enum bt_ctf_btr_status ret = BT_CTF_BTR_STATUS_OK;
        struct bt_ctf_clock_class *clock_class = NULL;
@@ -1827,12 +1826,7 @@ enum bt_ctf_btr_status update_clock(struct bt_ctf_notif_iter *notit,
 
        clock_class_found = g_hash_table_lookup_extended(notit->clock_states,
                clock_class, NULL, (gpointer) &clock_state);
-       if (unlikely(!clock_class_found)) {
-               ret = BT_CTF_BTR_STATUS_ERROR;
-               goto end;
-       }
-
-       if (unlikely(!clock_state)) {
+       if (!clock_class_found) {
                clock_state = g_new0(uint64_t, 1);
                if (!clock_state) {
                        BT_LOGE_STR("Failed to allocate a uint64_t.");
@@ -2811,27 +2805,6 @@ end:
        BT_PUT(event);
 }
 
-static
-int init_clock_states(GHashTable *clock_states, struct bt_ctf_trace *trace)
-{
-       int clock_class_count, i, ret = 0;
-
-       assert(trace);
-       clock_class_count = bt_ctf_trace_get_clock_class_count(trace);
-       assert(clock_class_count >= 0);
-
-       for (i = 0; i < clock_class_count; i++) {
-               struct bt_ctf_clock_class *clock_class;
-
-               clock_class = bt_ctf_trace_get_clock_class_by_index(trace, i);
-               assert(clock_class);
-               g_hash_table_insert(clock_states, bt_get(clock_class), NULL);
-               bt_put(clock_class);
-       }
-
-       return ret;
-}
-
 static
 void init_trace_field_path_cache(struct bt_ctf_trace *trace,
                struct trace_field_path_cache *trace_field_path_cache)
@@ -2883,10 +2856,8 @@ end:
 BT_HIDDEN
 struct bt_ctf_notif_iter *bt_ctf_notif_iter_create(struct bt_ctf_trace *trace,
                size_t max_request_sz,
-               struct bt_ctf_notif_iter_medium_ops medops,
-               void *data, FILE *err_stream)
+               struct bt_ctf_notif_iter_medium_ops medops, void *data)
 {
-       int ret;
        struct bt_ctf_notif_iter *notit = NULL;
        struct bt_ctf_btr_cbs cbs = {
                .types = {
@@ -2923,23 +2894,17 @@ struct bt_ctf_notif_iter *bt_ctf_notif_iter_create(struct bt_ctf_trace *trace,
                BT_LOGE_STR("Failed to allocate a GHashTable.");
                goto error;
        }
-       ret = init_clock_states(notit->clock_states, trace);
-       if (ret) {
-               BT_LOGW("Cannot initialize clock values.");
-               goto error;
-       }
        notit->meta.trace = bt_get(trace);
        notit->medium.medops = medops;
        notit->medium.max_request_sz = max_request_sz;
        notit->medium.data = data;
-       notit->err_stream = err_stream;
        notit->stack = stack_new(notit);
        if (!notit->stack) {
                BT_LOGE_STR("Failed to create field stack.");
                goto error;
        }
 
-       notit->btr = bt_ctf_btr_create(cbs, notit, err_stream);
+       notit->btr = bt_ctf_btr_create(cbs, notit);
        if (!notit->btr) {
                BT_LOGE_STR("Failed to create binary type reader (BTR).");
                goto error;
@@ -3164,3 +3129,11 @@ set_fields:
 end:
        return status;
 }
+
+BT_HIDDEN
+void bt_ctf_notif_iter_set_medops_data(struct bt_ctf_notif_iter *notit,
+               void *medops_data)
+{
+       assert(notit);
+       notit->medium.data = medops_data;
+}
This page took 0.024791 seconds and 4 git commands to generate.