From 4829c3e2f7137d73c75baff615bce560268ebba4 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 4 Nov 2019 16:31:52 -0500 Subject: [PATCH] src.ctf.fs: remove ctf_fs_ds_file_next The function ctf_fs_ds_file_next is not really relevant, as it doesn't deal with anything ds_file-specific anymore. It only calls the ctf_msg_iter_get_next_message and translates the result to a bt_component_class_message_iterator_next_method_status. I think this job can (and should) be done by fs.c directly, as it's the primary user/owner of the ctf_msg_iter. This patch removes ctf_fs_ds_file_next and updates ctf_fs_iterator_next_one to call ctf_msg_iter_get_next_message directly. Change-Id: I96a9e1aa9d3c689bdf19f342464e1632c35058ca Signed-off-by: Simon Marchi --- src/plugins/ctf/fs-src/data-stream-file.c | 33 ----------------------- src/plugins/ctf/fs-src/data-stream-file.h | 5 ---- src/plugins/ctf/fs-src/fs.c | 31 +++++++++++++++------ 3 files changed, 23 insertions(+), 46 deletions(-) diff --git a/src/plugins/ctf/fs-src/data-stream-file.c b/src/plugins/ctf/fs-src/data-stream-file.c index b8091f66..1fd9e425 100644 --- a/src/plugins/ctf/fs-src/data-stream-file.c +++ b/src/plugins/ctf/fs-src/data-stream-file.c @@ -796,39 +796,6 @@ void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *ds_file) g_free(ds_file); } -BT_HIDDEN -bt_component_class_message_iterator_next_method_status ctf_fs_ds_file_next( - struct ctf_msg_iter *msg_iter, - const bt_message **msg) -{ - enum ctf_msg_iter_status msg_iter_status; - bt_component_class_message_iterator_next_method_status status; - - msg_iter_status = ctf_msg_iter_get_next_message(msg_iter, msg); - - switch (msg_iter_status) { - case CTF_MSG_ITER_STATUS_EOF: - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; - break; - case CTF_MSG_ITER_STATUS_OK: - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; - break; - case CTF_MSG_ITER_STATUS_AGAIN: - /* - * Should not make it this far as this is - * medium-specific; there is nothing for the user to do - * and it should have been handled upstream. - */ - bt_common_abort(); - case CTF_MSG_ITER_STATUS_INVAL: - case CTF_MSG_ITER_STATUS_ERROR: - default: - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; - break; - } - return status; -} - BT_HIDDEN void ctf_fs_ds_index_destroy(struct ctf_fs_ds_index *index) { diff --git a/src/plugins/ctf/fs-src/data-stream-file.h b/src/plugins/ctf/fs-src/data-stream-file.h index 66a6c436..6f1535e3 100644 --- a/src/plugins/ctf/fs-src/data-stream-file.h +++ b/src/plugins/ctf/fs-src/data-stream-file.h @@ -98,11 +98,6 @@ struct ctf_fs_ds_file *ctf_fs_ds_file_create( BT_HIDDEN void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *stream); -BT_HIDDEN -bt_component_class_message_iterator_next_method_status ctf_fs_ds_file_next( - struct ctf_msg_iter *msg_iter, - const bt_message **msg); - BT_HIDDEN struct ctf_fs_ds_index *ctf_fs_ds_file_build_index( struct ctf_fs_ds_file *ds_file, diff --git a/src/plugins/ctf/fs-src/fs.c b/src/plugins/ctf/fs-src/fs.c index eb8dbe53..0f28a09a 100644 --- a/src/plugins/ctf/fs-src/fs.c +++ b/src/plugins/ctf/fs-src/fs.c @@ -127,17 +127,23 @@ bt_component_class_message_iterator_next_method_status ctf_fs_iterator_next_one( BT_ASSERT_DBG(msg_iter_data->ds_file); while (true) { - status = ctf_fs_ds_file_next(msg_iter_data->msg_iter, out_msg); - switch (status) { - case BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK: + enum ctf_msg_iter_status msg_iter_status; + int ret; + + msg_iter_status = ctf_msg_iter_get_next_message( + msg_iter_data->msg_iter, out_msg); + + switch (msg_iter_status) { + case CTF_MSG_ITER_STATUS_OK: + /* Cool, message has been written to *out_msg. */ + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; goto end; - case BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END: - { - int ret; + case CTF_MSG_ITER_STATUS_EOF: if (msg_iter_data->ds_file_info_index == msg_iter_data->ds_file_group->ds_file_infos->len - 1) { /* End of all group's stream files */ + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; goto end; } @@ -157,10 +163,19 @@ bt_component_class_message_iterator_next_method_status ctf_fs_iterator_next_one( goto end; } - /* Continue the loop to get the next message */ + /* Continue the loop to get the next message. */ break; - } + + case CTF_MSG_ITER_STATUS_AGAIN: + /* + * Should not make it this far as this is + * medium-specific; there is nothing for the user to do + * and it should have been handled upstream. + */ + bt_common_abort(); + default: + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; goto end; } } -- 2.34.1