Fix: debug info plugin incorrect assumption about header and clock
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 9 Jun 2017 23:00:22 +0000 (19:00 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 9 Jun 2017 23:15:16 +0000 (19:15 -0400)
Fix a few assumptions in the copy helper:
- A stream may not have event headers,
- A trace may not have clocks.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
plugins/lttng-utils/copy.c

index 9fddc8a73dba79ce1633e1e1b60b532d5f5ad765..d3a6878b6f5e58208fff069ca85d15cc0ddb39c2 100644 (file)
@@ -1060,20 +1060,16 @@ struct bt_ctf_stream_class *copy_stream_class_debug_info(FILE *err,
        BT_PUT(type);
 
        type = bt_ctf_stream_class_get_event_header_type(stream_class);
-       if (!type) {
-               fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
-                               __LINE__);
-               goto error;
-       }
-
-       ret_int = bt_ctf_stream_class_set_event_header_type(
-                       writer_stream_class, type);
-       if (ret_int < 0) {
-               fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
-                               __LINE__);
-               goto error;
+       if (type) {
+               ret_int = bt_ctf_stream_class_set_event_header_type(
+                               writer_stream_class, type);
+               if (ret_int < 0) {
+                       fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
+                                       __LINE__);
+                       goto error;
+               }
+               BT_PUT(type);
        }
-       BT_PUT(type);
 
        type = bt_ctf_stream_class_get_event_context_type(stream_class);
        if (type) {
@@ -1852,6 +1848,11 @@ struct bt_ctf_clock_class *stream_class_get_clock_class(FILE *err,
                goto end;
        }
 
+       if (!bt_ctf_trace_get_clock_class_count(trace)) {
+               /* No clock. */
+               goto end;
+       }
+
        /* FIXME multi-clock? */
        clock_class = bt_ctf_trace_get_clock_class_by_index(trace, 0);
 
@@ -1903,9 +1904,8 @@ int set_event_clock_value(FILE *err, struct bt_ctf_event *event,
 
        clock_class = event_get_clock_class(err, event);
        if (!clock_class) {
-               fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
-                               __LINE__);
-               goto error;
+               /* No clock on input trace. */
+               goto end;
        }
 
        clock_value = bt_ctf_event_get_clock_value(event, clock_class);
This page took 0.025481 seconds and 4 git commands to generate.