From cad707e2548d7c9ea8501f12aec7ed28eaaf7975 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 4 Nov 2019 16:48:15 -0500 Subject: [PATCH] ctf: const-ify a few bt_message parameters 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 --- src/plugins/ctf/common/msg-iter/msg-iter.c | 2 +- src/plugins/ctf/common/msg-iter/msg-iter.h | 2 +- src/plugins/ctf/fs-src/data-stream-file.c | 2 +- src/plugins/ctf/fs-src/data-stream-file.h | 2 +- src/plugins/ctf/fs-src/fs.c | 6 +----- src/plugins/ctf/lttng-live/lttng-live.c | 12 ++++++------ src/plugins/ctf/lttng-live/lttng-live.h | 2 +- 7 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/plugins/ctf/common/msg-iter/msg-iter.c b/src/plugins/ctf/common/msg-iter/msg-iter.c index 5c99aed1..c094acc4 100644 --- a/src/plugins/ctf/common/msg-iter/msg-iter.c +++ b/src/plugins/ctf/common/msg-iter/msg-iter.c @@ -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; diff --git a/src/plugins/ctf/common/msg-iter/msg-iter.h b/src/plugins/ctf/common/msg-iter/msg-iter.h index a5969f44..cc5313b1 100644 --- a/src/plugins/ctf/common/msg-iter/msg-iter.h +++ b/src/plugins/ctf/common/msg-iter/msg-iter.h @@ -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; diff --git a/src/plugins/ctf/fs-src/data-stream-file.c b/src/plugins/ctf/fs-src/data-stream-file.c index 6867529e..b8091f66 100644 --- a/src/plugins/ctf/fs-src/data-stream-file.c +++ b/src/plugins/ctf/fs-src/data-stream-file.c @@ -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; diff --git a/src/plugins/ctf/fs-src/data-stream-file.h b/src/plugins/ctf/fs-src/data-stream-file.h index ff9643b5..66a6c436 100644 --- a/src/plugins/ctf/fs-src/data-stream-file.h +++ b/src/plugins/ctf/fs-src/data-stream-file.h @@ -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( diff --git a/src/plugins/ctf/fs-src/fs.c b/src/plugins/ctf/fs-src/fs.c index 0530f015..eb8dbe53 100644 --- a/src/plugins/ctf/fs-src/fs.c +++ b/src/plugins/ctf/fs-src/fs.c @@ -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: { diff --git a/src/plugins/ctf/lttng-live/lttng-live.c b/src/plugins/ctf/lttng-live/lttng-live.c index 77dd590d..b8f3c8c2 100644 --- a/src/plugins/ctf/lttng-live/lttng-live.c +++ b/src/plugins/ctf/lttng-live/lttng-live.c @@ -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); diff --git a/src/plugins/ctf/lttng-live/lttng-live.h b/src/plugins/ctf/lttng-live/lttng-live.h index ad01c7dd..a6e1590d 100644 --- a/src/plugins/ctf/lttng-live/lttng-live.h +++ b/src/plugins/ctf/lttng-live/lttng-live.h @@ -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; -- 2.34.1