From f87fb9b4a7b6191360f192bf6e37db070d745e64 Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Fri, 2 Jun 2017 09:37:01 -0400 Subject: [PATCH] Fix copytrace: copy the entire payload_type MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Copy payload_type directly rather than iterating on its members. Signed-off-by: Julien Desfossez Signed-off-by: Jérémie Galarneau --- plugins/libctfcopytrace/ctfcopytrace.c | 27 ++++++++------------------ 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/plugins/libctfcopytrace/ctfcopytrace.c b/plugins/libctfcopytrace/ctfcopytrace.c index 8c54d43c..d2c78184 100644 --- a/plugins/libctfcopytrace/ctfcopytrace.c +++ b/plugins/libctfcopytrace/ctfcopytrace.c @@ -210,7 +210,7 @@ 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; + struct bt_ctf_field_type *context, *payload_type; const char *name; int count, i, ret; @@ -259,27 +259,16 @@ struct bt_ctf_event_class *ctf_copy_event_class(FILE *err, } } - count = bt_ctf_event_class_get_payload_type_field_count(event_class); - for (i = 0; i < count; i++) { - const char *field_name; - struct bt_ctf_field_type *field_type; - int ret; - - ret = bt_ctf_event_class_get_payload_type_field_by_index( - event_class, &field_name, &field_type, i); + payload_type = bt_ctf_event_class_get_payload_type(event_class); + if (payload_type) { + ret = bt_ctf_event_class_set_payload_type(writer_event_class, + payload_type); if (ret < 0) { - fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); - goto error; - } - - ret = bt_ctf_event_class_add_field(writer_event_class, field_type, - field_name); - BT_PUT(field_type); - if (ret < 0) { - fprintf(err, "[error] Cannot add field %s\n", field_name); - fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); + fprintf(err, "[error] %s in %s:%d\n", __func__, + __FILE__, __LINE__); goto error; } + BT_PUT(payload_type); } context = bt_ctf_event_class_get_context_type(event_class); -- 2.34.1