lib: make trace IR API const-correct
[babeltrace.git] / plugins / ctf / common / metadata / visitor-generate-ir.c
index b1519ff5cab233400515447c5e0902521d0828d9..d746b27e551dac3d38a769e6b73794cfdcbab22b 100644 (file)
@@ -554,7 +554,7 @@ void ctx_destroy(struct ctx *ctx)
                scope = parent_scope;
        }
 
-       bt_put(ctx->trace);
+       bt_object_put_ref(ctx->trace);
 
        if (ctx->ctf_tc) {
                ctf_trace_class_destroy(ctx->ctf_tc);
@@ -2719,7 +2719,8 @@ int visit_integer_decl(struct ctx *ctx,
        (*integer_decl)->is_signed = (signedness > 0);
        (*integer_decl)->disp_base = base;
        (*integer_decl)->encoding = encoding;
-       (*integer_decl)->mapped_clock_class = bt_get(mapped_clock_class);
+       (*integer_decl)->mapped_clock_class = mapped_clock_class;
+       bt_object_get_ref((*integer_decl)->mapped_clock_class);
        return 0;
 
 error:
@@ -3606,22 +3607,22 @@ int auto_map_field_to_trace_clock_class(struct ctx *ctx,
                 */
                clock_class_to_map_to = bt_clock_class_create();
                BT_ASSERT(clock_class_to_map_to);
-               ret = bt_clock_class_set_frequency(clock_class_to_map_to,
+               bt_clock_class_set_frequency(clock_class_to_map_to,
                        UINT64_C(1000000000));
-               BT_ASSERT(ret == 0);
                ret = bt_clock_class_set_name(clock_class_to_map_to,
                        "default");
                BT_ASSERT(ret == 0);
                g_ptr_array_add(ctx->ctf_tc->clock_classes,
-                       bt_get(clock_class_to_map_to));
+                       clock_class_to_map_to);
+               bt_object_get_ref(clock_class_to_map_to);
                break;
        case 1:
                /*
                 * Only one clock class exists in the trace at this point: use
                 * this one.
                 */
-               clock_class_to_map_to =
-                       bt_get(ctx->ctf_tc->clock_classes->pdata[0]);
+               clock_class_to_map_to = ctx->ctf_tc->clock_classes->pdata[0];
+               bt_object_get_ref(clock_class_to_map_to);
                break;
        default:
                /*
@@ -3635,10 +3636,11 @@ int auto_map_field_to_trace_clock_class(struct ctx *ctx,
        }
 
        BT_ASSERT(clock_class_to_map_to);
-       int_fc->mapped_clock_class = bt_get(clock_class_to_map_to);
+       int_fc->mapped_clock_class = clock_class_to_map_to;
+       bt_object_get_ref(int_fc->mapped_clock_class);
 
 end:
-       bt_put(clock_class_to_map_to);
+       bt_object_put_ref(clock_class_to_map_to);
        return ret;
 }
 
@@ -4433,13 +4435,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                        goto error;
                }
 
-               ret = bt_clock_class_set_uuid(clock, uuid);
-               if (ret) {
-                       _BT_LOGE_NODE(entry_node,
-                               "Cannot set clock class's UUID.");
-                       goto error;
-               }
-
+               bt_clock_class_set_uuid(clock, uuid);
                _SET(set, _CLOCK_UUID_SET);
        } else if (!strcmp(left, "description")) {
                char *right;
@@ -4496,13 +4492,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                        goto error;
                }
 
-               ret = bt_clock_class_set_frequency(clock, freq);
-               if (ret) {
-                       _BT_LOGE_NODE(entry_node,
-                               "Cannot set clock class's frequency.");
-                       goto error;
-               }
-
+               bt_clock_class_set_frequency(clock, freq);
                _SET(set, _CLOCK_FREQ_SET);
        } else if (!strcmp(left, "precision")) {
                uint64_t precision;
@@ -4523,13 +4513,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                        goto error;
                }
 
-               ret = bt_clock_class_set_precision(clock, precision);
-               if (ret) {
-                       _BT_LOGE_NODE(entry_node,
-                               "Cannot set clock class's precision.");
-                       goto error;
-               }
-
+               bt_clock_class_set_precision(clock, precision);
                _SET(set, _CLOCK_PRECISION_SET);
        } else if (!strcmp(left, "offset_s")) {
                if (_IS_SET(set, _CLOCK_OFFSET_S_SET)) {
@@ -4587,13 +4571,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                        goto error;
                }
 
-               ret = bt_clock_class_set_is_absolute(clock, ret);
-               if (ret) {
-                       _BT_LOGE_NODE(entry_node,
-                               "Cannot set clock class's absolute flag.");
-                       goto error;
-               }
-
+               bt_clock_class_set_is_absolute(clock, ret);
                _SET(set, _CLOCK_ABSOLUTE_SET);
        } else {
                _BT_LOGW_NODE(entry_node,
@@ -4638,9 +4616,9 @@ void calibrate_clock_class_offsets(int64_t *offset_seconds,
 }
 
 static
-void apply_clock_class_offset(struct ctx *ctx, struct bt_clock_class *clock)
+void apply_clock_class_offset(struct ctx *ctx,
+               struct bt_clock_class *clock)
 {
-       int ret;
        uint64_t freq;
        int64_t offset_s_to_apply = ctx->decoder_config.clock_class_offset_s;
        uint64_t offset_ns_to_apply;
@@ -4675,7 +4653,8 @@ void apply_clock_class_offset(struct ctx *ctx, struct bt_clock_class *clock)
        }
 
        freq = bt_clock_class_get_frequency(clock);
-       bt_clock_class_get_offset(clock, &cur_offset_s, &cur_offset_cycles);
+       bt_clock_class_get_offset(clock,
+                                 &cur_offset_s, &cur_offset_cycles);
 
        /* Apply offsets */
        cur_offset_s += offset_s_to_apply;
@@ -4688,8 +4667,7 @@ void apply_clock_class_offset(struct ctx *ctx, struct bt_clock_class *clock)
        calibrate_clock_class_offsets(&cur_offset_s, &cur_offset_cycles, freq);
 
        /* Set final offsets */
-       ret = bt_clock_class_set_offset(clock, cur_offset_s, cur_offset_cycles);
-       BT_ASSERT(ret == 0);
+       bt_clock_class_set_offset(clock, cur_offset_s, cur_offset_cycles);
 
 end:
        return;
@@ -4724,12 +4702,7 @@ int visit_clock_decl(struct ctx *ctx, struct ctf_node *clock_node)
        }
 
        /* CTF: not absolute by default */
-       ret = bt_clock_class_set_is_absolute(clock, BT_FALSE);
-       if (ret) {
-               _BT_LOGE_NODE(clock_node,
-                       "Cannot set clock class's absolute flag.");
-               goto end;
-       }
+       bt_clock_class_set_is_absolute(clock, BT_FALSE);
 
        bt_list_for_each_entry(entry_node, decl_list, siblings) {
                ret = visit_clock_decl_entry(ctx, entry_node, clock, &set,
@@ -4758,12 +4731,7 @@ int visit_clock_decl(struct ctx *ctx, struct ctf_node *clock_node)
                 * it's a condition to be able to sort notifications
                 * from different sources.
                 */
-               ret = bt_clock_class_set_is_absolute(clock, BT_TRUE);
-               if (ret) {
-                       _BT_LOGE_NODE(clock_node,
-                               "Cannot set clock class's absolute flag.");
-                       goto end;
-               }
+               bt_clock_class_set_is_absolute(clock, BT_TRUE);
        }
 
        /*
@@ -4773,13 +4741,13 @@ int visit_clock_decl(struct ctx *ctx, struct ctf_node *clock_node)
        freq = bt_clock_class_get_frequency(clock);
        calibrate_clock_class_offsets(&offset_seconds, &offset_cycles, freq);
        BT_ASSERT(offset_cycles < bt_clock_class_get_frequency(clock));
-       ret = bt_clock_class_set_offset(clock, offset_seconds, offset_cycles);
-       BT_ASSERT(ret == 0);
+       bt_clock_class_set_offset(clock, offset_seconds, offset_cycles);
        apply_clock_class_offset(ctx, clock);
-       g_ptr_array_add(ctx->ctf_tc->clock_classes, bt_get(clock));
+       g_ptr_array_add(ctx->ctf_tc->clock_classes, clock);
+       bt_object_get_ref(clock);
 
 end:
-       BT_PUT(clock);
+       BT_OBJECT_PUT_REF_AND_RESET(clock);
        return ret;
 }
 
@@ -4934,7 +4902,8 @@ struct bt_trace *ctf_visitor_generate_ir_get_ir_trace(
 
        BT_ASSERT(ctx);
        BT_ASSERT(ctx->trace);
-       return bt_get(ctx->trace);
+       bt_object_get_ref(ctx->trace);
+       return ctx->trace;
 }
 
 BT_HIDDEN
This page took 0.038774 seconds and 4 git commands to generate.