Fix: unchecked bt_ctf_field_type_set_alignment return value
[babeltrace.git] / formats / ctf / ir / trace.c
index 2c0e7670f627600ef4bf7dc8ab3e7cbbd1aa02be..4d9e97f9e1f8f53770c464ec2c9dca53681c5330 100644 (file)
@@ -136,43 +136,6 @@ void bt_ctf_trace_destroy(struct bt_object *obj)
        g_free(trace);
 }
 
-struct bt_ctf_stream *bt_ctf_trace_create_stream(struct bt_ctf_trace *trace,
-               struct bt_ctf_stream_class *stream_class)
-{
-       int ret;
-       int stream_class_found = 0;
-       size_t i;
-       struct bt_ctf_stream *stream = NULL;
-
-       if (!trace || !stream_class) {
-               goto error;
-       }
-
-       for (i = 0; i < trace->stream_classes->len; i++) {
-               if (trace->stream_classes->pdata[i] == stream_class) {
-                       stream_class_found = 1;
-               }
-       }
-
-       if (!stream_class_found) {
-               ret = bt_ctf_trace_add_stream_class(trace, stream_class);
-               if (ret) {
-                       goto error;
-               }
-       }
-
-       stream = bt_ctf_stream_create(stream_class, trace);
-       if (!stream) {
-               goto error;
-       }
-
-       g_ptr_array_add(trace->streams, stream);
-       return stream;
-error:
-        BT_PUT(stream);
-       return stream;
-}
-
 int bt_ctf_trace_set_environment_field(struct bt_ctf_trace *trace,
                const char *name, struct bt_value *value)
 {
@@ -388,6 +351,15 @@ int bt_ctf_trace_add_clock(struct bt_ctf_trace *trace,
        bt_get(clock);
        g_ptr_array_add(trace->clocks, clock);
 
+       if (!trace->is_created_by_writer) {
+               /*
+                * Non-writer mode trace: disable clock value functions
+                * because clock values are per-stream in that
+                * situation.
+                */
+               clock->has_value = 0;
+       }
+
        if (trace->frozen) {
                bt_ctf_clock_freeze(clock);
        }
@@ -1058,6 +1030,7 @@ end:
 BT_HIDDEN
 struct bt_ctf_field_type *get_field_type(enum field_type_alias alias)
 {
+       int ret;
        unsigned int alignment, size;
        struct bt_ctf_field_type *field_type = NULL;
 
@@ -1068,7 +1041,10 @@ struct bt_ctf_field_type *get_field_type(enum field_type_alias alias)
        alignment = field_type_aliases_alignments[alias];
        size = field_type_aliases_sizes[alias];
        field_type = bt_ctf_field_type_integer_create(size);
-       bt_ctf_field_type_set_alignment(field_type, alignment);
+       ret = bt_ctf_field_type_set_alignment(field_type, alignment);
+       if (ret) {
+               BT_PUT(field_type);
+       }
 end:
        return field_type;
 }
This page took 0.023327 seconds and 4 git commands to generate.