From 279c77d0c8f4acd36f82fbc2c85a410ad5f9a202 Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Fri, 2 Jun 2017 09:12:03 -0400 Subject: [PATCH] move the copy of event_context in ctf_copy_event_class MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Julien Desfossez Signed-off-by: Jérémie Galarneau --- plugins/libctfcopytrace/ctfcopytrace.c | 31 ++++++++++++-------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/plugins/libctfcopytrace/ctfcopytrace.c b/plugins/libctfcopytrace/ctfcopytrace.c index 882ab85a..bfd51129 100644 --- a/plugins/libctfcopytrace/ctfcopytrace.c +++ b/plugins/libctfcopytrace/ctfcopytrace.c @@ -214,8 +214,9 @@ struct bt_ctf_event_class *ctf_copy_event_class(FILE *err, struct bt_ctf_event_class *event_class) { struct bt_ctf_event_class *writer_event_class = NULL; + struct bt_ctf_field_type *context; const char *name; - int count, i; + int count, i, ret; name = bt_ctf_event_class_get_name(event_class); if (!name) { @@ -285,6 +286,18 @@ struct bt_ctf_event_class *ctf_copy_event_class(FILE *err, } } + context = bt_ctf_event_class_get_context_type(event_class); + if (context) { + ret = bt_ctf_event_class_set_context_type( + writer_event_class, context); + BT_PUT(context); + if (ret < 0) { + fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, + __LINE__); + goto error; + } + } + goto end; error: @@ -310,7 +323,6 @@ enum bt_component_status ctf_copy_event_classes(FILE *err, } for (i = 0; i < count; i++) { - struct bt_ctf_field_type *context; int int_ret; event_class = bt_ctf_stream_class_get_event_class_by_index( @@ -329,21 +341,6 @@ enum bt_component_status ctf_copy_event_classes(FILE *err, goto error; } - context = bt_ctf_event_class_get_context_type(event_class); - if (!context) { - fprintf(err, "[error] %s in %s:%d\n", __func__, - __FILE__, __LINE__); - ret = BT_COMPONENT_STATUS_ERROR; - goto error; - } - ret = bt_ctf_event_class_set_context_type(writer_event_class, context); - BT_PUT(context); - if (ret < 0) { - fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, - __LINE__); - goto error; - } - int_ret = bt_ctf_stream_class_add_event_class(writer_stream_class, writer_event_class); if (int_ret < 0) { -- 2.34.1