ctf: const-ify a few bt_message parameters
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 4 Nov 2019 21:48:15 +0000 (16:48 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Fri, 15 Nov 2019 18:08:11 +0000 (13:08 -0500)
I didn't understand at first why we needed a temporary local variable in
ctf_fs_iterator_next_one, why we couldn't just pass out_msg directly to
ctf_fs_ds_file_next.  If we constify the parameter of
ctf_fs_ds_file_next, we can get rid of the variable.  Doing so has a few
ramifications, it requires to constify the parameter in a few other
functions.  But in the end I think it's all for the greater good.

Change-Id: Ie68249d38dae7a26ab8ce9341b436257644b3b10
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
src/plugins/ctf/common/msg-iter/msg-iter.c
src/plugins/ctf/common/msg-iter/msg-iter.h
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
src/plugins/ctf/lttng-live/lttng-live.c
src/plugins/ctf/lttng-live/lttng-live.h

index 5c99aed1e3381989f91fe59d47212ca23ce1dee0..c094acc4c002fcf0b03ec4a348543abc1709d416 100644 (file)
@@ -2916,7 +2916,7 @@ void ctf_msg_iter_destroy(struct ctf_msg_iter *msg_it)
 
 enum ctf_msg_iter_status ctf_msg_iter_get_next_message(
                struct ctf_msg_iter *msg_it,
-               bt_message **message)
+               const bt_message **message)
 {
        enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
        bt_self_component *self_comp = msg_it->self_comp;
index a5969f44406f26a10b47acb584edc3cc0c6984b5..cc5313b1f54eac7a01b555c3e4b6498feb2472cb 100644 (file)
@@ -291,7 +291,7 @@ void ctf_msg_iter_destroy(struct ctf_msg_iter *msg_iter);
 BT_HIDDEN
 enum ctf_msg_iter_status ctf_msg_iter_get_next_message(
                struct ctf_msg_iter *msg_it,
-               bt_message **message);
+               const bt_message **message);
 
 struct ctf_msg_iter_packet_properties {
        int64_t exp_packet_total_size;
index 6867529e45d596a4847b73982f1b84e86b76fe8c..b8091f660755c6524715fc92c71ed45a09a31ac5 100644 (file)
@@ -799,7 +799,7 @@ void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *ds_file)
 BT_HIDDEN
 bt_component_class_message_iterator_next_method_status ctf_fs_ds_file_next(
                struct ctf_msg_iter *msg_iter,
-               bt_message **msg)
+               const bt_message **msg)
 {
        enum ctf_msg_iter_status msg_iter_status;
        bt_component_class_message_iterator_next_method_status status;
index ff9643b5af00043a83f2f552cbbbc74bc9146df9..66a6c436908c37059f1a5d76e2225fd8a4a0f01a 100644 (file)
@@ -101,7 +101,7 @@ 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,
-               bt_message **msg);
+               const bt_message **msg);
 
 BT_HIDDEN
 struct ctf_fs_ds_index *ctf_fs_ds_file_build_index(
index 0530f0152df1e542219310230068049731853006..eb8dbe53e7f803c114b5fbeeda44688e066ab958 100644 (file)
@@ -127,13 +127,9 @@ bt_component_class_message_iterator_next_method_status ctf_fs_iterator_next_one(
        BT_ASSERT_DBG(msg_iter_data->ds_file);
 
        while (true) {
-               bt_message *msg;
-
-               status = ctf_fs_ds_file_next(msg_iter_data->msg_iter, &msg);
+               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:
-                       *out_msg = msg;
-                       msg = NULL;
                        goto end;
                case BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END:
                {
index 77dd590d237f64b013b8fcbf4367c8f8ee4d7380..b8f3c8c278c36c31cd232351147e40ee243e6816 100644 (file)
@@ -623,7 +623,7 @@ static
 enum lttng_live_iterator_status emit_inactivity_message(
                struct lttng_live_msg_iter *lttng_live_msg_iter,
                struct lttng_live_stream_iterator *stream_iter,
-               bt_message **message, uint64_t timestamp)
+               const bt_message **message, uint64_t timestamp)
 {
        enum lttng_live_iterator_status ret = LTTNG_LIVE_ITERATOR_STATUS_OK;
        bt_logging_level log_level = lttng_live_msg_iter->log_level;
@@ -655,7 +655,7 @@ static
 enum lttng_live_iterator_status lttng_live_iterator_next_handle_one_quiescent_stream(
                struct lttng_live_msg_iter *lttng_live_msg_iter,
                struct lttng_live_stream_iterator *lttng_live_stream,
-               bt_message **message)
+               const bt_message **message)
 {
        enum lttng_live_iterator_status ret = LTTNG_LIVE_ITERATOR_STATUS_OK;
 
@@ -781,7 +781,7 @@ static
 enum lttng_live_iterator_status lttng_live_iterator_next_handle_one_active_data_stream(
                struct lttng_live_msg_iter *lttng_live_msg_iter,
                struct lttng_live_stream_iterator *lttng_live_stream,
-               bt_message **message)
+               const bt_message **message)
 {
        enum lttng_live_iterator_status ret = LTTNG_LIVE_ITERATOR_STATUS_OK;
        bt_logging_level log_level = lttng_live_msg_iter->log_level;
@@ -856,7 +856,7 @@ static
 enum lttng_live_iterator_status lttng_live_iterator_close_stream(
                struct lttng_live_msg_iter *lttng_live_msg_iter,
                struct lttng_live_stream_iterator *stream_iter,
-               bt_message **curr_msg)
+               const bt_message **curr_msg)
 {
        enum lttng_live_iterator_status live_status =
                LTTNG_LIVE_ITERATOR_STATUS_OK;
@@ -935,7 +935,7 @@ static
 enum lttng_live_iterator_status lttng_live_iterator_next_msg_on_stream(
                struct lttng_live_msg_iter *lttng_live_msg_iter,
                struct lttng_live_stream_iterator *stream_iter,
-               bt_message **curr_msg)
+               const bt_message **curr_msg)
 {
        bt_logging_level log_level = lttng_live_msg_iter->log_level;
        bt_self_component *self_comp = lttng_live_msg_iter->self_comp;
@@ -1035,7 +1035,7 @@ enum lttng_live_iterator_status next_stream_iterator_for_trace(
                 * iterator get it.
                 */
                while (!stream_iter->current_msg) {
-                       bt_message *msg = NULL;
+                       const bt_message *msg = NULL;
                        int64_t curr_msg_ts_ns = INT64_MAX;
                        stream_iter_status = lttng_live_iterator_next_msg_on_stream(
                                lttng_live_msg_iter, stream_iter, &msg);
index ad01c7ddab760693e7cb0b7b2f084ac6d41d9948..a6e1590df8b58b7c0d59ddf1c2f22a01c15ea164 100644 (file)
@@ -110,7 +110,7 @@ struct lttng_live_stream_iterator {
         * The current message produced by this live stream iterator. Owned by
         * this.
         */
-       bt_message *current_msg;
+       const bt_message *current_msg;
 
        /* Timestamp in nanoseconds of the current message (current_msg). */
        int64_t current_msg_ts_ns;
This page took 0.029134 seconds and 4 git commands to generate.