From: Mathieu Desnoyers Date: Fri, 9 Jun 2017 23:00:22 +0000 (-0400) Subject: Fix: debug info plugin incorrect assumption about header and clock X-Git-Tag: v2.0.0-pre1~2 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=290b95cc70019c99e572bc1e34361edb0678d703 Fix: debug info plugin incorrect assumption about header and clock 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 --- 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);