src.ctf.fs: remove ctf_fs_ds_file_next
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 4 Nov 2019 21:31:52 +0000 (16:31 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Fri, 15 Nov 2019 18:08:11 +0000 (13:08 -0500)
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 <simon.marchi@efficios.com>
src/plugins/ctf/fs-src/data-stream-file.c
src/plugins/ctf/fs-src/data-stream-file.h
src/plugins/ctf/fs-src/fs.c

index b8091f660755c6524715fc92c71ed45a09a31ac5..1fd9e4257f5ca59f94bf7867eb9893c409689f36 100644 (file)
@@ -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)
 {
index 66a6c436908c37059f1a5d76e2225fd8a4a0f01a..6f1535e304126d9de8a19492efd46aa7b1394837 100644 (file)
@@ -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,
index eb8dbe53e7f803c114b5fbeeda44688e066ab958..0f28a09a8e6376f1792285f5822e56bd7537e382 100644 (file)
@@ -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;
                }
        }
This page took 0.026926 seconds and 4 git commands to generate.