From 290b95cc70019c99e572bc1e34361edb0678d703 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 9 Jun 2017 19:00:22 -0400 Subject: [PATCH] Fix: debug info plugin incorrect assumption about header and clock MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Jérémie Galarneau --- plugins/lttng-utils/copy.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/plugins/lttng-utils/copy.c b/plugins/lttng-utils/copy.c index 9fddc8a7..d3a6878b 100644 --- a/plugins/lttng-utils/copy.c +++ b/plugins/lttng-utils/copy.c @@ -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); -- 2.34.1