From 07c4863ff7f9ce15da078099db51e74e56c956be Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 20 Jun 2024 17:31:20 +0000 Subject: [PATCH] clang-tidy: apply suggested fixes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Apply FixIts proposed by clang-tidy (mostly missing 'const' qualifiers). Change-Id: Ic616ddf6e826ee787c048de3f18aec18f9481532 Signed-off-by: Jérémie Galarneau --- .clang-format | 1 + .../notification-client.cpp | 8 +- include/lttng/channel.h | 2 +- include/lttng/domain.h | 2 +- include/lttng/event.h | 6 +- include/lttng/health-internal.hpp | 2 +- src/bin/lttng-crash/lttng-crash.cpp | 4 +- src/bin/lttng-relayd/connection.cpp | 4 +- src/bin/lttng-relayd/ctf-trace.cpp | 8 +- src/bin/lttng-relayd/health-relayd.cpp | 4 +- src/bin/lttng-relayd/index.cpp | 14 +-- src/bin/lttng-relayd/live.cpp | 14 +-- src/bin/lttng-relayd/main.cpp | 14 +-- src/bin/lttng-relayd/session.cpp | 12 +- .../lttng-relayd/sessiond-trace-chunks.cpp | 8 +- src/bin/lttng-relayd/stream.cpp | 10 +- src/bin/lttng-relayd/viewer-session.cpp | 6 +- src/bin/lttng-relayd/viewer-stream.cpp | 8 +- src/bin/lttng-sessiond/action-executor.cpp | 10 +- src/bin/lttng-sessiond/agent-thread.cpp | 4 +- src/bin/lttng-sessiond/agent.cpp | 20 +-- src/bin/lttng-sessiond/buffer-registry.cpp | 14 +-- src/bin/lttng-sessiond/channel.cpp | 2 +- src/bin/lttng-sessiond/clear.cpp | 2 +- src/bin/lttng-sessiond/client.cpp | 10 +- src/bin/lttng-sessiond/cmd.cpp | 50 ++++---- src/bin/lttng-sessiond/condition-internal.cpp | 3 +- src/bin/lttng-sessiond/consumer.cpp | 14 +-- src/bin/lttng-sessiond/context.cpp | 2 +- .../ctf2-trace-class-visitor.cpp | 2 +- src/bin/lttng-sessiond/ctl-utils.hpp | 2 +- src/bin/lttng-sessiond/dispatch.cpp | 8 +- .../event-notifier-error-accounting.cpp | 18 +-- src/bin/lttng-sessiond/event.cpp | 16 +-- src/bin/lttng-sessiond/kernel-consumer.cpp | 6 +- src/bin/lttng-sessiond/kernel.cpp | 24 ++-- src/bin/lttng-sessiond/lttng-syscall.cpp | 4 +- src/bin/lttng-sessiond/manage-kernel.cpp | 2 +- src/bin/lttng-sessiond/modprobe.cpp | 2 +- .../notification-thread-events.cpp | 80 ++++++------ .../lttng-sessiond/notification-thread.cpp | 6 +- src/bin/lttng-sessiond/rotation-thread.cpp | 12 +- src/bin/lttng-sessiond/save.cpp | 10 +- src/bin/lttng-sessiond/session.cpp | 22 ++-- src/bin/lttng-sessiond/sessiond-config.cpp | 2 +- src/bin/lttng-sessiond/snapshot.cpp | 6 +- src/bin/lttng-sessiond/trace-ust.cpp | 20 +-- src/bin/lttng-sessiond/tracker.cpp | 10 +- .../tsdl-trace-class-visitor.cpp | 2 +- src/bin/lttng-sessiond/ust-app.cpp | 116 +++++++++--------- src/bin/lttng-sessiond/ust-consumer.cpp | 2 +- .../lttng-sessiond/ust-registry-channel.cpp | 4 +- .../ust-registry-session-pid.cpp | 2 +- .../ust-registry-session-uid.cpp | 2 +- .../lttng-sessiond/ust-registry-session.cpp | 22 ++-- src/bin/lttng/commands/add_trigger.cpp | 7 +- src/bin/lttng/commands/create.cpp | 2 +- src/bin/lttng/commands/destroy.cpp | 2 +- src/bin/lttng/commands/list_triggers.cpp | 2 +- src/bin/lttng/loglevel.cpp | 16 +-- src/bin/lttng/utils.cpp | 18 +-- src/common/argpar-utils/argpar-utils.cpp | 4 +- src/common/bytecode/bytecode.cpp | 6 +- src/common/compat/directory-handle.cpp | 4 +- src/common/conditions/buffer-usage.cpp | 2 +- src/common/conditions/event-rule-matches.cpp | 2 +- .../conditions/session-consumed-size.cpp | 2 +- src/common/conditions/session-rotation.cpp | 9 +- src/common/consumer/consumer-stream.cpp | 10 +- src/common/consumer/consumer-timer.cpp | 6 +- src/common/consumer/consumer.cpp | 84 ++++++------- src/common/dynamic-buffer.cpp | 2 +- src/common/error-query.cpp | 12 +- src/common/evaluation.cpp | 2 +- src/common/event-rule/event-rule.cpp | 2 +- src/common/event-rule/kernel-kprobe.cpp | 2 +- src/common/event.cpp | 18 +-- src/common/fd-tracker/fd-tracker.cpp | 6 +- src/common/fd-tracker/inode.cpp | 6 +- src/common/filter/filter-ast.hpp | 2 +- src/common/hashtable/hashtable.cpp | 22 ++-- src/common/index/index.cpp | 2 +- src/common/ini-config/ini-config.cpp | 2 +- src/common/ini-config/ini.cpp | 2 +- .../kernel-consumer/kernel-consumer.cpp | 42 +++---- src/common/log-level-rule.cpp | 4 +- src/common/lttng-elf.cpp | 6 +- src/common/pthread-lock.hpp | 4 +- src/common/reference.hpp | 2 +- src/common/runas.cpp | 4 +- src/common/sessiond-comm/inet.cpp | 2 +- src/common/sessiond-comm/inet6.cpp | 2 +- src/common/sessiond-comm/sessiond-comm.cpp | 2 +- src/common/string-utils/string-utils.cpp | 8 +- src/common/time.cpp | 6 +- src/common/trace-chunk.cpp | 16 +-- src/common/unix.cpp | 12 +- src/common/urcu.hpp | 2 +- src/common/userspace-probe.cpp | 6 +- src/common/ust-consumer/ust-consumer.cpp | 46 +++---- src/common/utils.cpp | 2 +- src/common/utils.hpp | 4 +- src/lib/lttng-ctl/clear.cpp | 2 +- src/lib/lttng-ctl/destruction-handle.cpp | 2 +- src/lib/lttng-ctl/lttng-ctl.cpp | 8 +- src/vendor/fmt/core.h | 2 +- tests/regression/kernel/select_poll_epoll.cpp | 68 +++++----- .../tools/trigger/name/trigger_name.cpp | 2 +- .../trigger/utils/notification-client.cpp | 39 +++--- tests/unit/test_action.cpp | 14 +-- tests/unit/test_buffer_view.cpp | 4 +- tests/unit/test_fd_tracker.cpp | 8 +- tests/unit/test_log_level_rule.cpp | 4 +- tests/unit/test_payload.cpp | 6 +- tests/unit/test_rate_policy.cpp | 8 +- ...elayd_backward_compat_group_by_session.cpp | 2 +- tests/unit/test_unix_socket.cpp | 2 +- tests/unit/test_utils_expand_path.cpp | 2 +- .../bt2_plugins/event_name/event_name.cpp | 12 +- .../bt2_plugins/field_stats/field_stats.cpp | 9 +- .../01-tp-before-define.cpp | 8 +- .../02-define-tp.cpp | 24 ++-- .../03-tp-after-define.cpp | 8 +- .../04-tp-provider.cpp | 24 ++-- .../05-tp-after-provider.cpp | 8 +- .../gen-ust-events-constructor/main-a.cpp | 14 +-- .../gen-ust-events-constructor/main.cpp | 14 +-- .../gen-ust-events-constructor/obj-a.h | 4 +- .../testapp/gen-ust-events-constructor/obj.h | 4 +- .../testapp/gen-ust-events/gen-ust-events.cpp | 4 +- .../gen-ust-nevents/gen-ust-nevents.cpp | 4 +- tests/utils/xml-utils/extract_xml.cpp | 2 +- 132 files changed, 700 insertions(+), 698 deletions(-) diff --git a/.clang-format b/.clang-format index 8fcee64f8..604c57d0c 100644 --- a/.clang-format +++ b/.clang-format @@ -103,4 +103,5 @@ SpacesInSquareBrackets: false Standard: Cpp11 TabWidth: 8 UseTab: Always +QualifierAlignment: Left ... diff --git a/doc/examples/trigger-condition-event-matches/notification-client.cpp b/doc/examples/trigger-condition-event-matches/notification-client.cpp index 05c7387c2..f92e1e21f 100644 --- a/doc/examples/trigger-condition-event-matches/notification-client.cpp +++ b/doc/examples/trigger-condition-event-matches/notification-client.cpp @@ -101,7 +101,7 @@ static void print_one_event_expr(const struct lttng_event_expr *event_expr) static bool action_group_contains_notify(const struct lttng_action *action_group) { unsigned int i, count; - enum lttng_action_status status = lttng_action_list_get_count(action_group, &count); + const lttng_action_status status = lttng_action_list_get_count(action_group, &count); if (status != LTTNG_ACTION_STATUS_OK) { printf("Failed to get action count from action group\n"); @@ -434,9 +434,9 @@ int main(int argc, char **argv) continue; } - if (!((action_type == LTTNG_ACTION_TYPE_LIST && - action_group_contains_notify(action)) || - action_type == LTTNG_ACTION_TYPE_NOTIFY)) { + if ((action_type != LTTNG_ACTION_TYPE_LIST || + !action_group_contains_notify(action)) && + action_type != LTTNG_ACTION_TYPE_NOTIFY) { printf("The action of trigger \"%s\" is not \"notify\", skipping.\n", trigger_name); continue; diff --git a/include/lttng/channel.h b/include/lttng/channel.h index a6a6f04fc..58917ae04 100644 --- a/include/lttng/channel.h +++ b/include/lttng/channel.h @@ -23,7 +23,7 @@ extern "C" { * * The structures should be initialized to zero before use. */ -#define LTTNG_CHANNEL_ATTR_PADDING1 LTTNG_SYMBOL_NAME_LEN + 12 +#define LTTNG_CHANNEL_ATTR_PADDING1 (LTTNG_SYMBOL_NAME_LEN + 12) /*! @brief diff --git a/include/lttng/domain.h b/include/lttng/domain.h index 26e9da932..da19ebf1c 100644 --- a/include/lttng/domain.h +++ b/include/lttng/domain.h @@ -65,7 +65,7 @@ enum lttng_buffer_type { * The structures should be initialized to zero before use. */ #define LTTNG_DOMAIN_PADDING1 12 -#define LTTNG_DOMAIN_PADDING2 LTTNG_SYMBOL_NAME_LEN + 32 +#define LTTNG_DOMAIN_PADDING2 (LTTNG_SYMBOL_NAME_LEN + 32) /*! @brief diff --git a/include/lttng/event.h b/include/lttng/event.h index e4ee28988..64bd2ad23 100644 --- a/include/lttng/event.h +++ b/include/lttng/event.h @@ -994,7 +994,7 @@ struct lttng_event_perf_counter_ctx { }; #define LTTNG_EVENT_CONTEXT_PADDING1 16 -#define LTTNG_EVENT_CONTEXT_PADDING2 LTTNG_SYMBOL_NAME_LEN + 32 +#define LTTNG_EVENT_CONTEXT_PADDING2 (LTTNG_SYMBOL_NAME_LEN + 32) /*! @brief @@ -1155,7 +1155,7 @@ struct lttng_event_function_attr { * The structures should be initialized to zero before use. */ #define LTTNG_EVENT_PADDING1 12 -#define LTTNG_EVENT_PADDING2 LTTNG_SYMBOL_NAME_LEN + 32 +#define LTTNG_EVENT_PADDING2 (LTTNG_SYMBOL_NAME_LEN + 32) /*! @brief @@ -1393,7 +1393,7 @@ struct lttng_event { attr; }; -#define LTTNG_EVENT_FIELD_PADDING LTTNG_SYMBOL_NAME_LEN + 32 +#define LTTNG_EVENT_FIELD_PADDING (LTTNG_SYMBOL_NAME_LEN + 32) /*! @brief diff --git a/include/lttng/health-internal.hpp b/include/lttng/health-internal.hpp index eee164cb1..ac260dcf8 100644 --- a/include/lttng/health-internal.hpp +++ b/include/lttng/health-internal.hpp @@ -26,7 +26,7 @@ #define HEALTH_POLL_VALUE (1UL << 0) #define HEALTH_CODE_VALUE (1UL << 1) -#define HEALTH_IS_IN_POLL(x) ((x) &HEALTH_POLL_VALUE) +#define HEALTH_IS_IN_POLL(x) ((x) & HEALTH_POLL_VALUE) struct health_app; diff --git a/src/bin/lttng-crash/lttng-crash.cpp b/src/bin/lttng-crash/lttng-crash.cpp index d4e41e033..51b970e43 100644 --- a/src/bin/lttng-crash/lttng-crash.cpp +++ b/src/bin/lttng-crash/lttng-crash.cpp @@ -72,7 +72,7 @@ enum lttng_crash_type { /* LTTng ring buffer defines (copied) */ -#define HALF_ULONG_BITS(wl) (((wl) *CHAR_BIT) >> 1) +#define HALF_ULONG_BITS(wl) (((wl) * CHAR_BIT) >> 1) #define SB_ID_OFFSET_SHIFT(wl) (HALF_ULONG_BITS(wl) + 1) #define SB_ID_OFFSET_COUNT(wl) (1UL << SB_ID_OFFSET_SHIFT(wl)) @@ -197,7 +197,7 @@ static struct option long_options[] = { static void usage() { - int ret = utils_show_help(1, "lttng-crash", help_msg); + const int ret = utils_show_help(1, "lttng-crash", help_msg); if (ret) { ERR("Cannot show --help for `lttng-crash`"); diff --git a/src/bin/lttng-relayd/connection.cpp b/src/bin/lttng-relayd/connection.cpp index 2de3abe2d..9a3dc1dc8 100644 --- a/src/bin/lttng-relayd/connection.cpp +++ b/src/bin/lttng-relayd/connection.cpp @@ -30,7 +30,7 @@ struct relay_connection *connection_get_by_sock(struct lttng_ht *relay_connectio LTTNG_ASSERT(sock >= 0); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; lttng_ht_lookup(relay_connections_ht, (void *) ((unsigned long) sock), &iter); node = lttng_ht_iter_get_node(&iter); if (!node) { @@ -150,7 +150,7 @@ static void connection_release(struct urcu_ref *ref) void connection_put(struct relay_connection *conn) { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; urcu_ref_put(&conn->ref, connection_release); } diff --git a/src/bin/lttng-relayd/ctf-trace.cpp b/src/bin/lttng-relayd/ctf-trace.cpp index 81c5a7707..f6a4b2dcd 100644 --- a/src/bin/lttng-relayd/ctf-trace.cpp +++ b/src/bin/lttng-relayd/ctf-trace.cpp @@ -150,7 +150,7 @@ struct ctf_trace *ctf_trace_get_by_path_or_create(struct relay_session *session, struct lttng_ht_iter iter; struct ctf_trace *trace = nullptr; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; lttng_ht_lookup(session->ctf_traces_ht, subpath, &iter); node = lttng_ht_iter_get_node(&iter); if (!node) { @@ -171,7 +171,7 @@ end: void ctf_trace_put(struct ctf_trace *trace) { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; urcu_ref_put(&trace->ref, ctf_trace_release); } @@ -179,7 +179,7 @@ int ctf_trace_close(struct ctf_trace *trace) { struct relay_stream *stream; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_list_for_each_entry_rcu(stream, &trace->stream_list, stream_node) { /* @@ -199,7 +199,7 @@ struct relay_viewer_stream *ctf_trace_get_viewer_metadata_stream(struct ctf_trac { struct relay_viewer_stream *vstream; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; vstream = rcu_dereference(trace->viewer_metadata_stream); if (!vstream) { goto end; diff --git a/src/bin/lttng-relayd/health-relayd.cpp b/src/bin/lttng-relayd/health-relayd.cpp index d1b619d39..614c7f7d9 100644 --- a/src/bin/lttng-relayd/health-relayd.cpp +++ b/src/bin/lttng-relayd/health-relayd.cpp @@ -76,7 +76,7 @@ static int create_lttng_rundir_with_perm(const char *rundir) ret = 0; } } else if (ret == 0) { - int is_root = !getuid(); + const int is_root = !getuid(); if (is_root) { gid_t gid; @@ -210,7 +210,7 @@ end: static int accept_unix_socket(void *data, int *out_fd) { int ret; - int accepting_sock = *((int *) data); + const int accepting_sock = *((int *) data); ret = lttcomm_accept_unix_sock(accepting_sock); if (ret < 0) { diff --git a/src/bin/lttng-relayd/index.cpp b/src/bin/lttng-relayd/index.cpp index 7fd94ac43..e47f647f1 100644 --- a/src/bin/lttng-relayd/index.cpp +++ b/src/bin/lttng-relayd/index.cpp @@ -120,7 +120,7 @@ struct relay_index *relay_index_get_by_id_or_create(struct relay_stream *stream, stream->stream_handle, net_seq_num); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; lttng_ht_lookup(stream->indexes_ht, &net_seq_num, &iter); node = lttng_ht_iter_get_node(&iter); if (node) { @@ -249,7 +249,7 @@ void relay_index_put(struct relay_index *index) /* * Ensure existence of index->lock for index unlock. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* * Index lock ensures that concurrent test and update of stream * ref is atomic. @@ -305,7 +305,7 @@ void relay_index_close_all(struct relay_stream *stream) struct lttng_ht_iter iter; struct relay_index *index; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (stream->indexes_ht->ht, &iter.iter, index, index_n.node) { /* Put self-ref from index. */ @@ -318,7 +318,7 @@ void relay_index_close_partial_fd(struct relay_stream *stream) struct lttng_ht_iter iter; struct relay_index *index; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (stream->indexes_ht->ht, &iter.iter, index, index_n.node) { if (!index->index_file) { @@ -339,7 +339,7 @@ uint64_t relay_index_find_last(struct relay_stream *stream) struct relay_index *index; uint64_t net_seq_num = -1ULL; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (stream->indexes_ht->ht, &iter.iter, index, index_n.node) { if (net_seq_num == -1ULL || index->index_n.key > net_seq_num) { @@ -390,7 +390,7 @@ int relay_index_switch_all_files(struct relay_stream *stream) struct relay_index *index; int ret = 0; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (stream->indexes_ht->ht, &iter.iter, index, index_n.node) { ret = relay_index_switch_file( @@ -424,7 +424,7 @@ int relay_index_set_control_data(struct relay_index *index, index->index_data.stream_instance_id = htobe64(data->stream_instance_id); index->index_data.packet_seq_num = htobe64(data->packet_seq_num); } else { - uint64_t unset_value = -1ULL; + const uint64_t unset_value = -1ULL; index->index_data.stream_instance_id = htobe64(unset_value); index->index_data.packet_seq_num = htobe64(unset_value); diff --git a/src/bin/lttng-relayd/live.cpp b/src/bin/lttng-relayd/live.cpp index 699778d0e..a100433b4 100644 --- a/src/bin/lttng-relayd/live.cpp +++ b/src/bin/lttng-relayd/live.cpp @@ -245,7 +245,7 @@ static int check_new_streams(struct relay_connection *conn) } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_list_for_each_entry_rcu( session, &conn->viewer_session->session_list, viewer_session_node) { @@ -282,7 +282,7 @@ send_viewer_streams(struct lttcomm_sock *sock, uint64_t session_id, unsigned int struct relay_viewer_stream *vstream; { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( viewer_streams_ht->ht, &iter.iter, vstream, stream_n.node) { @@ -379,7 +379,7 @@ static int make_viewer_streams(struct relay_session *relay_session, * used for a the given session id only. */ { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( relay_session->ctf_traces_ht->ht, &iter.iter, ctf_trace, node.node) { @@ -1061,7 +1061,7 @@ static int viewer_list_sessions(struct relay_connection *conn) } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (sessions_ht->ht, &iter.iter, session, session_n.node) { struct lttng_viewer_session *send_session; @@ -1076,7 +1076,7 @@ static int viewer_list_sessions(struct relay_connection *conn) if (count >= buf_count) { struct lttng_viewer_session *newbuf; - uint32_t new_buf_count = buf_count << 1; + const uint32_t new_buf_count = buf_count << 1; newbuf = (lttng_viewer_session *) realloc( send_session_buf, @@ -2531,7 +2531,7 @@ static void live_relay_unknown_command(struct relay_connection *conn) static int process_control(struct lttng_viewer_cmd *recv_hdr, struct relay_connection *conn) { int ret = 0; - lttng_viewer_command cmd = (lttng_viewer_command) be32toh(recv_hdr->cmd); + const lttng_viewer_command cmd = (lttng_viewer_command) be32toh(recv_hdr->cmd); /* * Make sure we've done the version check before any command other then @@ -2763,7 +2763,7 @@ error: /* Cleanup remaining connection object. */ { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( viewer_connections_ht->ht, &iter.iter, destroy_conn, sock_n.node) { diff --git a/src/bin/lttng-relayd/main.cpp b/src/bin/lttng-relayd/main.cpp index ea0ed2119..87b623895 100644 --- a/src/bin/lttng-relayd/main.cpp +++ b/src/bin/lttng-relayd/main.cpp @@ -1519,7 +1519,7 @@ static void publish_connection_local_streams(struct relay_connection *conn) * session lock. */ pthread_mutex_lock(&session->lock); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_list_for_each_entry_rcu(stream, &session->recv_list, recv_node) { stream_publish(stream); @@ -2227,7 +2227,7 @@ static int relay_begin_data_pending(const struct lttcomm_relayd_hdr *recv_hdr, * the right session_id. */ { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (relay_streams_ht->ht, &iter.iter, stream, node.node) { if (!stream_get(stream)) { @@ -2306,7 +2306,7 @@ static int relay_end_data_pending(const struct lttcomm_relayd_hdr *recv_hdr __at * flag is set. */ { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (relay_streams_ht->ht, &iter.iter, stream, node.node) { if (!stream_get(stream)) { @@ -4079,7 +4079,7 @@ restart: if (last_seen_data_fd >= 0) { for (i = 0; i < nb_fd; i++) { - int pollfd = LTTNG_POLL_GETFD(&events, i); + const int pollfd = LTTNG_POLL_GETFD(&events, i); health_code_update(); @@ -4093,8 +4093,8 @@ restart: /* Process data connection. */ for (i = idx + 1; i < nb_fd; i++) { /* Fetch the poll data. */ - uint32_t revents = LTTNG_POLL_GETEV(&events, i); - int pollfd = LTTNG_POLL_GETFD(&events, i); + const uint32_t revents = LTTNG_POLL_GETEV(&events, i); + const int pollfd = LTTNG_POLL_GETFD(&events, i); struct relay_connection *data_conn; health_code_update(); @@ -4174,7 +4174,7 @@ exit: error: /* Cleanup remaining connection object. */ { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( relay_connections_ht->ht, &iter.iter, destroy_conn, sock_n.node) { diff --git a/src/bin/lttng-relayd/session.cpp b/src/bin/lttng-relayd/session.cpp index 19f1936f2..c199efcd1 100644 --- a/src/bin/lttng-relayd/session.cpp +++ b/src/bin/lttng-relayd/session.cpp @@ -455,7 +455,7 @@ struct relay_session *session_get_by_id(uint64_t id) struct lttng_ht_node_u64 *node; struct lttng_ht_iter iter; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; lttng_ht_lookup(sessions_ht, &id, &iter); node = lttng_ht_iter_get_node(&iter); if (!node) { @@ -503,7 +503,7 @@ bool session_has_ongoing_rotation(const struct relay_session *session) * originate from the same session daemon session. */ { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( sessions_ht->ht, &iter.iter, iterated_session, session_n.node) { @@ -614,7 +614,7 @@ void session_put(struct relay_session *session) if (!session) { return; } - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; urcu_ref_put(&session->ref, session_release); } @@ -633,7 +633,7 @@ int session_close(struct relay_session *session) pthread_mutex_unlock(&session->lock); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (session->ctf_traces_ht->ht, &iter.iter, trace, node.node) { ret = ctf_trace_close(trace); @@ -661,7 +661,7 @@ end: int session_abort(struct relay_session *session) { - int ret = 0; + const int ret = 0; if (!session) { return 0; @@ -684,7 +684,7 @@ void print_sessions() } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (sessions_ht->ht, &iter.iter, session, session_n.node) { if (!session_get(session)) { diff --git a/src/bin/lttng-relayd/sessiond-trace-chunks.cpp b/src/bin/lttng-relayd/sessiond-trace-chunks.cpp index 2326878fb..cf2cfe601 100644 --- a/src/bin/lttng-relayd/sessiond-trace-chunks.cpp +++ b/src/bin/lttng-relayd/sessiond-trace-chunks.cpp @@ -113,7 +113,7 @@ static void trace_chunk_registry_ht_element_release(struct urcu_ref *ref) DBG("Destroying trace chunk registry associated to sessiond {%s}", uuid_str); if (element->sessiond_trace_chunk_registry) { /* Unpublish. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_del(element->sessiond_trace_chunk_registry->ht, &element->ht_node); element->sessiond_trace_chunk_registry = nullptr; } @@ -146,7 +146,7 @@ trace_chunk_registry_ht_element_find(struct sessiond_trace_chunk_registry *sessi struct cds_lfht_node *node; struct cds_lfht_iter iter; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_lookup(sessiond_registry->ht, trace_chunk_registry_ht_key_hash(key), trace_chunk_registry_ht_key_match, @@ -202,7 +202,7 @@ trace_chunk_registry_ht_element_create(struct sessiond_trace_chunk_registry *ses * Keep the rcu read lock is held accross all attempts * purely for efficiency reasons. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; while (true) { struct cds_lfht_node *published_node; struct trace_chunk_registry_ht_element *published_element; @@ -274,7 +274,7 @@ error: void sessiond_trace_chunk_registry_destroy(struct sessiond_trace_chunk_registry *sessiond_registry) { - int ret = cds_lfht_destroy(sessiond_registry->ht, nullptr); + const int ret = cds_lfht_destroy(sessiond_registry->ht, nullptr); LTTNG_ASSERT(!ret); free(sessiond_registry); diff --git a/src/bin/lttng-relayd/stream.cpp b/src/bin/lttng-relayd/stream.cpp index 5390c49bb..9b592b8e0 100644 --- a/src/bin/lttng-relayd/stream.cpp +++ b/src/bin/lttng-relayd/stream.cpp @@ -48,7 +48,7 @@ struct relay_stream *stream_get_by_id(uint64_t stream_id) struct lttng_ht_iter iter; struct relay_stream *stream = nullptr; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; lttng_ht_lookup(relay_streams_ht, &stream_id, &iter); node = lttng_ht_iter_get_node(&iter); if (!node) { @@ -473,7 +473,7 @@ end: */ static int try_rotate_stream_index(struct relay_stream *stream) { - int ret = 0; + const int ret = 0; if (!stream->ongoing_rotation.is_set) { /* No rotation expected. */ @@ -807,7 +807,7 @@ static void stream_release(struct urcu_ref *ref) void stream_put(struct relay_stream *stream) { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; LTTNG_ASSERT(stream->ref.refcount != 0); /* * Wait until we have processed all the stream packets before @@ -1312,7 +1312,7 @@ static void print_stream_indexes(struct relay_stream *stream) struct relay_index *index; { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (stream->indexes_ht->ht, &iter.iter, index, index_n.node) { DBG("index %p net_seq_num %" PRIu64 " refcount %ld" @@ -1368,7 +1368,7 @@ void print_relay_streams() } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (relay_streams_ht->ht, &iter.iter, stream, node.node) { if (!stream_get(stream)) { diff --git a/src/bin/lttng-relayd/viewer-session.cpp b/src/bin/lttng-relayd/viewer-session.cpp index 45fa2dcac..176cdc525 100644 --- a/src/bin/lttng-relayd/viewer-session.cpp +++ b/src/bin/lttng-relayd/viewer-session.cpp @@ -151,7 +151,7 @@ void viewer_session_close_one_session(struct relay_viewer_session *vsession, * vstream per session. */ { - lttng::urcu::read_lock_guard read_guard; + const lttng::urcu::read_lock_guard read_guard; cds_lfht_for_each_entry ( viewer_streams_ht->ht, &iter.iter, vstream, stream_n.node) { @@ -183,7 +183,7 @@ void viewer_session_close(struct relay_viewer_session *vsession) struct relay_session *session; { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_list_for_each_entry_rcu(session, &vsession->session_list, viewer_session_node) { @@ -210,7 +210,7 @@ int viewer_session_is_attached(struct relay_viewer_session *vsession, struct rel } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_list_for_each_entry_rcu(iter, &vsession->session_list, viewer_session_node) { if (session == iter) { diff --git a/src/bin/lttng-relayd/viewer-stream.cpp b/src/bin/lttng-relayd/viewer-stream.cpp index 8830dae7a..6ea7d8898 100644 --- a/src/bin/lttng-relayd/viewer-stream.cpp +++ b/src/bin/lttng-relayd/viewer-stream.cpp @@ -263,7 +263,7 @@ struct relay_viewer_stream *viewer_stream_get_by_id(uint64_t id) struct lttng_ht_iter iter; struct relay_viewer_stream *vstream = nullptr; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; lttng_ht_lookup(viewer_streams_ht, &id, &iter); node = lttng_ht_iter_get_node(&iter); if (!node) { @@ -280,7 +280,7 @@ end: void viewer_stream_put(struct relay_viewer_stream *vstream) { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; urcu_ref_put(&vstream->ref, viewer_stream_release); } @@ -348,7 +348,7 @@ int viewer_stream_rotate(struct relay_viewer_stream *vstream) if (tracefile_array_seq_in_file(stream->tfa, new_id, vstream->index_sent_seqcount)) { vstream->current_tracefile_id = new_id; } else { - uint64_t seq_tail = tracefile_array_get_seq_tail(stream->tfa); + const uint64_t seq_tail = tracefile_array_get_seq_tail(stream->tfa); /* * This can only be reached on overwrite, which implies there @@ -378,7 +378,7 @@ void print_viewer_streams() } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( viewer_streams_ht->ht, &iter.iter, vstream, stream_n.node) { diff --git a/src/bin/lttng-sessiond/action-executor.cpp b/src/bin/lttng-sessiond/action-executor.cpp index aa8be1fcf..6f75b07b4 100644 --- a/src/bin/lttng-sessiond/action-executor.cpp +++ b/src/bin/lttng-sessiond/action-executor.cpp @@ -289,7 +289,7 @@ static int action_executor_start_session_handler(struct action_executor *executo enum lttng_error_code cmd_ret; struct lttng_action *action = item->action; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; action_status = lttng_action_start_session_get_session_name(action, &session_name); if (action_status != LTTNG_ACTION_STATUS_OK) { @@ -379,7 +379,7 @@ static int action_executor_stop_session_handler(struct action_executor *executor enum lttng_error_code cmd_ret; struct lttng_action *action = item->action; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; action_status = lttng_action_stop_session_get_session_name(action, &session_name); if (action_status != LTTNG_ACTION_STATUS_OK) { @@ -470,7 +470,7 @@ static int action_executor_rotate_session_handler(struct action_executor *execut enum lttng_error_code cmd_ret; struct lttng_action *action = item->action; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; action_status = lttng_action_rotate_session_get_session_name(action, &session_name); if (action_status != LTTNG_ACTION_STATUS_OK) { @@ -572,7 +572,7 @@ static int action_executor_snapshot_session_handler(struct action_executor *exec default_snapshot_output.max_size = UINT64_MAX; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* * Validate if, at the moment the action was queued, the target session @@ -979,7 +979,7 @@ static int add_action_to_subitem_array(struct lttng_action *action, struct lttng_dynamic_array *subitems) { int ret = 0; - enum lttng_action_type type = lttng_action_get_type(action); + const lttng_action_type type = lttng_action_get_type(action); const char *session_name = nullptr; enum lttng_action_status status; struct action_work_subitem subitem = { diff --git a/src/bin/lttng-sessiond/agent-thread.cpp b/src/bin/lttng-sessiond/agent-thread.cpp index 036b3dc60..8925db4f9 100644 --- a/src/bin/lttng-sessiond/agent-thread.cpp +++ b/src/bin/lttng-sessiond/agent-thread.cpp @@ -76,7 +76,7 @@ static void update_agent_app(const struct agent_app *app) if (session->ust_session) { const struct agent *agt; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; agt = trace_ust_find_agent(session->ust_session, app->domain); if (agt) { agent_update(agt, app); @@ -91,7 +91,7 @@ static void update_agent_app(const struct agent_app *app) * We are protected against the addition of new events by the session * list lock being held. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( the_trigger_agents_ht_by_domain->ht, &iter.iter, trigger_agent, node.node) { diff --git a/src/bin/lttng-sessiond/agent.cpp b/src/bin/lttng-sessiond/agent.cpp index 5c080ca51..48968c44b 100644 --- a/src/bin/lttng-sessiond/agent.cpp +++ b/src/bin/lttng-sessiond/agent.cpp @@ -684,7 +684,7 @@ int agent_enable_event(struct agent_event *event, enum lttng_domain_type domain) LTTNG_ASSERT(event); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( the_agent_apps_ht_by_sock->ht, &iter.iter, app, node.node) { @@ -757,7 +757,7 @@ int agent_enable_context(const struct lttng_event_context *ctx, enum lttng_domai } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( the_agent_apps_ht_by_sock->ht, &iter.iter, app, node.node) { @@ -817,7 +817,7 @@ int agent_disable_event(struct agent_event *event, enum lttng_domain_type domain } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( the_agent_apps_ht_by_sock->ht, &iter.iter, app, node.node) { @@ -857,7 +857,7 @@ static int disable_context(struct agent_app_ctx *ctx, enum lttng_domain_type dom DBG2("Disabling agent application context %s:%s", ctx->provider_name, ctx->ctx_name); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( the_agent_apps_ht_by_sock->ht, &iter.iter, app, node.node) { @@ -902,7 +902,7 @@ int agent_list_events(struct lttng_event **events, enum lttng_domain_type domain } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( the_agent_apps_ht_by_sock->ht, &iter.iter, app, node.node) { @@ -1424,7 +1424,7 @@ void agent_destroy(struct agent *agt) DBG3("Agent destroy"); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (agt->events->ht, &iter.iter, node, node) { int ret; @@ -1479,7 +1479,7 @@ void agent_destroy_app_by_sock(int sock) * happen. The hash table deletion is ONLY done through this call when the * main sessiond thread is torn down. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; app = agent_find_app_by_sock(sock); LTTNG_ASSERT(app); @@ -1503,7 +1503,7 @@ void agent_app_ht_clean() } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (the_agent_apps_ht_by_sock->ht, &iter.iter, node, node) { struct agent_app *app; @@ -1539,7 +1539,7 @@ void agent_update(const struct agent *agt, const struct agent_app *app) * there is a serious code flow error. */ { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (agt->events->ht, &iter.iter, event, node.node) { /* Skip event if disabled. */ @@ -1596,7 +1596,7 @@ void agent_by_event_notifier_domain_ht_destroy() } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( the_trigger_agents_ht_by_domain->ht, &iter.iter, node, node) { diff --git a/src/bin/lttng-sessiond/buffer-registry.cpp b/src/bin/lttng-sessiond/buffer-registry.cpp index 8e241feb6..9885ed6c8 100644 --- a/src/bin/lttng-sessiond/buffer-registry.cpp +++ b/src/bin/lttng-sessiond/buffer-registry.cpp @@ -172,7 +172,7 @@ void buffer_reg_uid_add(struct buffer_reg_uid *reg) DBG3("Buffer registry per UID adding to global registry with id: %" PRIu64, reg->session_id); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; nodep = cds_lfht_add_unique( ht->ht, ht->hash_fct(reg, lttng_ht_seed), ht->match_fct, reg, ®->node.node); LTTNG_ASSERT(nodep == ®->node.node); @@ -298,7 +298,7 @@ void buffer_reg_pid_add(struct buffer_reg_pid *reg) DBG3("Buffer registry per PID adding to global registry with id: %" PRIu64, reg->session_id); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; lttng_ht_add_unique_u64(buffer_registry_pid, ®->node); } @@ -344,7 +344,7 @@ int buffer_reg_uid_consumer_channel_key(struct cds_list_head *buffer_reg_uid_lis int ret = -1; { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* * For the per-uid registry, we have to iterate since we don't have the @@ -443,7 +443,7 @@ void buffer_reg_channel_add(struct buffer_reg_session *session, struct buffer_re LTTNG_ASSERT(session); LTTNG_ASSERT(channel); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; lttng_ht_add_unique_u64(session->channels, &channel->node); } @@ -591,7 +591,7 @@ static void buffer_reg_session_destroy(struct buffer_reg_session *regp, /* Destroy all channels. */ { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (regp->channels->ht, &iter.iter, reg_chan, node.node) { ret = lttng_ht_del(regp->channels, &iter); @@ -624,7 +624,7 @@ void buffer_reg_uid_remove(struct buffer_reg_uid *regp) LTTNG_ASSERT(regp); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; iter.iter.node = ®p->node.node; ret = lttng_ht_del(buffer_registry_uid, &iter); LTTNG_ASSERT(!ret); @@ -671,7 +671,7 @@ void buffer_reg_uid_destroy(struct buffer_reg_uid *regp, struct consumer_output } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* Get the right socket from the consumer object. */ socket = consumer_find_socket_by_bitness(regp->bits_per_long, consumer); if (!socket) { diff --git a/src/bin/lttng-sessiond/channel.cpp b/src/bin/lttng-sessiond/channel.cpp index 4e5401295..77c073e2c 100644 --- a/src/bin/lttng-sessiond/channel.cpp +++ b/src/bin/lttng-sessiond/channel.cpp @@ -325,7 +325,7 @@ enum lttng_error_code channel_ust_create(struct ltt_ust_session *usess, struct lttng_channel *defattr = nullptr; enum lttng_domain_type domain = LTTNG_DOMAIN_UST; bool chan_published = false; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; LTTNG_ASSERT(usess); diff --git a/src/bin/lttng-sessiond/clear.cpp b/src/bin/lttng-sessiond/clear.cpp index b08cc8791..2e26c880a 100644 --- a/src/bin/lttng-sessiond/clear.cpp +++ b/src/bin/lttng-sessiond/clear.cpp @@ -182,7 +182,7 @@ int cmd_clear_session(const ltt_session::locked_ref& session, int *sock_fd) /* Flag session that trace should start automatically */ if (usess) { - int int_ret = ust_app_start_trace_all(usess); + const int int_ret = ust_app_start_trace_all(usess); if (int_ret < 0) { ret = LTTNG_ERR_UST_START_FAIL; diff --git a/src/bin/lttng-sessiond/client.cpp b/src/bin/lttng-sessiond/client.cpp index 89989f377..9052546c4 100644 --- a/src/bin/lttng-sessiond/client.cpp +++ b/src/bin/lttng-sessiond/client.cpp @@ -1284,7 +1284,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int *sock, int *sock_ if (need_tracing_session) { /* Create UST session if none exist. */ if ((*target_session)->ust_session == nullptr) { - lttng_domain domain = cmd_ctx->lsm.domain; + const lttng_domain domain = cmd_ctx->lsm.domain; ret = create_ust_session(*target_session, &domain); if (ret != LTTNG_OK) { goto error; @@ -1975,7 +1975,7 @@ skip_domain: { uint32_t snapshot_id; struct lttcomm_lttng_output_id reply; - lttng_snapshot_output output = cmd_ctx->lsm.u.snapshot_output.output; + const lttng_snapshot_output output = cmd_ctx->lsm.u.snapshot_output.output; ret = cmd_snapshot_add_output(*target_session, &output, &snapshot_id); if (ret != LTTNG_OK) { @@ -1991,7 +1991,7 @@ skip_domain: } case LTTCOMM_SESSIOND_COMMAND_SNAPSHOT_DEL_OUTPUT: { - lttng_snapshot_output output = cmd_ctx->lsm.u.snapshot_output.output; + const lttng_snapshot_output output = cmd_ctx->lsm.u.snapshot_output.output; ret = cmd_snapshot_del_output(*target_session, &output); break; } @@ -2016,7 +2016,7 @@ skip_domain: } case LTTCOMM_SESSIOND_COMMAND_SNAPSHOT_RECORD: { - lttng_snapshot_output output = cmd_ctx->lsm.u.snapshot_record.output; + const lttng_snapshot_output output = cmd_ctx->lsm.u.snapshot_record.output; ret = cmd_snapshot_record(*target_session, &output, 0); // RFC: set to zero // since it's ignored // by @@ -2029,7 +2029,7 @@ skip_domain: lttng_dynamic_buffer_init(&payload); - lttng::ctl::session_descriptor reply_session_descriptor = [cmd_ctx, sock]() { + const lttng::ctl::session_descriptor reply_session_descriptor = [cmd_ctx, sock]() { lttng_session_descriptor *raw_descriptor; const auto create_ret = cmd_create_session(cmd_ctx, *sock, &raw_descriptor); if (create_ret != LTTNG_OK) { diff --git a/src/bin/lttng-sessiond/cmd.cpp b/src/bin/lttng-sessiond/cmd.cpp index 6aa9c9402..a0e9c49e6 100644 --- a/src/bin/lttng-sessiond/cmd.cpp +++ b/src/bin/lttng-sessiond/cmd.cpp @@ -340,7 +340,7 @@ static enum lttng_error_code list_lttng_agent_events(struct agent *agt, local_nb_events = (unsigned int) agent_event_count; { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (agt->events->ht, &iter.iter, event, node.node) { struct lttng_event *tmp_event = lttng_event_create(); @@ -404,7 +404,7 @@ static enum lttng_error_code list_lttng_ust_global_events(char *channel_name, DBG("Listing UST global events for channel %s", channel_name); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; lttng_ht_lookup(ust_global->channels, (void *) channel_name, &iter); node = lttng_ht_iter_get_node(&iter); @@ -754,7 +754,7 @@ static int init_kernel_tracing(struct ltt_kernel_session *session) LTTNG_ASSERT(session); if (session->consumer_fds_sent == 0 && session->consumer != nullptr) { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( session->consumer->socks->ht, &iter.iter, socket, node.node) { @@ -1029,7 +1029,7 @@ int cmd_setup_relayd(const ltt_session::locked_ref& session) DBG("Setting relayd for session %s", session->name); if (session->current_trace_chunk) { - enum lttng_trace_chunk_status status = lttng_trace_chunk_get_id( + const lttng_trace_chunk_status status = lttng_trace_chunk_get_id( session->current_trace_chunk, ¤t_chunk_id.value); if (status == LTTNG_TRACE_CHUNK_STATUS_OK) { @@ -1044,7 +1044,7 @@ int cmd_setup_relayd(const ltt_session::locked_ref& session) if (usess && usess->consumer && usess->consumer->type == CONSUMER_DST_NET && usess->consumer->enabled) { /* For each consumer socket, send relayd sockets */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( usess->consumer->socks->ht, &iter.iter, socket, node.node) { @@ -1075,7 +1075,7 @@ int cmd_setup_relayd(const ltt_session::locked_ref& session) if (ksess && ksess->consumer && ksess->consumer->type == CONSUMER_DST_NET && ksess->consumer->enabled) { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( ksess->consumer->socks->ht, &iter.iter, socket, node.node) { @@ -1232,7 +1232,7 @@ int cmd_disable_channel(const ltt_session::locked_ref& session, usess = session->ust_session; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; switch (domain) { case LTTNG_DOMAIN_KERNEL: @@ -1339,7 +1339,7 @@ static enum lttng_error_code cmd_enable_channel_internal(ltt_session::locked_ref LTTNG_ASSERT(_attr); LTTNG_ASSERT(domain); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; attr = lttng_channel_copy(_attr); if (!attr) { @@ -1741,7 +1741,7 @@ int cmd_disable_event(struct command_ctx *cmd_ctx, event_name = event->name; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* Error out on unhandled search criteria */ if (event->loglevel_type || event->loglevel != -1 || event->enabled || event->pid || @@ -2074,7 +2074,7 @@ static int _cmd_enable_event(ltt_session::locked_ref& locked_session, { int ret = 0, channel_created = 0; struct lttng_channel *attr = nullptr; - ltt_session& session = *locked_session; + const ltt_session& session = *locked_session; LTTNG_ASSERT(event); LTTNG_ASSERT(channel_name); @@ -2096,7 +2096,7 @@ static int _cmd_enable_event(ltt_session::locked_ref& locked_session, } } - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; switch (domain->type) { case LTTNG_DOMAIN_KERNEL: @@ -2821,7 +2821,7 @@ int cmd_start_trace(const ltt_session::locked_ref& session) /* Flag session that trace should start automatically */ if (usess) { - int int_ret = ust_app_start_trace_all(usess); + const int int_ret = ust_app_start_trace_all(usess); if (int_ret < 0) { ret = LTTNG_ERR_UST_START_FAIL; @@ -2846,7 +2846,7 @@ int cmd_start_trace(const ltt_session::locked_ref& session) session->rotated_after_last_stop = false; if (session->rotate_timer_period && !session->rotation_schedule_timer_enabled) { - int int_ret = timer_session_rotation_schedule_timer_start( + const int int_ret = timer_session_rotation_schedule_timer_start( session, session->rotate_timer_period); if (int_ret < 0) { @@ -3044,9 +3044,9 @@ set_session_output_from_descriptor(const ltt_session::locked_ref& session, { int ret; enum lttng_error_code ret_code = LTTNG_OK; - enum lttng_session_descriptor_type session_type = + const lttng_session_descriptor_type session_type = lttng_session_descriptor_get_type(descriptor); - enum lttng_session_descriptor_output_type output_type = + const lttng_session_descriptor_output_type output_type = lttng_session_descriptor_get_output_type(descriptor); struct lttng_uri uris[2] = {}; size_t uri_count = 0; @@ -3631,7 +3631,7 @@ int cmd_register_consumer(const ltt_session::locked_ref& session, pthread_mutex_init(socket->lock, nullptr); socket->registered = 1; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; consumer_add_socket(socket, ksess->consumer); pthread_mutex_lock(&cdata->pid_mutex); @@ -3674,7 +3674,7 @@ ssize_t cmd_list_domains(const ltt_session::locked_ref& session, struct lttng_do DBG3("Listing domains found UST global domain"); nb_dom++; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( session->ust_session->agents->ht, &iter.iter, agt, node.node) { @@ -3709,7 +3709,7 @@ ssize_t cmd_list_domains(const ltt_session::locked_ref& session, struct lttng_do index++; { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( session->ust_session->agents->ht, &iter.iter, agt, node.node) { @@ -3804,7 +3804,7 @@ enum lttng_error_code cmd_list_channels(enum lttng_domain_type domain, struct ltt_ust_channel *uchan; { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (session->ust_session->domain_global.channels->ht, &iter.iter, @@ -3922,7 +3922,7 @@ enum lttng_error_code cmd_list_events(enum lttng_domain_type domain, struct lttng_ht_iter iter; struct agent *agt; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( session->ust_session->agents->ht, &iter.iter, agt, node.node) { @@ -4180,7 +4180,7 @@ int cmd_snapshot_del_output(const ltt_session::locked_ref& session, LTTNG_ASSERT(output); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* * Permission denied to create an output if the session is not @@ -4254,7 +4254,7 @@ ssize_t cmd_snapshot_list_outputs(const ltt_session::locked_ref& session, /* Copy list from session to the new list object. */ { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( session->snapshot.output_ht->ht, &iter.iter, output, node.node) { @@ -4944,7 +4944,7 @@ static enum lttng_error_code set_relayd_for_snapshot(struct consumer_output *out DBG2("Set relayd object from snapshot output"); if (session->current_trace_chunk) { - enum lttng_trace_chunk_status chunk_status = lttng_trace_chunk_get_id( + const lttng_trace_chunk_status chunk_status = lttng_trace_chunk_get_id( session->current_trace_chunk, ¤t_chunk_id.value); if (chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK) { @@ -4976,7 +4976,7 @@ static enum lttng_error_code set_relayd_for_snapshot(struct consumer_output *out * snapshot output. */ { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (output->socks->ht, &iter.iter, socket, node.node) { pthread_mutex_lock(socket->lock); @@ -5362,7 +5362,7 @@ int cmd_snapshot_record(const ltt_session::locked_ref& session, struct snapshot_output *sout; struct lttng_ht_iter iter; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( session->snapshot.output_ht->ht, &iter.iter, sout, node.node) { diff --git a/src/bin/lttng-sessiond/condition-internal.cpp b/src/bin/lttng-sessiond/condition-internal.cpp index ee7b4305a..5cae8677b 100644 --- a/src/bin/lttng-sessiond/condition-internal.cpp +++ b/src/bin/lttng-sessiond/condition-internal.cpp @@ -53,7 +53,8 @@ static unsigned long lttng_condition_session_consumed_size_hash(const struct lttng_condition *_condition) { unsigned long hash; - unsigned long condition_type = (unsigned long) LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE; + const unsigned long condition_type = + (unsigned long) LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE; struct lttng_condition_session_consumed_size *condition; uint64_t val; diff --git a/src/bin/lttng-sessiond/consumer.cpp b/src/bin/lttng-sessiond/consumer.cpp index 9629182ba..3a25cf5eb 100644 --- a/src/bin/lttng-sessiond/consumer.cpp +++ b/src/bin/lttng-sessiond/consumer.cpp @@ -293,7 +293,7 @@ void consumer_output_send_destroy_relayd(struct consumer_output *consumer) /* Destroy any relayd connection */ if (consumer->type == CONSUMER_DST_NET) { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (consumer->socks->ht, &iter.iter, socket, node.node) { /* Send destroy relayd command. */ @@ -320,7 +320,7 @@ int consumer_create_socket(struct consumer_data *data, struct consumer_output *o LTTNG_ASSERT(data); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; if (output == nullptr || data->cmd_sock < 0) { /* @@ -544,7 +544,7 @@ void consumer_destroy_output_sockets(struct consumer_output *obj) } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (obj->socks->ht, &iter.iter, socket, node.node) { consumer_del_socket(socket, obj); @@ -638,7 +638,7 @@ int consumer_copy_sockets(struct consumer_output *dst, struct consumer_output *s LTTNG_ASSERT(src); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (src->socks->ht, &iter.iter, socket, node.node) { /* Ignore socket that are already there. */ @@ -1272,7 +1272,7 @@ int consumer_is_data_pending(uint64_t session_id, struct consumer_output *consum { /* Send command for each consumer. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (consumer->socks->ht, &iter.iter, socket, node.node) { pthread_mutex_lock(socket->lock); @@ -1585,7 +1585,7 @@ int consumer_get_discarded_events(uint64_t session_id, /* Send command for each consumer. */ { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (consumer->socks->ht, &iter.iter, socket, node.node) { uint64_t consumer_discarded = 0; @@ -1647,7 +1647,7 @@ int consumer_get_lost_packets(uint64_t session_id, /* Send command for each consumer. */ { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (consumer->socks->ht, &iter.iter, socket, node.node) { uint64_t consumer_lost = 0; diff --git a/src/bin/lttng-sessiond/context.cpp b/src/bin/lttng-sessiond/context.cpp index 79c454809..0e9e91f0e 100644 --- a/src/bin/lttng-sessiond/context.cpp +++ b/src/bin/lttng-sessiond/context.cpp @@ -375,7 +375,7 @@ int context_ust_add(struct ltt_ust_session *usess, LTTNG_ASSERT(ctx); LTTNG_ASSERT(channel_name); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; chan_ht = usess->domain_global.channels; diff --git a/src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp b/src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp index 71a2e48d2..1388aa593 100644 --- a/src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp +++ b/src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp @@ -311,7 +311,7 @@ private: auto member_classes_value = json::json::array(); for (const auto& field : type.fields_) { ::ctf2::field_visitor member_visitor; - json::json member_class; + const json::json member_class; field->accept(member_visitor); member_classes_value.emplace_back(member_visitor.move_fragment()); diff --git a/src/bin/lttng-sessiond/ctl-utils.hpp b/src/bin/lttng-sessiond/ctl-utils.hpp index 13c21605a..be694cfa9 100644 --- a/src/bin/lttng-sessiond/ctl-utils.hpp +++ b/src/bin/lttng-sessiond/ctl-utils.hpp @@ -29,7 +29,7 @@ using session_descriptor = std::unique_ptr< */ using trigger = std::unique_ptr< lttng_trigger, - lttng::memory::create_deleter_class::deleter>; + lttng::memory::create_deleter_class::deleter>; } /* namespace ctl */ } /* namespace lttng */ diff --git a/src/bin/lttng-sessiond/dispatch.cpp b/src/bin/lttng-sessiond/dispatch.cpp index 33e90a1a5..32d50a25e 100644 --- a/src/bin/lttng-sessiond/dispatch.cpp +++ b/src/bin/lttng-sessiond/dispatch.cpp @@ -48,7 +48,7 @@ static void update_ust_app(int app_sock) return; } - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; LTTNG_ASSERT(app_sock >= 0); app = ust_app_find_by_sock(app_sock); if (app == nullptr) { @@ -133,8 +133,8 @@ static void sanitize_wait_queue(struct ust_reg_wait_queue *wait_queue) for (i = 0; i < nb_fd; i++) { /* Get faulty FD. */ - uint32_t revents = LTTNG_POLL_GETEV(&events, i); - int pollfd = LTTNG_POLL_GETFD(&events, i); + const uint32_t revents = LTTNG_POLL_GETEV(&events, i); + const int pollfd = LTTNG_POLL_GETFD(&events, i); cds_list_for_each_entry_safe (wait_node, tmp_wait_node, &wait_queue->head, head) { if (pollfd == wait_node->app->sock && (revents & (LPOLLHUP | LPOLLERR))) { @@ -379,7 +379,7 @@ static void *thread_dispatch_ust_registration(void *data) * and change its state. */ const auto list_lock = lttng::sessiond::lock_session_list(); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* * Add application to the global hash table. This needs to be diff --git a/src/bin/lttng-sessiond/event-notifier-error-accounting.cpp b/src/bin/lttng-sessiond/event-notifier-error-accounting.cpp index e22598223..f9f685176 100644 --- a/src/bin/lttng-sessiond/event-notifier-error-accounting.cpp +++ b/src/bin/lttng-sessiond/event-notifier-error-accounting.cpp @@ -155,7 +155,7 @@ static void ust_error_accounting_entry_release(struct urcu_ref *entry_ref) struct ust_error_accounting_entry *entry = lttng::utils::container_of(entry_ref, &ust_error_accounting_entry::ref); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_del(error_counter_uid_ht->ht, &entry->node.node); call_rcu(&entry->rcu_head, free_ust_error_accounting_entry); } @@ -180,7 +180,7 @@ static void put_ref_all_ust_error_accounting_entry() ASSERT_LOCKED(the_event_notifier_counter.lock); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( error_counter_uid_ht->ht, &iter.iter, uid_entry, node.node) { @@ -200,7 +200,7 @@ static void get_ref_all_ust_error_accounting_entry() ASSERT_LOCKED(the_event_notifier_counter.lock); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( error_counter_uid_ht->ht, &iter.iter, uid_entry, node.node) { @@ -304,7 +304,7 @@ static enum event_notifier_error_accounting_status get_error_counter_index_for_t struct lttng_ht_iter iter; const struct index_ht_entry *index_entry; enum event_notifier_error_accounting_status status; - lttng::urcu::read_lock_guard read_guard; + const lttng::urcu::read_lock_guard read_guard; lttng_ht_lookup(state->indices_ht, &tracer_token, &iter); node = lttng_ht_iter_get_node(&iter); @@ -594,7 +594,7 @@ event_notifier_error_accounting_register_app(struct ust_app *app) struct ust_error_accounting_entry *entry; enum event_notifier_error_accounting_status status; struct lttng_ust_abi_object_data **cpu_counters; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; if (!ust_app_supports_counters(app)) { status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_UNSUPPORTED; @@ -746,7 +746,7 @@ event_notifier_error_accounting_unregister_app(struct ust_app *app) struct ust_error_accounting_entry *entry; int i; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* If an error occurred during app registration no entry was created. */ if (!app->event_notifier_group.counter) { @@ -797,7 +797,7 @@ event_notifier_error_accounting_ust_get_count(const struct lttng_trigger *trigge uid_t trigger_owner_uid; const char *trigger_name; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; get_trigger_info_for_log(trigger, &trigger_name, &trigger_owner_uid); @@ -870,7 +870,7 @@ event_notifier_error_accounting_ust_clear(const struct lttng_trigger *trigger) size_t dimension_index; const uint64_t tracer_token = lttng_trigger_get_tracer_token(trigger); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; status = get_error_counter_index_for_token(&ust_state, tracer_token, &error_counter_index); if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) { @@ -1261,7 +1261,7 @@ void event_notifier_error_accounting_unregister_event_notifier(const struct lttn enum event_notifier_error_accounting_status status; struct error_accounting_state *state; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; status = event_notifier_error_accounting_clear(trigger); if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) { diff --git a/src/bin/lttng-sessiond/event.cpp b/src/bin/lttng-sessiond/event.cpp index c0b1aeebe..bd28d948c 100644 --- a/src/bin/lttng-sessiond/event.cpp +++ b/src/bin/lttng-sessiond/event.cpp @@ -173,7 +173,7 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess, LTTNG_ASSERT(uchan); LTTNG_ASSERT(event); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; uevent = trace_ust_find_event(uchan->events, event->name, @@ -263,7 +263,7 @@ int event_ust_disable_tracepoint(struct ltt_ust_session *usess, ht = uchan->events; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* * We use a custom lookup since we need the iterator for the next_duplicate @@ -328,7 +328,7 @@ int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess, struct ltt_ /* Disabling existing events */ { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (uchan->events->ht, &iter.iter, uevent, node.node) { if (uevent->enabled) { @@ -370,7 +370,7 @@ static void agent_enable_all(struct agent *agt) { /* Flag every event as enabled. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (agt->events->ht, &iter.iter, aevent, node.node) { aevent->enabled_count++; @@ -482,7 +482,7 @@ static int agent_enable(struct agent *agt, LTTNG_ASSERT(event); LTTNG_ASSERT(agt); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; aevent = agent_find_event( event->name, event->loglevel_type, event->loglevel, filter_expression, agt); if (!aevent) { @@ -837,7 +837,7 @@ int trigger_agent_disable(const struct lttng_trigger *trigger, struct agent *agt DBG("Event agent disabling for trigger %" PRIu64, lttng_trigger_get_tracer_token(trigger)); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; aevent = agent_find_event_by_trigger(trigger, agt); if (aevent == nullptr) { @@ -875,7 +875,7 @@ int event_agent_disable(struct ltt_ust_session *usess, struct agent *agt, const DBG("Event agent disabling %s (all loglevels) for session %" PRIu64, event_name, usess->id); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; agent_find_events_by_name(event_name, agt, &iter); node = lttng_ht_iter_get_node(&iter); @@ -925,7 +925,7 @@ int event_agent_disable_all(struct ltt_ust_session *usess, struct agent *agt) /* Disable every event. */ { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (agt->events->ht, &iter.iter, aevent, node.node) { if (!AGENT_EVENT_IS_ENABLED(aevent)) { diff --git a/src/bin/lttng-sessiond/kernel-consumer.cpp b/src/bin/lttng-sessiond/kernel-consumer.cpp index b813f0fe6..f0b1ae4f7 100644 --- a/src/bin/lttng-sessiond/kernel-consumer.cpp +++ b/src/bin/lttng-sessiond/kernel-consumer.cpp @@ -95,7 +95,7 @@ static int kernel_consumer_add_channel(struct consumer_socket *sock, struct lttng_channel_extended *channel_attr_extended; bool is_local_trace; size_t consumer_path_offset = 0; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* Safety net */ LTTNG_ASSERT(channel); @@ -210,7 +210,7 @@ int kernel_consumer_add_metadata(struct consumer_socket *sock, struct lttcomm_consumer_msg lkm; struct consumer_output *consumer; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* Safety net */ LTTNG_ASSERT(ksession); @@ -364,7 +364,7 @@ int kernel_consumer_send_channel_streams(struct consumer_socket *sock, LTTNG_ASSERT(ksession->consumer); LTTNG_ASSERT(sock); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* Bail out if consumer is disabled */ if (!ksession->consumer->enabled) { diff --git a/src/bin/lttng-sessiond/kernel.cpp b/src/bin/lttng-sessiond/kernel.cpp index e7626a85d..2d60fdca0 100644 --- a/src/bin/lttng-sessiond/kernel.cpp +++ b/src/bin/lttng-sessiond/kernel.cpp @@ -109,7 +109,7 @@ static inline uint64_t sanitize_uprobe_offset(uint64_t raw_offset) return raw_offset &= ~0b1; } #else /* defined(__arm__) || defined(__aarch64__) */ -static inline uint64_t sanitize_uprobe_offset(uint64_t raw_offset) +inline uint64_t sanitize_uprobe_offset(uint64_t raw_offset) { return raw_offset; } @@ -848,7 +848,7 @@ static int kernel_disable_event_notifier_rule(struct ltt_kernel_event_notifier_r LTTNG_ASSERT(event); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_del(kernel_token_to_event_notifier_rule_ht, &event->ht_node); ret = kernctl_disable(event->fd); @@ -1296,7 +1296,7 @@ error: void kernel_wait_quiescent() { int ret; - int fd = kernel_tracer_fd; + const int fd = kernel_tracer_fd; DBG("Kernel quiescent wait on %d", fd); @@ -1641,7 +1641,7 @@ void kernel_destroy_session(struct ltt_kernel_session *ksess) struct lttng_ht_iter iter; /* For each consumer socket. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( ksess->consumer->socks->ht, &iter.iter, socket, node.node) { @@ -1751,7 +1751,7 @@ enum lttng_error_code kernel_snapshot_record(struct ltt_kernel_session *ksess, { /* Send metadata to consumer and snapshot everything. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (output->socks->ht, &iter.iter, socket, node.node) { struct ltt_kernel_channel *chan; @@ -1914,7 +1914,7 @@ enum lttng_error_code kernel_rotate_session(const ltt_session::locked_ref& sessi * Note that this loop will end after one iteration given that there is * only one kernel consumer. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( ksess->consumer->socks->ht, &iter.iter, socket, node.node) { @@ -1958,7 +1958,7 @@ enum lttng_error_code kernel_create_channel_subdirectories(const struct ltt_kern enum lttng_error_code ret = LTTNG_OK; enum lttng_trace_chunk_status chunk_status; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; LTTNG_ASSERT(ksess->current_trace_chunk); /* @@ -2023,7 +2023,7 @@ void set_kernel_tracer_status_from_modules_ret(int code) int init_kernel_tracer() { int ret; - bool is_root = !getuid(); + const bool is_root = !getuid(); const auto log_status_on_exit = lttng::make_scope_exit([]() noexcept { DBG_FMT("Kernel tracer status set to `{}`", @@ -2265,7 +2265,7 @@ enum lttng_error_code kernel_clear_session(const ltt_session::locked_ref& sessio * Note that this loop will end after one iteration given that there is * only one kernel consumer. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( ksess->consumer->socks->ht, &iter.iter, socket, node.node) { @@ -2364,7 +2364,7 @@ error: enum lttng_error_code kernel_destroy_event_notifier_group_notification_fd(int event_notifier_group_notification_fd) { - enum lttng_error_code ret_code = LTTNG_OK; + const lttng_error_code ret_code = LTTNG_OK; DBG("Closing event notifier group notification file descriptor: fd = %d", event_notifier_group_notification_fd); @@ -2547,7 +2547,7 @@ static enum lttng_error_code kernel_create_event_notifier_rule( /* Add trigger to kernel token mapping in the hash table. */ { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_add(kernel_token_to_event_notifier_rule_ht, hash_trigger(trigger), &event_notifier_rule->ht_node); @@ -2613,7 +2613,7 @@ enum lttng_error_code kernel_unregister_event_notifier(const struct lttng_trigge enum lttng_error_code error_code_ret; int ret; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_lookup(kernel_token_to_event_notifier_rule_ht, hash_trigger(trigger), diff --git a/src/bin/lttng-sessiond/lttng-syscall.cpp b/src/bin/lttng-sessiond/lttng-syscall.cpp index 06f4ab1fb..42eb0e7ee 100644 --- a/src/bin/lttng-sessiond/lttng-syscall.cpp +++ b/src/bin/lttng-sessiond/lttng-syscall.cpp @@ -165,7 +165,7 @@ static void destroy_syscall_ht(struct lttng_ht *ht) } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ht->ht, &iter.iter, ksyscall, node.node) { int ret; @@ -313,7 +313,7 @@ ssize_t syscall_table_list(struct lttng_event **_events) } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; struct syscall *ksyscall; ksyscall = lookup_syscall(syscalls_ht, syscall_table[i].name); diff --git a/src/bin/lttng-sessiond/manage-kernel.cpp b/src/bin/lttng-sessiond/manage-kernel.cpp index 520583cc2..70a750aec 100644 --- a/src/bin/lttng-sessiond/manage-kernel.cpp +++ b/src/bin/lttng-sessiond/manage-kernel.cpp @@ -130,7 +130,7 @@ static int update_kernel_stream(int fd) } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( ksess->consumer->socks->ht, &iter.iter, socket, node.node) { diff --git a/src/bin/lttng-sessiond/modprobe.cpp b/src/bin/lttng-sessiond/modprobe.cpp index 0b274c9a3..e2050e7fe 100644 --- a/src/bin/lttng-sessiond/modprobe.cpp +++ b/src/bin/lttng-sessiond/modprobe.cpp @@ -787,7 +787,7 @@ int modprobe_lttng_data() } } else { /* Default probes. */ - int def_len = ARRAY_SIZE(kern_modules_probes_default); + const int def_len = ARRAY_SIZE(kern_modules_probes_default); probes = calloc(def_len); if (!probes) { diff --git a/src/bin/lttng-sessiond/notification-thread-events.cpp b/src/bin/lttng-sessiond/notification-thread-events.cpp index 8065cd732..b06d7bea0 100644 --- a/src/bin/lttng-sessiond/notification-thread-events.cpp +++ b/src/bin/lttng-sessiond/notification-thread-events.cpp @@ -217,8 +217,8 @@ static int match_channel_trigger_list(struct cds_lfht_node *node, const void *ke trigger_list = caa_container_of(node, struct lttng_channel_trigger_list, channel_triggers_ht_node); - return !!((channel_key->key == trigger_list->channel_key.key) && - (channel_key->domain == trigger_list->channel_key.domain)); + return !((channel_key->key != trigger_list->channel_key.key) || + (channel_key->domain != trigger_list->channel_key.domain)); } static int match_session_trigger_list(struct cds_lfht_node *node, const void *key) @@ -239,8 +239,8 @@ static int match_channel_state_sample(struct cds_lfht_node *node, const void *ke sample = caa_container_of(node, struct channel_state_sample, channel_state_ht_node); - return !!((channel_key->key == sample->key.key) && - (channel_key->domain == sample->key.domain)); + return !((channel_key->key != sample->key.key) || + (channel_key->domain != sample->key.domain)); } static int match_channel_info(struct cds_lfht_node *node, const void *key) @@ -250,8 +250,8 @@ static int match_channel_info(struct cds_lfht_node *node, const void *key) channel_info = caa_container_of(node, struct channel_info, channels_ht_node); - return !!((channel_key->key == channel_info->key.key) && - (channel_key->domain == channel_info->key.domain)); + return !((channel_key->key != channel_info->key.key) || + (channel_key->domain != channel_info->key.domain)); } static int match_trigger(struct cds_lfht_node *node, const void *key) @@ -312,7 +312,7 @@ static struct session_info *get_session_info_by_id(const struct notification_thr { struct cds_lfht_iter iter; struct cds_lfht_node *node; - lttng::urcu::read_lock_guard read_lock_guard; + const lttng::urcu::read_lock_guard read_lock_guard; cds_lfht_lookup( state->sessions_ht, hash_session_info_id(id), match_session_info, &id, &iter); @@ -444,8 +444,8 @@ static unsigned long hash_trigger_by_name_uid(const struct lttng_trigger *trigge static unsigned long hash_channel_key(struct channel_key *key) { - unsigned long key_hash = hash_key_u64(&key->key, lttng_ht_seed); - unsigned long domain_hash = + const unsigned long key_hash = hash_key_u64(&key->key, lttng_ht_seed); + const unsigned long domain_hash = hash_key_ulong((void *) (unsigned long) key->domain, lttng_ht_seed); return key_hash ^ domain_hash; @@ -527,7 +527,7 @@ static void session_info_destroy(void *_data) } lttng_session_trigger_list_destroy(session_info->trigger_list); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_del(session_info->sessions_ht, &session_info->sessions_ht_node); free(session_info->name); lttng_trace_archive_location_put(session_info->last_state_sample.rotation.location); @@ -595,7 +595,7 @@ error: static void session_info_add_channel(struct session_info *session_info, struct channel_info *channel_info) { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_add(session_info->channel_infos_ht, hash_channel_key(&channel_info->key), &channel_info->session_info_channels_ht_node); @@ -604,7 +604,7 @@ static void session_info_add_channel(struct session_info *session_info, static void session_info_remove_channel(struct session_info *session_info, struct channel_info *channel_info) { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_del(session_info->channel_infos_ht, &channel_info->session_info_channels_ht_node); } @@ -663,7 +663,7 @@ static void notification_client_list_release(struct urcu_ref *list_ref) lttng_condition_put(list->condition); if (list->notification_trigger_clients_ht) { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_del(list->notification_trigger_clients_ht, &list->notification_trigger_clients_ht_node); @@ -728,7 +728,7 @@ notification_client_list_create(struct notification_thread_state *state, { /* Build a list of clients to which this new condition applies. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( state->client_socket_ht, &iter, client, client_socket_ht_node) { @@ -755,7 +755,7 @@ notification_client_list_create(struct notification_thread_state *state, * Add the client list to the global list of client list. */ { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_add_unique(state->notification_trigger_clients_ht, lttng_condition_hash(client_list->condition), @@ -790,7 +790,7 @@ get_client_list_from_condition(struct notification_thread_state *state, struct cds_lfht_iter iter; struct notification_client_list *list = nullptr; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_lookup(state->notification_trigger_clients_ht, lttng_condition_hash(condition), match_client_list_condition, @@ -820,7 +820,7 @@ static int evaluate_channel_condition_for_client(const struct lttng_condition *c struct channel_state_sample *last_sample = nullptr; struct lttng_channel_trigger_list *channel_trigger_list = nullptr; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* Find the channel associated with the condition. */ cds_lfht_for_each_entry ( @@ -1516,7 +1516,7 @@ lttng_session_trigger_list_create(const char *session_name, struct cds_lfht *ses /* Publish the list through the session_triggers_ht. */ { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_add(session_triggers_ht, hash_key_str(session_name, lttng_ht_seed), &list->session_triggers_ht_node); @@ -1543,7 +1543,7 @@ static void lttng_session_trigger_list_destroy(struct lttng_session_trigger_list cds_list_del(&trigger_list_element->node); free(trigger_list_element); } - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* Unpublish the list from the session_triggers_ht. */ cds_lfht_del(list->session_triggers_ht, &list->session_triggers_ht_node); call_rcu(&list->rcu_node, free_session_trigger_list_rcu); @@ -1610,7 +1610,7 @@ lttng_session_trigger_list_build(const struct notification_thread_state *state, { /* Add all triggers applying to the session named 'session_name'. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (state->triggers_ht, &iter, trigger_ht_element, node) { int ret; @@ -1646,7 +1646,7 @@ static struct session_info *create_and_publish_session_info(struct notification_ struct session_info *session = nullptr; struct lttng_session_trigger_list *trigger_list; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; trigger_list = lttng_session_trigger_list_build(state, name); if (!trigger_list) { goto error; @@ -1699,7 +1699,7 @@ static int handle_notification_thread_command_add_channel(struct notification_th int trigger_count = 0; struct cds_lfht_iter iter; struct session_info *session_info = nullptr; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; DBG("Adding channel: channel name = `%s`, session id = %" PRIu64 ", channel key = %" PRIu64 ", domain = %s", @@ -1867,7 +1867,7 @@ handle_notification_thread_command_remove_channel(struct notification_thread_sta channel_key, lttng_domain_type_str(domain)); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_lookup(state->channel_triggers_ht, hash_channel_key(&key), @@ -1942,7 +1942,7 @@ handle_notification_thread_command_session_rotation(struct notification_thread_s struct lttng_credentials session_creds; struct session_state_sample new_session_state; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; session_info = get_session_info_by_id(state, session_id); if (!session_info) { @@ -2269,7 +2269,7 @@ handle_notification_thread_command_list_triggers(struct notification_thread_hand struct lttng_triggers *local_triggers = nullptr; const struct lttng_credentials *creds; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; local_triggers = lttng_triggers_create(); if (!local_triggers) { @@ -2341,7 +2341,7 @@ static int handle_notification_thread_command_get_trigger(struct notification_th uid_t trigger_owner_uid; { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (state->triggers_ht, &iter, trigger_ht_element, node) { if (lttng_trigger_is_equal(trigger, trigger_ht_element->trigger)) { @@ -2674,7 +2674,7 @@ handle_notification_thread_command_register_trigger(struct notification_thread_s enum action_executor_status executor_status; const uint64_t trigger_tracer_token = state->trigger_id.next_tracer_token++; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* Set the trigger's tracer token. */ lttng_trigger_set_tracer_token(trigger, trigger_tracer_token); @@ -2985,7 +2985,7 @@ static void teardown_tracer_notifier(struct notification_thread_state *state, struct notification_trigger_tokens_ht_element *trigger_tokens_ht_element; { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( state->trigger_tokens_ht, &iter, trigger_tokens_ht_element, node) { @@ -3048,7 +3048,7 @@ handle_notification_thread_command_unregister_trigger(struct notification_thread const struct lttng_condition *condition = lttng_trigger_get_const_condition(trigger); enum lttng_error_code cmd_reply; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_lookup( state->triggers_ht, lttng_condition_hash(condition), match_trigger, trigger, &iter); @@ -3153,7 +3153,7 @@ end: static notification_thread_command *pop_cmd_queue(notification_thread_handle *handle) { - lttng::pthread::lock_guard queue_lock(handle->cmd_queue.lock); + const lttng::pthread::lock_guard queue_lock(handle->cmd_queue.lock); uint64_t counter; const auto read_ret = lttng_read(handle->cmd_queue.event_fd, &counter, sizeof(counter)); @@ -3289,7 +3289,7 @@ int handle_notification_thread_command(struct notification_thread_handle *handle cmd->parameters.client_communication_update.id; struct notification_client *client; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; client = get_client_from_id(client_id, state); if (!client) { @@ -3436,7 +3436,7 @@ int handle_notification_thread_client_connect(struct notification_thread_state * DBG("Added new notification channel client socket (%i) to poll set", client->socket); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_add(state->client_socket_ht, hash_client_socket(client->socket), @@ -3497,7 +3497,7 @@ int handle_notification_thread_client_disconnect(int client_socket, int ret = 0; struct notification_client *client; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; DBG("Closing client connection (socket fd = %i)", client_socket); client = get_client_from_socket(client_socket, state); @@ -3522,7 +3522,7 @@ int handle_notification_thread_client_disconnect_all(struct notification_thread_ DBG("Closing all client connections"); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( state->client_socket_ht, &iter, client, client_socket_ht_node) { @@ -3544,9 +3544,9 @@ int handle_notification_thread_trigger_unregister_all(struct notification_thread struct cds_lfht_iter iter; struct lttng_trigger_ht_element *trigger_ht_element; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (state->triggers_ht, &iter, trigger_ht_element, node) { - int ret = handle_notification_thread_command_unregister_trigger( + const int ret = handle_notification_thread_command_unregister_trigger( state, trigger_ht_element->trigger, nullptr); if (ret) { error_occurred = true; @@ -4025,7 +4025,7 @@ int handle_notification_thread_client_in(struct notification_thread_state *state ssize_t recv_ret; size_t offset; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; client = get_client_from_socket(socket, state); if (!client) { /* Internal error, abort. */ @@ -4124,7 +4124,7 @@ int handle_notification_thread_client_out(struct notification_thread_state *stat struct notification_client *client; enum client_transmission_status transmission_status; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; client = get_client_from_socket(socket, state); if (!client) { /* Internal error, abort. */ @@ -4654,7 +4654,7 @@ dispatch_one_event_notifier_notification(struct notification_thread_state *state unsigned int capture_count = 0; /* Find triggers associated with this token. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_lookup(state->trigger_tokens_ht, hash_key_u64(¬ification->tracer_token, lttng_ht_seed), match_trigger_token, @@ -4825,7 +4825,7 @@ int handle_notification_thread_channel_sample(struct notification_thread_state * struct lttng_credentials channel_creds = {}; struct lttng_credentials session_creds = {}; struct session_info *session; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* * The monitoring pipe only holds messages smaller than PIPE_BUF, diff --git a/src/bin/lttng-sessiond/notification-thread.cpp b/src/bin/lttng-sessiond/notification-thread.cpp index 72aa08292..82272fedc 100644 --- a/src/bin/lttng-sessiond/notification-thread.cpp +++ b/src/bin/lttng-sessiond/notification-thread.cpp @@ -156,7 +156,7 @@ error: static char *get_notification_channel_sock_path() { int ret; - bool is_root = !getuid(); + const bool is_root = !getuid(); char *sock_path; sock_path = calloc(LTTNG_PATH_MAX); @@ -662,8 +662,8 @@ static void *thread_notification(void *data) fd_count = ret; for (i = 0; i < fd_count; i++) { - int fd = LTTNG_POLL_GETFD(&state.events, i); - uint32_t revents = LTTNG_POLL_GETEV(&state.events, i); + const int fd = LTTNG_POLL_GETFD(&state.events, i); + const uint32_t revents = LTTNG_POLL_GETEV(&state.events, i); DBG("Handling fd (%i) activity (%u)", fd, revents); diff --git a/src/bin/lttng-sessiond/rotation-thread.cpp b/src/bin/lttng-sessiond/rotation-thread.cpp index 10e065672..a26f620b4 100644 --- a/src/bin/lttng-sessiond/rotation-thread.cpp +++ b/src/bin/lttng-sessiond/rotation-thread.cpp @@ -122,7 +122,7 @@ void check_session_rotation_pending_on_consumers(const ltt_session::locked_ref& uint64_t relayd_id; bool chunk_exists_on_peer = false; enum lttng_trace_chunk_status chunk_status; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; LTTNG_ASSERT(session->chunk_being_archived); @@ -140,7 +140,7 @@ void check_session_rotation_pending_on_consumers(const ltt_session::locked_ref& -1ULL : session->ust_session->consumer->net_seq_index; - lttng::pthread::lock_guard socket_lock(*socket->lock); + const lttng::pthread::lock_guard socket_lock(*socket->lock); ret = consumer_trace_chunk_exists(socket, relayd_id, session->id, @@ -164,7 +164,7 @@ skip_ust: cds_lfht_for_each_entry ( session->kernel_session->consumer->socks->ht, &iter, socket, node.node) { - lttng::pthread::lock_guard socket_lock(*socket->lock); + const lttng::pthread::lock_guard socket_lock(*socket->lock); relayd_id = session->kernel_session->consumer->type == CONSUMER_DST_LOCAL ? -1ULL : @@ -391,7 +391,7 @@ void ls::rotation_thread_timer_queue_destroy(struct rotation_thread_timer_queue lttng_pipe_destroy(queue->event_pipe); { - lttng::pthread::lock_guard queue_lock(queue->lock); + const lttng::pthread::lock_guard queue_lock(queue->lock); LTTNG_ASSERT(cds_list_empty(&queue->list)); } @@ -472,7 +472,7 @@ void ls::rotation_thread_enqueue_job(ls::rotation_thread_timer_queue *queue, const char dummy = '!'; struct rotation_thread_job *job = nullptr; const char *job_type_str = get_job_type_str(job_type); - lttng::pthread::lock_guard queue_lock(queue->lock); + const lttng::pthread::lock_guard queue_lock(queue->lock); if (timer_job_exists(queue, job_type, session)) { /* @@ -533,7 +533,7 @@ void ls::rotation_thread::_handle_job_queue() { /* Take the queue lock only to pop an element from the list. */ - lttng::pthread::lock_guard rotation_timer_queue_lock( + const lttng::pthread::lock_guard rotation_timer_queue_lock( _rotation_timer_queue.lock); if (cds_list_empty(&_rotation_timer_queue.list)) { break; diff --git a/src/bin/lttng-sessiond/save.cpp b/src/bin/lttng-sessiond/save.cpp index 7e3c49290..67fa01de6 100644 --- a/src/bin/lttng-sessiond/save.cpp +++ b/src/bin/lttng-sessiond/save.cpp @@ -1108,7 +1108,7 @@ static int save_ust_events(struct config_writer *writer, struct lttng_ht *events } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (events->ht, &iter.iter, node, node) { event = lttng::utils::container_of(node, <t_ust_event::node); @@ -1189,7 +1189,7 @@ static int save_agent_events(struct config_writer *writer, struct agent *agent) } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (agent->events->ht, &iter.iter, node, node) { struct agent_event *agent_event; @@ -1833,7 +1833,7 @@ static int save_process_attr_tracker(struct config_writer *writer, if (tracking_policy == LTTNG_TRACKING_POLICY_INCLUDE_SET) { unsigned int i, count; - enum process_attr_tracker_status status = + const process_attr_tracker_status status = process_attr_tracker_get_inclusion_set(tracker, &values); if (status != PROCESS_ATTR_TRACKER_STATUS_OK) { @@ -2039,7 +2039,7 @@ static int save_ust_domain(struct config_writer *writer, } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( session->ust_session->domain_global.channels->ht, &iter.iter, node, node) { @@ -2319,7 +2319,7 @@ static int save_snapshot_outputs(struct config_writer *writer, struct snapshot * } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (snapshot->output_ht->ht, &iter.iter, output, node.node) { ret = config_writer_open_element(writer, config_element_output); diff --git a/src/bin/lttng-sessiond/session.cpp b/src/bin/lttng-sessiond/session.cpp index ea92db57f..f60415841 100644 --- a/src/bin/lttng-sessiond/session.cpp +++ b/src/bin/lttng-sessiond/session.cpp @@ -520,7 +520,7 @@ static int _session_set_trace_chunk_no_lock_check(const ltt_session::locked_ref& uint64_t chunk_id; enum lttng_trace_chunk_status chunk_status; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* * Ownership of current trace chunk is transferred to * `current_trace_chunk`. @@ -889,7 +889,7 @@ static enum lttng_error_code session_kernel_open_packets(const ltt_session::lock struct cds_lfht_node *node; struct ltt_kernel_channel *chan; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_first(session->kernel_session->consumer->socks->ht, &iter.iter); node = cds_lfht_iter_get_node(&iter.iter); @@ -1402,7 +1402,7 @@ bool sample_session_id_by_name(const char *name, uint64_t *id) struct lttng_ht_iter iter; struct ltt_session *ls; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; if (!ltt_sessions_ht_by_name) { found = false; @@ -1447,7 +1447,7 @@ void ltt_session::_locked_const_session_release(const ltt_session *session) ltt_session::locked_ref ltt_session::find_locked_session(ltt_session::id_t id) { - lttng::urcu::read_lock_guard rcu_lock; + const lttng::urcu::read_lock_guard rcu_lock; auto session = session_find_by_id(id); if (!session) { @@ -1464,7 +1464,7 @@ ltt_session::locked_ref ltt_session::find_locked_session(ltt_session::id_t id) ltt_session::locked_ref ltt_session::find_locked_session(lttng::c_string_view name) { - lttng::urcu::read_lock_guard rcu_lock; + const lttng::urcu::read_lock_guard rcu_lock; auto session = session_find_by_name(name.data()); if (!session) { @@ -1477,7 +1477,7 @@ ltt_session::locked_ref ltt_session::find_locked_session(lttng::c_string_view na ltt_session::const_locked_ref ltt_session::find_locked_const_session(ltt_session::id_t id) { - lttng::urcu::read_lock_guard rcu_lock; + const lttng::urcu::read_lock_guard rcu_lock; const auto *session = session_find_by_id(id); if (!session) { @@ -1490,7 +1490,7 @@ ltt_session::const_locked_ref ltt_session::find_locked_const_session(ltt_session ltt_session::const_locked_ref ltt_session::find_locked_const_session(lttng::c_string_view name) { - lttng::urcu::read_lock_guard rcu_lock; + const lttng::urcu::read_lock_guard rcu_lock; const auto *session = session_find_by_name(name.data()); if (!session) { @@ -1503,7 +1503,7 @@ ltt_session::const_locked_ref ltt_session::find_locked_const_session(lttng::c_st ltt_session::ref ltt_session::find_session(ltt_session::id_t id) { - lttng::urcu::read_lock_guard rcu_lock; + const lttng::urcu::read_lock_guard rcu_lock; auto session = session_find_by_id(id); if (!session) { @@ -1515,7 +1515,7 @@ ltt_session::ref ltt_session::find_session(ltt_session::id_t id) ltt_session::ref ltt_session::find_session(lttng::c_string_view name) { - lttng::urcu::read_lock_guard rcu_lock; + const lttng::urcu::read_lock_guard rcu_lock; auto session = session_find_by_name(name.data()); if (!session) { @@ -1527,7 +1527,7 @@ ltt_session::ref ltt_session::find_session(lttng::c_string_view name) ltt_session::const_ref ltt_session::find_const_session(ltt_session::id_t id) { - lttng::urcu::read_lock_guard rcu_lock; + const lttng::urcu::read_lock_guard rcu_lock; const auto *session = session_find_by_id(id); if (!session) { @@ -1539,7 +1539,7 @@ ltt_session::const_ref ltt_session::find_const_session(ltt_session::id_t id) ltt_session::const_ref ltt_session::find_const_session(lttng::c_string_view name) { - lttng::urcu::read_lock_guard rcu_lock; + const lttng::urcu::read_lock_guard rcu_lock; const auto *session = session_find_by_name(name.data()); if (!session) { diff --git a/src/bin/lttng-sessiond/sessiond-config.cpp b/src/bin/lttng-sessiond/sessiond-config.cpp index e8aeae8ef..037488b8a 100644 --- a/src/bin/lttng-sessiond/sessiond-config.cpp +++ b/src/bin/lttng-sessiond/sessiond-config.cpp @@ -236,7 +236,7 @@ end: int sessiond_config_init(struct sessiond_config *config) { int ret; - bool is_root = (getuid() == 0); + const bool is_root = (getuid() == 0); char *str; LTTNG_ASSERT(config); diff --git a/src/bin/lttng-sessiond/snapshot.cpp b/src/bin/lttng-sessiond/snapshot.cpp index f9ab929d6..d4fb5f069 100644 --- a/src/bin/lttng-sessiond/snapshot.cpp +++ b/src/bin/lttng-sessiond/snapshot.cpp @@ -194,7 +194,7 @@ void snapshot_delete_output(struct snapshot *snapshot, struct snapshot_output *o LTTNG_ASSERT(output); iter.iter.node = &output->node.node; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; ret = lttng_ht_del(snapshot->output_ht, &iter); LTTNG_ASSERT(!ret); /* @@ -213,7 +213,7 @@ void snapshot_add_output(struct snapshot *snapshot, struct snapshot_output *outp LTTNG_ASSERT(snapshot->output_ht); LTTNG_ASSERT(output); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; lttng_ht_add_unique_ulong(snapshot->output_ht, &output->node); /* * This is safe because the ownership of a snapshot object is in a session @@ -327,7 +327,7 @@ void snapshot_destroy(struct snapshot *obj) } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (obj->output_ht->ht, &iter.iter, output, node.node) { snapshot_delete_output(obj, output); diff --git a/src/bin/lttng-sessiond/trace-ust.cpp b/src/bin/lttng-sessiond/trace-ust.cpp index bffd2900b..ea892a6d9 100644 --- a/src/bin/lttng-sessiond/trace-ust.cpp +++ b/src/bin/lttng-sessiond/trace-ust.cpp @@ -282,7 +282,7 @@ struct ltt_ust_session *trace_ust_create_session(uint64_t session_id) /* Init data structure */ lus->id = session_id; - lus->active = 0; + lus->active = false; /* Set default metadata channel attribute. */ lus->metadata_attr.overwrite = DEFAULT_CHANNEL_OVERWRITE; @@ -764,10 +764,10 @@ static void fini_id_tracker(struct ust_id_tracker *id_tracker) } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (id_tracker->ht->ht, &iter.iter, tracker_node, node.node) { - int ret = lttng_ht_del(id_tracker->ht, &iter); + const int ret = lttng_ht_del(id_tracker->ht, &iter); LTTNG_ASSERT(!ret); destroy_id_tracker_node(tracker_node); @@ -781,7 +781,7 @@ static void fini_id_tracker(struct ust_id_tracker *id_tracker) static struct ust_id_tracker_node * id_tracker_lookup(struct ust_id_tracker *id_tracker, int id, struct lttng_ht_iter *iter) { - unsigned long _id = (unsigned long) id; + const unsigned long _id = (unsigned long) id; struct lttng_ht_node_ulong *node; lttng_ht_lookup(id_tracker->ht, (void *) _id, iter); @@ -1208,7 +1208,7 @@ static void destroy_contexts(struct lttng_ht *ht) LTTNG_ASSERT(ht); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ht->ht, &iter.iter, node, node) { /* Remove from ordered list. */ @@ -1276,7 +1276,7 @@ static void destroy_events(struct lttng_ht *events) LTTNG_ASSERT(events); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (events->ht, &iter.iter, node, node) { ret = lttng_ht_del(events, &iter); @@ -1345,7 +1345,7 @@ int trace_ust_regenerate_metadata(struct ltt_ust_session *usess) struct buffer_reg_uid *uid_reg = nullptr; struct buffer_reg_session *session_reg = nullptr; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_list_for_each_entry (uid_reg, &usess->buffer_reg_uid_list, lnode) { lsu::registry_session *registry; @@ -1376,7 +1376,7 @@ static void destroy_channels(struct lttng_ht *channels) LTTNG_ASSERT(channels); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (channels->ht, &iter.iter, node, node) { struct ltt_ust_channel *chan = @@ -1418,10 +1418,10 @@ void trace_ust_destroy_session(struct ltt_ust_session *session) destroy_domain_global(&session->domain_global); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (session->agents->ht, &iter.iter, agt, node.node) { - int ret = lttng_ht_del(session->agents, &iter); + const int ret = lttng_ht_del(session->agents, &iter); LTTNG_ASSERT(!ret); agent_destroy(agt); diff --git a/src/bin/lttng-sessiond/tracker.cpp b/src/bin/lttng-sessiond/tracker.cpp index 526e51b6b..453034490 100644 --- a/src/bin/lttng-sessiond/tracker.cpp +++ b/src/bin/lttng-sessiond/tracker.cpp @@ -93,7 +93,7 @@ static void process_attr_tracker_clear_inclusion_set(struct process_attr_tracker } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( tracker->inclusion_set_ht, &iter.iter, value_node, inclusion_set_ht_node) { @@ -167,7 +167,7 @@ process_attr_tracker_lookup(const struct process_attr_tracker *tracker, LTTNG_ASSERT(tracker->policy == LTTNG_TRACKING_POLICY_INCLUDE_SET); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_lookup(tracker->inclusion_set_ht, process_attr_value_hash(value), match_inclusion_set_value, @@ -189,7 +189,7 @@ process_attr_tracker_inclusion_set_add_value(struct process_attr_tracker *tracke struct process_attr_value *value_copy = nullptr; struct process_attr_tracker_value_node *value_node = nullptr; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; if (tracker->policy != LTTNG_TRACKING_POLICY_INCLUDE_SET) { status = PROCESS_ATTR_TRACKER_STATUS_INVALID_TRACKING_POLICY; goto end; @@ -236,7 +236,7 @@ process_attr_tracker_inclusion_set_remove_value(struct process_attr_tracker *tra struct process_attr_tracker_value_node *value_node; enum process_attr_tracker_status status = PROCESS_ATTR_TRACKER_STATUS_OK; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; if (tracker->policy != LTTNG_TRACKING_POLICY_INCLUDE_SET) { status = PROCESS_ATTR_TRACKER_STATUS_INVALID_TRACKING_POLICY; goto end; @@ -275,7 +275,7 @@ process_attr_tracker_get_inclusion_set(const struct process_attr_tracker *tracke } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( tracker->inclusion_set_ht, &iter.iter, value_node, inclusion_set_ht_node) { diff --git a/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp b/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp index 83f4a2427..4129333c1 100644 --- a/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp +++ b/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp @@ -75,7 +75,7 @@ std::string escape_tsdl_identifier(const std::string& original_identifier) new_identifier = "_"; /* Replace illegal characters by '_'. */ - std::locale c_locale{ "C" }; + const std::locale c_locale{ "C" }; for (const auto current_char : original_identifier) { if (!std::isalnum(current_char, c_locale) && current_char != '_') { new_identifier += '_'; diff --git a/src/bin/lttng-sessiond/ust-app.cpp b/src/bin/lttng-sessiond/ust-app.cpp index cc23c75fa..cb70dae23 100644 --- a/src/bin/lttng-sessiond/ust-app.cpp +++ b/src/bin/lttng-sessiond/ust-app.cpp @@ -503,7 +503,7 @@ static void save_per_pid_lost_discarded_counters(struct ust_app_channel *ua_chan return; } - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; try { const auto session = ltt_session::find_session(ua_chan->session->tracing_id); @@ -881,7 +881,7 @@ static int close_metadata(uint64_t metadata_key, { int ret; struct consumer_socket *socket; - lttng::urcu::read_lock_guard read_lock_guard; + const lttng::urcu::read_lock_guard read_lock_guard; LTTNG_ASSERT(consumer); @@ -1033,13 +1033,13 @@ static void delete_ust_app(struct ust_app *app) /* Wipe sessions */ cds_list_for_each_entry_safe (ua_sess, tmp_ua_sess, &app->teardown_head, teardown_node) { /* Free every object in the session and the session. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; delete_ust_app_session(sock, ua_sess, app); } /* Remove the event notifier rules associated with this app. */ { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (app->token_to_event_notifier_rule_ht->ht, &iter.iter, @@ -1722,7 +1722,7 @@ static struct lttng_ust_abi_event_exclusion * create_ust_exclusion_from_exclusion(const struct lttng_event_exclusion *exclusion) { struct lttng_ust_abi_event_exclusion *ust_exclusion = nullptr; - size_t exclusion_alloc_size = sizeof(struct lttng_ust_abi_event_exclusion) + + const size_t exclusion_alloc_size = sizeof(struct lttng_ust_abi_event_exclusion) + LTTNG_UST_ABI_SYM_NAME_LEN * exclusion->count; ust_exclusion = zmalloc(exclusion_alloc_size); @@ -2565,7 +2565,7 @@ static int setup_buffer_reg_pid(struct ust_app_session *ua_sess, LTTNG_ASSERT(ua_sess); LTTNG_ASSERT(app); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; reg_pid = buffer_reg_pid_find(ua_sess->id); if (!reg_pid) { @@ -2634,7 +2634,7 @@ static int setup_buffer_reg_uid(struct ltt_ust_session *usess, LTTNG_ASSERT(usess); LTTNG_ASSERT(app); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; reg_uid = buffer_reg_uid_find(usess->id, app->abi.bits_per_long, app->uid); if (!reg_uid) { @@ -3050,7 +3050,7 @@ static int do_consumer_create_channel(struct ltt_ust_session *usess, LTTNG_ASSERT(ua_chan); LTTNG_ASSERT(registry); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; health_code_update(); /* Get the right consumer socket for the application. */ @@ -3569,7 +3569,7 @@ static int create_channel_per_pid(struct ust_app *app, DBG("UST app creating channel %s with per PID buffers", ua_chan->name); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; registry = ust_app_get_session_registry(ua_sess->get_identifier()); /* The UST app session lock is held, registry shall not be null. */ @@ -4120,7 +4120,7 @@ void ust_app_add(struct ust_app *app) app->registration_time = time(nullptr); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* * On a re-registration, we want to kick out the previous registration of @@ -4319,7 +4319,7 @@ static void ust_app_unregister(ust_app& app) struct lttng_ht_iter iter; struct ust_app_session *ua_sess; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* * For per-PID buffers, perform "push metadata" and flush all @@ -4425,7 +4425,7 @@ void ust_app_unregister_by_socket(int sock_fd) struct lttng_ht_iter ust_app_sock_iter; int ret; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* Get the node reference for a call_rcu */ lttng_ht_lookup(ust_app_ht_by_sock, (void *) ((unsigned long) sock_fd), &ust_app_sock_iter); @@ -4469,7 +4469,7 @@ int ust_app_list_events(struct lttng_event **events) } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { struct lttng_ust_abi_tracepoint_iter uiter; @@ -4627,7 +4627,7 @@ int ust_app_list_event_fields(struct lttng_event_field **fields) } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { struct lttng_ust_abi_field_iter uiter; @@ -4776,7 +4776,7 @@ void ust_app_clean_list() /* Cleanup notify socket hash table */ if (ust_app_ht_by_notify_sock) { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( ust_app_ht_by_notify_sock->ht, &iter.iter, app, notify_sock_n.node) { @@ -4791,7 +4791,7 @@ void ust_app_clean_list() /* Cleanup socket hash table */ if (ust_app_ht_by_sock) { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ust_app_ht_by_sock->ht, &iter.iter, app, sock_n.node) { ret = lttng_ht_del(ust_app_ht_by_sock, &iter); @@ -4850,7 +4850,7 @@ int ust_app_disable_channel_glb(struct ltt_ust_session *usess, struct ltt_ust_ch usess->id); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* For every registered applications */ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { @@ -4905,7 +4905,7 @@ int ust_app_enable_channel_glb(struct ltt_ust_session *usess, struct ltt_ust_cha usess->id); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* For every registered applications */ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { @@ -4956,7 +4956,7 @@ int ust_app_disable_event_glb(struct ltt_ust_session *usess, usess->id); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* For all registered applications */ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { @@ -5109,7 +5109,7 @@ int ust_app_enable_event_glb(struct ltt_ust_session *usess, */ { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* For all registered applications */ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { @@ -5192,7 +5192,7 @@ int ust_app_create_event_glb(struct ltt_ust_session *usess, usess->id); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* For all registered applications */ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { @@ -5255,7 +5255,7 @@ static int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *ap DBG("Starting tracing for ust app pid %d", app->pid); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; const auto update_health_code_on_exit = lttng::make_scope_exit([]() noexcept { health_code_update(); }); @@ -5345,7 +5345,7 @@ static int ust_app_stop_trace(struct ltt_ust_session *usess, struct ust_app *app DBG("Stopping tracing for ust app pid %d", app->pid); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; const auto update_health_code_on_exit = lttng::make_scope_exit([]() noexcept { health_code_update(); }); @@ -5472,7 +5472,7 @@ static int ust_app_flush_app_session(ust_app& app, ust_app_session& ua_sess) switch (ua_sess.buffer_type) { case LTTNG_BUFFER_PER_PID: { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ua_sess.channels->ht, &iter.iter, ua_chan, node.node) { health_code_update(); @@ -5515,7 +5515,7 @@ static int ust_app_flush_session(struct ltt_ust_session *usess) /* Flush all per UID buffers associated to that session. */ cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; lsu::registry_session *ust_session_reg; struct buffer_reg_channel *buf_reg_chan; struct consumer_socket *socket; @@ -5551,7 +5551,7 @@ static int ust_app_flush_session(struct ltt_ust_session *usess) struct ust_app_session *ua_sess; struct lttng_ht_iter iter; struct ust_app *app; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { ua_sess = ust_app_lookup_app_session(usess, app); @@ -5583,7 +5583,7 @@ static int ust_app_clear_quiescent_app_session(struct ust_app *app, struct ust_a DBG("Clearing stream quiescent state for ust app pid %d", app->pid); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; const auto update_health_code_on_exit = lttng::make_scope_exit([]() noexcept { health_code_update(); }); @@ -5652,7 +5652,7 @@ static int ust_app_clear_quiescent_session(struct ltt_ust_session *usess) cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) { struct consumer_socket *socket; struct buffer_reg_channel *buf_reg_chan; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* Get associated consumer socket.*/ socket = consumer_find_socket_by_bitness(reg->bits_per_long, @@ -5685,7 +5685,7 @@ static int ust_app_clear_quiescent_session(struct ltt_ust_session *usess) struct ust_app_session *ua_sess; struct lttng_ht_iter iter; struct ust_app *app; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { ua_sess = ust_app_lookup_app_session(usess, app); @@ -5719,7 +5719,7 @@ static int destroy_trace(struct ltt_ust_session *usess, struct ust_app *app) DBG("Destroy tracing for ust app pid %d", app->pid); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; if (!app->compatible) { goto end; @@ -5788,7 +5788,7 @@ int ust_app_start_trace_all(struct ltt_ust_session *usess) (void) ust_app_clear_quiescent_session(usess); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { ust_app_global_update(usess, app); @@ -5817,7 +5817,7 @@ int ust_app_stop_trace_all(struct ltt_ust_session *usess) usess->active = false; { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { ret = ust_app_stop_trace(usess, app); @@ -5845,7 +5845,7 @@ int ust_app_destroy_trace_all(struct ltt_ust_session *usess) DBG("Destroy all UST traces"); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { ret = destroy_trace(usess, app); @@ -6007,7 +6007,7 @@ static void ust_app_synchronize_event_notifier_rules(struct ust_app *app) } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* Remove all unknown event sources from the app. */ cds_lfht_for_each_entry (app->token_to_event_notifier_rule_ht->ht, @@ -6146,7 +6146,7 @@ static void ust_app_synchronize(struct ltt_ust_session *usess, struct ust_app *a } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; ust_app_synchronize_all_channels(usess, locked_ua_sess, app); @@ -6247,7 +6247,7 @@ void ust_app_global_update_all(struct ltt_ust_session *usess) struct ust_app *app; { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { ust_app_global_update(usess, app); @@ -6260,7 +6260,7 @@ void ust_app_global_update_all_event_notifier_rules() struct lttng_ht_iter iter; struct ust_app *app; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { ust_app_global_update_event_notifier_rules(app); } @@ -6283,7 +6283,7 @@ int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess, LTTNG_ASSERT(usess->active); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { if (!app->compatible) { /* @@ -6453,7 +6453,7 @@ static int handle_app_register_channel_notification(int sock, lttng::make_unique_wrapper( raw_context_fields); - lttng::urcu::read_lock_guard read_lock_guard; + const lttng::urcu::read_lock_guard read_lock_guard; /* Lookup application. If not found, there is a code flow error. */ app = find_app_by_notify_sock(sock); @@ -6622,7 +6622,7 @@ static int add_event_ust_registry(int sock, struct ust_app *app; struct ust_app_channel *ua_chan; struct ust_app_session *ua_sess; - lttng::urcu::read_lock_guard rcu_lock; + const lttng::urcu::read_lock_guard rcu_lock; auto signature = lttng::make_unique_wrapper(raw_signature); auto fields = lttng::make_unique_wrapper(raw_fields); @@ -6747,7 +6747,7 @@ static int add_enum_ust_registry(int sock, struct ust_app *app; struct ust_app_session *ua_sess; uint64_t enum_id = -1ULL; - lttng::urcu::read_lock_guard read_lock_guard; + const lttng::urcu::read_lock_guard read_lock_guard; auto entries = lttng::make_unique_wrapper( raw_entries); @@ -6884,7 +6884,7 @@ int ust_app_recv_notify(int sock) } { - lttng::urcu::read_lock_guard rcu_lock; + const lttng::urcu::read_lock_guard rcu_lock; const struct ust_app *app = find_app_by_notify_sock(sock); if (!app) { DBG("Application socket %d is being torn down. Abort event notify", @@ -7019,7 +7019,7 @@ void ust_app_notify_sock_unregister(int sock) LTTNG_ASSERT(sock >= 0); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; obj = zmalloc(); if (!obj) { @@ -7109,7 +7109,7 @@ enum lttng_error_code ust_app_snapshot_record(const struct ltt_ust_session *uses { struct buffer_reg_uid *reg; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) { struct buffer_reg_channel *buf_reg_chan; @@ -7178,7 +7178,7 @@ enum lttng_error_code ust_app_snapshot_record(const struct ltt_ust_session *uses } case LTTNG_BUFFER_PER_PID: { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { struct consumer_socket *socket; @@ -7289,7 +7289,7 @@ uint64_t ust_app_get_size_one_more_packet_per_stream(const struct ltt_ust_sessio cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) { struct buffer_reg_channel *buf_reg_chan; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( reg->registry->channels->ht, &iter.iter, buf_reg_chan, node.node) { @@ -7307,7 +7307,7 @@ uint64_t ust_app_get_size_one_more_packet_per_stream(const struct ltt_ust_sessio } case LTTNG_BUFFER_PER_PID: { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { struct ust_app_channel *ua_chan; @@ -7396,7 +7396,7 @@ int ust_app_pid_get_channel_runtime_stats(struct ltt_ust_session *usess, * Iterate over every registered applications. Sum counters for * all applications containing requested session and channel. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { struct lttng_ht_iter uiter; @@ -7444,7 +7444,7 @@ static int ust_app_regenerate_statedump(struct ltt_ust_session *usess, struct us DBG("Regenerating the metadata for ust app pid %d", app->pid); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; const auto update_health_code_on_exit = lttng::make_scope_exit([]() noexcept { health_code_update(); }); @@ -7476,7 +7476,7 @@ int ust_app_regenerate_statedump_all(struct ltt_ust_session *usess) DBG("Regenerating the metadata for all UST apps"); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { if (!app->compatible) { @@ -7515,7 +7515,7 @@ enum lttng_error_code ust_app_rotate_session(const ltt_session::locked_ref& sess cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) { struct buffer_reg_channel *buf_reg_chan; struct consumer_socket *socket; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* Get consumer socket to use to push the metadata.*/ socket = consumer_find_socket_by_bitness(reg->bits_per_long, @@ -7569,7 +7569,7 @@ enum lttng_error_code ust_app_rotate_session(const ltt_session::locked_ref& sess } case LTTNG_BUFFER_PER_PID: { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; ust_app *raw_app; cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, raw_app, pid_n.node) { @@ -7664,7 +7664,7 @@ enum lttng_error_code ust_app_create_channel_subdirectories(const struct ltt_ust case LTTNG_BUFFER_PER_UID: { struct buffer_reg_uid *reg; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) { fmt_ret = asprintf(&pathname_index, @@ -7695,7 +7695,7 @@ enum lttng_error_code ust_app_create_channel_subdirectories(const struct ltt_ust case LTTNG_BUFFER_PER_PID: { struct ust_app *app; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* * Create the toplevel ust/ directory in case no apps are running. @@ -7779,7 +7779,7 @@ enum lttng_error_code ust_app_clear_session(const ltt_session::locked_ref& sessi case LTTNG_BUFFER_PER_UID: { struct buffer_reg_uid *reg; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) { struct buffer_reg_channel *buf_reg_chan; @@ -7821,7 +7821,7 @@ enum lttng_error_code ust_app_clear_session(const ltt_session::locked_ref& sessi } case LTTNG_BUFFER_PER_PID: { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { struct consumer_socket *socket; @@ -7938,7 +7938,7 @@ enum lttng_error_code ust_app_open_packets(const ltt_session::locked_ref& sessio cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) { struct buffer_reg_channel *buf_reg_chan; struct consumer_socket *socket; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; socket = consumer_find_socket_by_bitness(reg->bits_per_long, usess->consumer); @@ -7963,7 +7963,7 @@ enum lttng_error_code ust_app_open_packets(const ltt_session::locked_ref& sessio case LTTNG_BUFFER_PER_PID: { struct ust_app *app; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) { struct consumer_socket *socket; diff --git a/src/bin/lttng-sessiond/ust-consumer.cpp b/src/bin/lttng-sessiond/ust-consumer.cpp index 8bcc24612..a4de848cb 100644 --- a/src/bin/lttng-sessiond/ust-consumer.cpp +++ b/src/bin/lttng-sessiond/ust-consumer.cpp @@ -462,7 +462,7 @@ int ust_consumer_metadata_request(struct consumer_socket *socket) LTTNG_ASSERT(socket); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; health_code_update(); /* Wait for a metadata request */ diff --git a/src/bin/lttng-sessiond/ust-registry-channel.cpp b/src/bin/lttng-sessiond/ust-registry-channel.cpp index f4c8f226e..93e031733 100644 --- a/src/bin/lttng-sessiond/ust-registry-channel.cpp +++ b/src/bin/lttng-sessiond/ust-registry-channel.cpp @@ -381,7 +381,7 @@ void lsu::registry_channel::add_event(int session_objd, { uint32_t event_id; struct cds_lfht_node *nptr; - lttng::urcu::read_lock_guard read_lock_guard; + const lttng::urcu::read_lock_guard read_lock_guard; /* * This should not happen but since it comes from the UST tracer, an @@ -500,7 +500,7 @@ void lsu::registry_channel::_accept_on_event_classes( std::vector sorted_event_classes; { - lttng::urcu::read_lock_guard read_lock_guard; + const lttng::urcu::read_lock_guard read_lock_guard; struct lttng_ht_iter iter; const lttng::sessiond::ust::registry_event *event; diff --git a/src/bin/lttng-sessiond/ust-registry-session-pid.cpp b/src/bin/lttng-sessiond/ust-registry-session-pid.cpp index 49dc60d52..4463e78e9 100644 --- a/src/bin/lttng-sessiond/ust-registry-session-pid.cpp +++ b/src/bin/lttng-sessiond/ust-registry-session-pid.cpp @@ -28,7 +28,7 @@ lsu::registry_session_per_pid::registry_session_per_pid(const struct ust_app& ap _procname{ app.name }, _app_creation_time{ app.registration_time } { - lttng::pthread::lock_guard registry_lock(_lock); + const lttng::pthread::lock_guard registry_lock(_lock); _generate_metadata(); } diff --git a/src/bin/lttng-sessiond/ust-registry-session-uid.cpp b/src/bin/lttng-sessiond/ust-registry-session-uid.cpp index f5e1a93c2..3959d0394 100644 --- a/src/bin/lttng-sessiond/ust-registry-session-uid.cpp +++ b/src/bin/lttng-sessiond/ust-registry-session-uid.cpp @@ -22,7 +22,7 @@ lsu::registry_session_per_uid::registry_session_per_uid(const struct lst::abi& i registry_session{ in_abi, major, minor, root_shm_path, shm_path, euid, egid, tracing_id }, _tracing_uid{ tracing_uid } { - lttng::pthread::lock_guard registry_lock(_lock); + const lttng::pthread::lock_guard registry_lock(_lock); _generate_metadata(); } diff --git a/src/bin/lttng-sessiond/ust-registry-session.cpp b/src/bin/lttng-sessiond/ust-registry-session.cpp index 860e623cd..c6dac671d 100644 --- a/src/bin/lttng-sessiond/ust-registry-session.cpp +++ b/src/bin/lttng-sessiond/ust-registry-session.cpp @@ -123,7 +123,7 @@ void destroy_channel(lsu::registry_channel *chan, bool notify) noexcept } if (chan->_events) { - lttng::urcu::read_lock_guard read_lock_guard; + const lttng::urcu::read_lock_guard read_lock_guard; /* Destroy all event associated with this registry. */ DIAGNOSTIC_PUSH @@ -359,7 +359,7 @@ const lst::type *lsu::registry_session::packet_header() const noexcept void lsu::registry_session::_destroy_enum(lsu::registry_enum *reg_enum) noexcept { int ret; - lttng::urcu::read_lock_guard read_lock_guard; + const lttng::urcu::read_lock_guard read_lock_guard; LTTNG_ASSERT(reg_enum); ASSERT_RCU_READ_LOCKED(); @@ -384,7 +384,7 @@ lsu::registry_session::~registry_session() LTTNG_ASSERT(!ret); if (_channels) { - lttng::urcu::read_lock_guard read_lock_guard; + const lttng::urcu::read_lock_guard read_lock_guard; /* Destroy all event associated with this registry. */ DIAGNOSTIC_PUSH @@ -421,7 +421,7 @@ lsu::registry_session::~registry_session() /* Destroy the enum hash table */ if (_enums) { - lttng::urcu::read_lock_guard read_lock_guard; + const lttng::urcu::read_lock_guard read_lock_guard; /* Destroy all enum entries associated with this registry. */ DIAGNOSTIC_PUSH @@ -444,7 +444,7 @@ lsu::registry_session::locked_ref lsu::registry_session::lock() noexcept */ void lsu::registry_session::add_channel(uint64_t key) { - lttng::pthread::lock_guard session_lock_guard(_lock); + const lttng::pthread::lock_guard session_lock_guard(_lock); /* * Assign a channel ID right now since the event notification comes @@ -481,14 +481,14 @@ void lsu::registry_session::add_channel(uint64_t key) } }); - lttng::urcu::read_lock_guard rcu_read_lock_guard; + const lttng::urcu::read_lock_guard rcu_read_lock_guard; lttng_ht_node_init_u64(&chan->_node, key); lttng_ht_add_unique_u64(_channels.get(), &chan->_node); } lttng::sessiond::ust::registry_channel& lsu::registry_session::channel(uint64_t channel_key) const { - lttng::urcu::read_lock_guard read_lock_guard; + const lttng::urcu::read_lock_guard read_lock_guard; struct lttng_ht_node_u64 *node; struct lttng_ht_iter iter; @@ -512,7 +512,7 @@ void lsu::registry_session::remove_channel(uint64_t channel_key, bool notify) { struct lttng_ht_iter iter; int ret; - lttng::urcu::read_lock_guard read_lock_guard; + const lttng::urcu::read_lock_guard read_lock_guard; ASSERT_LOCKED(_lock); auto& channel_to_remove = channel(channel_key); @@ -566,7 +566,7 @@ void lsu::registry_session::_accept_on_stream_classes(lst::trace_class_visitor& std::vector sorted_stream_classes; { - lttng::urcu::read_lock_guard rcu_lock_guard; + const lttng::urcu::read_lock_guard rcu_lock_guard; const lsu::registry_channel *channel; lttng_ht_iter channel_it; @@ -680,7 +680,7 @@ void lsu::registry_session::_generate_metadata() void lsu::registry_session::regenerate_metadata() { - lttng::pthread::lock_guard registry_lock(_lock); + const lttng::pthread::lock_guard registry_lock(_lock); /* Resample the clock */ _clock = lttng::make_unique(); @@ -783,7 +783,7 @@ void lsu::registry_session::create_or_find_enum(int session_objd, { struct cds_lfht_node *nodep; lsu::registry_enum *reg_enum = nullptr, *old_reg_enum; - lttng::urcu::read_lock_guard read_lock_guard; + const lttng::urcu::read_lock_guard read_lock_guard; auto entries = lttng::make_unique_wrapper( raw_entries); diff --git a/src/bin/lttng/commands/add_trigger.cpp b/src/bin/lttng/commands/add_trigger.cpp index 54f41f28b..fa20cda61 100644 --- a/src/bin/lttng/commands/add_trigger.cpp +++ b/src/bin/lttng/commands/add_trigger.cpp @@ -980,7 +980,7 @@ static struct parse_event_rule_res parse_event_rule(int *argc, const char ***arg /* Set exclusion list. */ if (lttng_dynamic_pointer_array_get_count(&exclude_names) > 0) { int n; - int count = lttng_dynamic_pointer_array_get_count(&exclude_names); + const int count = lttng_dynamic_pointer_array_get_count(&exclude_names); for (n = 0; n < count; n++) { const char *exclude_name = @@ -1628,7 +1628,7 @@ static struct lttng_action *handle_action_simple_session_with_policy( } } else { const char *arg = argpar_item_non_opt_arg(argpar_item); - unsigned int idx = argpar_item_non_opt_non_opt_index(argpar_item); + const unsigned int idx = argpar_item_non_opt_non_opt_index(argpar_item); switch (idx) { case 0: @@ -2177,7 +2177,8 @@ int cmd_add_trigger(int argc, const char **argv) nullptr); if (status == PARSE_NEXT_ITEM_STATUS_ERROR) { if (argpar_error_type(argpar_error) == ARGPAR_ERROR_TYPE_MISSING_OPT_ARG) { - int opt_id = argpar_error_opt_descr(argpar_error, nullptr)->id; + const int opt_id = + argpar_error_opt_descr(argpar_error, nullptr)->id; if (opt_id == OPT_CONDITION) { print_valid_condition_names(); diff --git a/src/bin/lttng/commands/create.cpp b/src/bin/lttng/commands/create.cpp index e1756c3d3..189d7c2a0 100644 --- a/src/bin/lttng/commands/create.cpp +++ b/src/bin/lttng/commands/create.cpp @@ -523,7 +523,7 @@ static int spawn_sessiond(const char *pathname) */ for (;;) { int status; - pid_t wait_pid_ret = waitpid(pid, &status, 0); + const pid_t wait_pid_ret = waitpid(pid, &status, 0); if (wait_pid_ret < 0) { if (errno == EINTR) { diff --git a/src/bin/lttng/commands/destroy.cpp b/src/bin/lttng/commands/destroy.cpp index ef4b914d3..b39d70527 100644 --- a/src/bin/lttng/commands/destroy.cpp +++ b/src/bin/lttng/commands/destroy.cpp @@ -349,7 +349,7 @@ int cmd_destroy(int argc, const char **argv) static poptContext pc; const char *leftover = nullptr; lttng::cli::session_spec spec(lttng::cli::session_spec::type::NAME); - lttng::cli::session_list const sessions; + const lttng::cli::session_list sessions; pc = poptGetContext(nullptr, argc, argv, long_options, 0); poptReadDefaultConfig(pc, 0); diff --git a/src/bin/lttng/commands/list_triggers.cpp b/src/bin/lttng/commands/list_triggers.cpp index 03e567c86..0cedb2642 100644 --- a/src/bin/lttng/commands/list_triggers.cpp +++ b/src/bin/lttng/commands/list_triggers.cpp @@ -250,7 +250,7 @@ static void print_event_rule_kernel_tracepoint(const struct lttng_event_rule *ev static void print_event_rule_logging(const struct lttng_event_rule *event_rule) { enum lttng_event_rule_status event_rule_status; - enum lttng_event_rule_type event_rule_type = lttng_event_rule_get_type(event_rule); + const lttng_event_rule_type event_rule_type = lttng_event_rule_get_type(event_rule); const char *pattern; const char *filter; int log_level; diff --git a/src/bin/lttng/loglevel.cpp b/src/bin/lttng/loglevel.cpp index 739407236..d266baa44 100644 --- a/src/bin/lttng/loglevel.cpp +++ b/src/bin/lttng/loglevel.cpp @@ -225,7 +225,7 @@ bool loglevel_parse_range_string(const char *str, enum lttng_loglevel *max) { int min_int, max_int; - bool ret = loglevel_parse_range_string_common( + const bool ret = loglevel_parse_range_string_common( str, loglevel_values, ARRAY_SIZE(loglevel_values), &min_int, &max_int); *min = (lttng_loglevel) min_int; @@ -252,7 +252,7 @@ bool loglevel_log4j_parse_range_string(const char *str, enum lttng_loglevel_log4j *max) { int min_int, max_int; - bool ret = loglevel_parse_range_string_common( + const bool ret = loglevel_parse_range_string_common( str, loglevel_log4j_values, ARRAY_SIZE(loglevel_log4j_values), &min_int, &max_int); *min = (lttng_loglevel_log4j) min_int; @@ -279,7 +279,7 @@ bool loglevel_jul_parse_range_string(const char *str, enum lttng_loglevel_jul *max) { int min_int, max_int; - bool ret = loglevel_parse_range_string_common( + const bool ret = loglevel_parse_range_string_common( str, loglevel_jul_values, ARRAY_SIZE(loglevel_jul_values), &min_int, &max_int); *min = (lttng_loglevel_jul) min_int; @@ -306,11 +306,11 @@ bool loglevel_python_parse_range_string(const char *str, enum lttng_loglevel_python *max) { int min_int, max_int; - bool ret = loglevel_parse_range_string_common(str, - loglevel_python_values, - ARRAY_SIZE(loglevel_python_values), - &min_int, - &max_int); + const bool ret = loglevel_parse_range_string_common(str, + loglevel_python_values, + ARRAY_SIZE(loglevel_python_values), + &min_int, + &max_int); *min = (lttng_loglevel_python) min_int; *max = (lttng_loglevel_python) max_int; diff --git a/src/bin/lttng/utils.cpp b/src/bin/lttng/utils.cpp index 45fe256a5..6622d1aa8 100644 --- a/src/bin/lttng/utils.cpp +++ b/src/bin/lttng/utils.cpp @@ -758,36 +758,36 @@ void print_kernel_tracer_status_error() case LTTNG_KERNEL_TRACER_STATUS_INITIALIZED: return; case LTTNG_KERNEL_TRACER_STATUS_ERR_MODULES_UNKNOWN: - std::cerr << "\tKernel module loading failed" << std::endl; + std::cerr << "\tKernel module loading failed" << '\n'; break; case LTTNG_KERNEL_TRACER_STATUS_ERR_MODULES_MISSING: - std::cerr << "\tMissing one or more required kernel modules" << std::endl; + std::cerr << "\tMissing one or more required kernel modules" << '\n'; break; case LTTNG_KERNEL_TRACER_STATUS_ERR_MODULES_SIGNATURE: std::cerr << "\tKernel module signature error prevented loading of one or more required kernel modules" - << std::endl; + << '\n'; break; case LTTNG_KERNEL_TRACER_STATUS_ERR_NEED_ROOT: - std::cerr << "\tlttng-sessiond isn't running as root" << std::endl; + std::cerr << "\tlttng-sessiond isn't running as root" << '\n'; break; case LTTNG_KERNEL_TRACER_STATUS_ERR_NOTIFIER: - std::cerr << "\tFailed to setup notifiers" << std::endl; + std::cerr << "\tFailed to setup notifiers" << '\n'; break; case LTTNG_KERNEL_TRACER_STATUS_ERR_OPEN_PROC_LTTNG: - std::cerr << "\tlttng-sessiond failed to open /proc/lttng" << std::endl; + std::cerr << "\tlttng-sessiond failed to open /proc/lttng" << '\n'; break; case LTTNG_KERNEL_TRACER_STATUS_ERR_VERSION_MISMATCH: std::cerr << "\tVersion mismatch between kernel tracer and kernel tracer ABI" - << std::endl; + << '\n'; break; default: std::cerr << lttng::format("\t\tUnknown kernel tracer status (%d)", static_cast(kernel_tracer_status)) - << std::endl; + << '\n'; break; } - std::cerr << "\tConsult lttng-sessiond logs for more information" << std::endl; + std::cerr << "\tConsult lttng-sessiond logs for more information" << '\n'; } } diff --git a/src/common/argpar-utils/argpar-utils.cpp b/src/common/argpar-utils/argpar-utils.cpp index 7c8934778..27e08c7ee 100644 --- a/src/common/argpar-utils/argpar-utils.cpp +++ b/src/common/argpar-utils/argpar-utils.cpp @@ -74,7 +74,7 @@ static ATTR_FORMAT_PRINTF(4, 0) char *format_arg_error_v(const struct argpar_err { bool is_short; const struct argpar_opt_descr *descr = argpar_error_opt_descr(error, &is_short); - int orig_index = argpar_error_orig_index(error); + const int orig_index = argpar_error_orig_index(error); const char *arg = argv[orig_index]; if (is_short) { @@ -101,7 +101,7 @@ static ATTR_FORMAT_PRINTF(4, 0) char *format_arg_error_v(const struct argpar_err } case ARGPAR_ERROR_TYPE_UNKNOWN_OPT: { - int orig_index = argpar_error_orig_index(error); + const int orig_index = argpar_error_orig_index(error); const char *unknown_opt = argpar_error_unknown_opt_name(error); ret = strutils_appendf(&str, diff --git a/src/common/bytecode/bytecode.cpp b/src/common/bytecode/bytecode.cpp index 00b4f5e7b..e66f03bd3 100644 --- a/src/common/bytecode/bytecode.cpp +++ b/src/common/bytecode/bytecode.cpp @@ -40,10 +40,10 @@ int bytecode_init(struct lttng_bytecode_alloc **fb) static int32_t bytecode_reserve(struct lttng_bytecode_alloc **fb, uint32_t align, uint32_t len) { int32_t ret; - uint32_t padding = lttng_offset_align((*fb)->b.len, align); - uint32_t new_len = (*fb)->b.len + padding + len; + const uint32_t padding = lttng_offset_align((*fb)->b.len, align); + const uint32_t new_len = (*fb)->b.len + padding + len; uint32_t new_alloc_len = sizeof(struct lttng_bytecode_alloc) + new_len; - uint32_t old_alloc_len = (*fb)->alloc_len; + const uint32_t old_alloc_len = (*fb)->alloc_len; if (new_len > LTTNG_FILTER_MAX_LEN) return -EINVAL; diff --git a/src/common/compat/directory-handle.cpp b/src/common/compat/directory-handle.cpp index 157e9d4c2..afa6c9f09 100644 --- a/src/common/compat/directory-handle.cpp +++ b/src/common/compat/directory-handle.cpp @@ -318,7 +318,7 @@ static DIR *lttng_directory_handle_opendir(const struct lttng_directory_handle * const char *path) { DIR *dir_stream = nullptr; - int fd = openat(handle->dirfd, path, O_RDONLY); + const int fd = openat(handle->dirfd, path, O_RDONLY); if (fd < 0) { goto end; @@ -343,7 +343,7 @@ end: static int lttng_directory_handle_rmdir(const struct lttng_directory_handle *handle, const char *name) { - int ret = unlinkat(handle->dirfd, name, AT_REMOVEDIR); + const int ret = unlinkat(handle->dirfd, name, AT_REMOVEDIR); if (ret) { PERROR("Failed to remove directory `%s`", name); } diff --git a/src/common/conditions/buffer-usage.cpp b/src/common/conditions/buffer-usage.cpp index c78528735..692d605c9 100644 --- a/src/common/conditions/buffer-usage.cpp +++ b/src/common/conditions/buffer-usage.cpp @@ -22,7 +22,7 @@ static bool is_usage_evaluation(const struct lttng_evaluation *evaluation) { - enum lttng_condition_type type = lttng_evaluation_get_type(evaluation); + const lttng_condition_type type = lttng_evaluation_get_type(evaluation); return type == LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW || type == LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH; diff --git a/src/common/conditions/event-rule-matches.cpp b/src/common/conditions/event-rule-matches.cpp index d86d2ad7b..91012f475 100644 --- a/src/common/conditions/event-rule-matches.cpp +++ b/src/common/conditions/event-rule-matches.cpp @@ -30,7 +30,7 @@ static bool is_event_rule_matches_evaluation(const struct lttng_evaluation *evaluation) { - enum lttng_condition_type type = lttng_evaluation_get_type(evaluation); + const lttng_condition_type type = lttng_evaluation_get_type(evaluation); return type == LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES; } diff --git a/src/common/conditions/session-consumed-size.cpp b/src/common/conditions/session-consumed-size.cpp index 1e9cb4379..b6f2bbfa5 100644 --- a/src/common/conditions/session-consumed-size.cpp +++ b/src/common/conditions/session-consumed-size.cpp @@ -212,7 +212,7 @@ static ssize_t init_condition_from_payload(struct lttng_condition *condition, const char *session_name; struct lttng_buffer_view session_name_view; const struct lttng_condition_session_consumed_size_comm *condition_comm; - struct lttng_payload_view condition_comm_view = + const lttng_payload_view condition_comm_view = lttng_payload_view_from_view(src_view, 0, sizeof(*condition_comm)); if (!lttng_payload_view_is_valid(&condition_comm_view)) { diff --git a/src/common/conditions/session-rotation.cpp b/src/common/conditions/session-rotation.cpp index 20af727cf..45e360996 100644 --- a/src/common/conditions/session-rotation.cpp +++ b/src/common/conditions/session-rotation.cpp @@ -48,7 +48,7 @@ static const struct lttng_evaluation rotation_evaluation_template = { static bool is_rotation_condition(const struct lttng_condition *condition) { - enum lttng_condition_type type = lttng_condition_get_type(condition); + const lttng_condition_type type = lttng_condition_get_type(condition); return type == LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING || type == LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED; @@ -56,7 +56,7 @@ static bool is_rotation_condition(const struct lttng_condition *condition) static bool is_rotation_evaluation(const struct lttng_evaluation *evaluation) { - enum lttng_condition_type type = lttng_evaluation_get_type(evaluation); + const lttng_condition_type type = lttng_evaluation_get_type(evaluation); return type == LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING || type == LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED; @@ -187,7 +187,7 @@ static ssize_t init_condition_from_payload(struct lttng_condition *condition, const char *session_name; struct lttng_buffer_view name_view; const struct lttng_condition_session_rotation_comm *condition_comm; - struct lttng_payload_view condition_comm_view = + const lttng_payload_view condition_comm_view = lttng_payload_view_from_view(src_view, 0, sizeof(*condition_comm)); if (!lttng_payload_view_is_valid(&condition_comm_view)) { @@ -318,7 +318,8 @@ static ssize_t create_evaluation_from_payload(enum lttng_condition_type type, struct lttng_evaluation *evaluation = nullptr; struct lttng_trace_archive_location *location = nullptr; const struct lttng_evaluation_session_rotation_comm *comm; - struct lttng_payload_view comm_view = lttng_payload_view_from_view(view, 0, sizeof(*comm)); + const lttng_payload_view comm_view = + lttng_payload_view_from_view(view, 0, sizeof(*comm)); if (!lttng_payload_view_is_valid(&comm_view)) { goto error; diff --git a/src/common/consumer/consumer-stream.cpp b/src/common/consumer/consumer-stream.cpp index 0742c8652..e65592055 100644 --- a/src/common/consumer/consumer-stream.cpp +++ b/src/common/consumer/consumer-stream.cpp @@ -373,7 +373,7 @@ int consumer_stream_sync_metadata(struct lttng_consumer_local_data *ctx, uint64_ /* Ease our life a bit. */ ht = the_consumer_data.stream_list_ht; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* Search the metadata associated with the session id of the given stream. */ @@ -643,7 +643,7 @@ struct lttng_consumer_stream *consumer_stream_create(struct lttng_consumer_chann { int ret; struct lttng_consumer_stream *stream; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; stream = zmalloc(); if (stream == nullptr) { @@ -851,7 +851,7 @@ void consumer_stream_close_output(struct lttng_consumer_stream *stream) stream->trace_chunk = nullptr; /* Check and cleanup relayd if needed. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; relayd = consumer_find_relayd(stream->net_seq_idx); if (relayd != nullptr) { consumer_stream_relayd_close(stream, relayd); @@ -874,7 +874,7 @@ void consumer_stream_delete(struct lttng_consumer_stream *stream, struct lttng_h /* Should NEVER be called not in monitor mode. */ LTTNG_ASSERT(stream->chan->monitor); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; if (ht) { iter.iter.node = &stream->node.node; @@ -1093,7 +1093,7 @@ int consumer_stream_write_index(struct lttng_consumer_stream *stream, LTTNG_ASSERT(stream); LTTNG_ASSERT(element); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; if (stream->net_seq_idx != (uint64_t) -1ULL) { struct consumer_relayd_sock_pair *relayd; relayd = consumer_find_relayd(stream->net_seq_idx); diff --git a/src/common/consumer/consumer-timer.cpp b/src/common/consumer/consumer-timer.cpp index 70094ef4f..c4c45e8a1 100644 --- a/src/common/consumer/consumer-timer.cpp +++ b/src/common/consumer/consumer-timer.cpp @@ -284,7 +284,7 @@ static void live_timer(struct lttng_consumer_local_data *ctx, siginfo_t *si) DBG("Live timer for channel %" PRIu64, channel->key); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry_duplicate(ht->ht, ht->hash_fct(&channel->key, lttng_ht_seed), ht->match_fct, @@ -576,7 +576,7 @@ static int sample_channel_positions(struct lttng_consumer_channel *channel, *_total_consumed = 0; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry_duplicate(ht->ht, ht->hash_fct(&channel->key, lttng_ht_seed), @@ -644,7 +644,7 @@ end: void sample_and_send_channel_buffer_stats(struct lttng_consumer_channel *channel) { int ret; - int channel_monitor_pipe = consumer_timer_thread_get_channel_monitor_pipe(); + const int channel_monitor_pipe = consumer_timer_thread_get_channel_monitor_pipe(); struct lttcomm_consumer_channel_monitor_msg msg = { .key = channel->key, .session_id = channel->session_id, diff --git a/src/common/consumer/consumer.cpp b/src/common/consumer/consumer.cpp index ed25a42ea..295ea2726 100644 --- a/src/common/consumer/consumer.cpp +++ b/src/common/consumer/consumer.cpp @@ -199,7 +199,7 @@ static struct lttng_consumer_stream *find_stream(uint64_t key, struct lttng_ht * return nullptr; } - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; lttng_ht_lookup(ht, &key, &iter); node = lttng_ht_iter_get_node(&iter); @@ -214,7 +214,7 @@ static void steal_stream_key(uint64_t key, struct lttng_ht *ht) { struct lttng_consumer_stream *stream; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; stream = find_stream(key, ht); if (stream) { stream->key = (uint64_t) -1ULL; @@ -267,7 +267,7 @@ static void steal_channel_key(uint64_t key) { struct lttng_consumer_channel *channel; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; channel = consumer_find_channel(key); if (channel) { channel->key = (uint64_t) -1ULL; @@ -398,7 +398,7 @@ void consumer_del_channel(struct lttng_consumer_channel *channel) if (channel->is_published) { int ret; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; iter.iter.node = &channel->node.node; ret = lttng_ht_del(the_consumer_data.channel_ht, &iter); LTTNG_ASSERT(!ret); @@ -425,7 +425,7 @@ static void cleanup_relayd_ht() struct consumer_relayd_sock_pair *relayd; { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( the_consumer_data.relayd_ht->ht, &iter.iter, relayd, node.node) { @@ -451,7 +451,7 @@ static void update_endpoint_status_by_netidx(uint64_t net_seq_idx, DBG("Consumer set delete flag on stream by idx %" PRIu64, net_seq_idx); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* Let's begin with metadata */ cds_lfht_for_each_entry (metadata_ht->ht, &iter.iter, stream, node.node) { @@ -576,7 +576,7 @@ void consumer_add_data_stream(struct lttng_consumer_stream *stream) pthread_mutex_lock(&stream->chan->lock); pthread_mutex_lock(&stream->chan->timer_lock); pthread_mutex_lock(&stream->lock); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* Steal stream identifier to avoid having streams with the same key */ steal_stream_key(stream->key, ht); @@ -621,7 +621,7 @@ void consumer_add_data_stream(struct lttng_consumer_stream *stream) */ static int add_relayd(struct consumer_relayd_sock_pair *relayd) { - int ret = 0; + const int ret = 0; struct lttng_ht_node_u64 *node; struct lttng_ht_iter iter; @@ -714,7 +714,7 @@ int consumer_send_relayd_stream(struct lttng_consumer_stream *stream, char *path LTTNG_ASSERT(path); /* The stream is not metadata. Get relayd reference if exists. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; relayd = consumer_find_relayd(stream->net_seq_idx); if (relayd != nullptr) { /* Add stream on the relayd */ @@ -767,7 +767,7 @@ int consumer_send_relayd_streams_sent(uint64_t net_seq_idx) LTTNG_ASSERT(net_seq_idx != -1ULL); /* The stream is not metadata. Get relayd reference if exists. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; relayd = consumer_find_relayd(net_seq_idx); if (relayd != nullptr) { /* Add stream on the relayd */ @@ -801,7 +801,7 @@ void close_relayd_stream(struct lttng_consumer_stream *stream) struct consumer_relayd_sock_pair *relayd; /* The stream is not metadata. Get relayd reference if exists. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; relayd = consumer_find_relayd(stream->net_seq_idx); if (relayd) { consumer_stream_relayd_close(stream, relayd); @@ -1032,8 +1032,8 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, channel->monitor = monitor; channel->live_timer_interval = live_timer_interval; channel->is_live = is_in_live_session; - pthread_mutex_init(&channel->lock, NULL); - pthread_mutex_init(&channel->timer_lock, NULL); + pthread_mutex_init(&channel->lock, nullptr); + pthread_mutex_init(&channel->timer_lock, nullptr); switch (output) { case LTTNG_EVENT_SPLICE: @@ -1084,7 +1084,7 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, CDS_INIT_LIST_HEAD(&channel->streams.head); if (trace_chunk) { - int ret = lttng_consumer_channel_set_trace_chunk(channel, trace_chunk); + const int ret = lttng_consumer_channel_set_trace_chunk(channel, trace_chunk); if (ret) { goto error; } @@ -1120,7 +1120,7 @@ int consumer_add_channel(struct lttng_consumer_channel *channel, */ steal_channel_key(channel->key); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; lttng_ht_add_unique_u64(the_consumer_data.channel_ht, &channel->node); lttng_ht_add_u64(the_consumer_data.channels_by_session_id_ht, &channel->channels_by_session_id_ht_node); @@ -1163,7 +1163,7 @@ static int update_poll_array(struct lttng_consumer_local_data *ctx, *nb_inactive_fd = 0; { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ht->ht, &iter.iter, stream, node.node) { /* * Only active streams with an active end point can be added to the @@ -1276,7 +1276,7 @@ void lttng_consumer_cleanup() unsigned int trace_chunks_left; { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( the_consumer_data.channel_ht->ht, &iter.iter, channel, node.node) { @@ -1343,7 +1343,7 @@ void lttng_consumer_should_exit(struct lttng_consumer_local_data *ctx) */ static void lttng_consumer_sync_trace_file(struct lttng_consumer_stream *stream, off_t orig_offset) { - int outfd = stream->out_fd; + const int outfd = stream->out_fd; /* * This does a blocking write-and-wait on any page that belongs to the @@ -1461,7 +1461,7 @@ static void destroy_data_stream_ht(struct lttng_ht *ht) } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ht->ht, &iter.iter, stream, node.node) { /* * Ignore return value since we are currently cleaning up so any error @@ -1488,7 +1488,7 @@ static void destroy_metadata_stream_ht(struct lttng_ht *ht) } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ht->ht, &iter.iter, stream, node.node) { /* * Ignore return value since we are currently cleaning up so any error @@ -1598,7 +1598,7 @@ ssize_t lttng_consumer_on_read_subbuffer_mmap(struct lttng_consumer_stream *stre size_t write_len; /* RCU lock for the relayd pointer */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; LTTNG_ASSERT(stream->net_seq_idx != (uint64_t) -1ULL || stream->trace_chunk); /* Flag that the current stream if set for network streaming. */ @@ -1755,7 +1755,7 @@ ssize_t lttng_consumer_on_read_subbuffer_splice(struct lttng_consumer_local_data ssize_t ret = 0, written = 0, ret_splice = 0; loff_t offset = 0; off_t orig_offset = stream->out_fd_offset; - int fd = stream->wait_fd; + const int fd = stream->wait_fd; /* Default is on the disk */ int outfd = stream->out_fd; struct consumer_relayd_sock_pair *relayd = nullptr; @@ -1775,7 +1775,7 @@ ssize_t lttng_consumer_on_read_subbuffer_splice(struct lttng_consumer_local_data } /* RCU lock for the relayd pointer */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* Flag that the current stream if set for network streaming. */ if (stream->net_seq_idx != (uint64_t) -1ULL) { @@ -1872,7 +1872,7 @@ ssize_t lttng_consumer_on_read_subbuffer_splice(struct lttng_consumer_local_data /* Handle stream on the relayd if the output is on the network */ if (relayd && stream->metadata_flag) { - size_t metadata_payload_size = + const size_t metadata_payload_size = sizeof(struct lttcomm_relayd_metadata_payload); /* Update counter to fit the spliced data */ @@ -2178,7 +2178,7 @@ void consumer_add_metadata_stream(struct lttng_consumer_stream *stream) * after this point. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* * Lookup the stream just to make sure it does not exist in our internal @@ -2229,7 +2229,7 @@ static void validate_endpoint_status_data_stream() DBG("Consumer delete flagged data stream"); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (data_ht->ht, &iter.iter, stream, node.node) { /* Validate delete flag of the stream */ @@ -2255,7 +2255,7 @@ static void validate_endpoint_status_metadata_stream(struct lttng_poll_event *po LTTNG_ASSERT(pollset); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (metadata_ht->ht, &iter.iter, stream, node.node) { /* Validate delete flag of the stream */ if (stream->endpoint_status == CONSUMER_ENDPOINT_ACTIVE) { @@ -2405,7 +2405,7 @@ void *consumer_thread_metadata_poll(void *data) continue; } - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; { uint64_t tmp_id = (uint64_t) pollfd; @@ -2806,7 +2806,7 @@ static void consumer_close_channel_streams(struct lttng_consumer_channel *channe ht = the_consumer_data.stream_per_chan_id_ht; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry_duplicate(ht->ht, ht->hash_fct(&channel->key, lttng_ht_seed), ht->match_fct, @@ -2859,7 +2859,7 @@ static void destroy_channel_ht(struct lttng_ht *ht) } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (ht->ht, &iter.iter, channel, wait_fd_node.node) { ret = lttng_ht_del(ht, &iter); @@ -2972,7 +2972,7 @@ void *consumer_thread_channel_poll(void *data) lttng_ht_node_init_u64(&chan->wait_fd_node, chan->wait_fd); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; lttng_ht_add_unique_u64(channel_ht, &chan->wait_fd_node); /* Add channel to the global poll events list */ @@ -2993,7 +2993,7 @@ void *consumer_thread_channel_poll(void *data) * GET_CHANNEL failed. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; chan = consumer_find_channel(key); if (!chan) { ERR("UST consumer get channel key %" PRIu64 @@ -3061,7 +3061,7 @@ void *consumer_thread_channel_poll(void *data) continue; } - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; { uint64_t tmp_id = (uint64_t) pollfd; @@ -3739,7 +3739,7 @@ int consumer_data_pending(uint64_t id) DBG("Consumer data pending command on session id %" PRIu64, id); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; pthread_mutex_lock(&the_consumer_data.lock); switch (the_consumer_data.type) { @@ -3984,7 +3984,7 @@ int lttng_consumer_rotate_channel(struct lttng_consumer_channel *channel, nullptr); lttng_dynamic_pointer_array_init(&streams_packet_to_open, nullptr); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; pthread_mutex_lock(&channel->lock); LTTNG_ASSERT(channel->trace_chunk); @@ -4422,7 +4422,7 @@ static int consumer_clear_unmonitored_channel(struct lttng_consumer_channel *cha int ret; struct lttng_consumer_stream *stream; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; pthread_mutex_lock(&channel->lock); cds_list_for_each_entry (stream, &channel->streams.head, send_node) { health_code_update(); @@ -4634,7 +4634,7 @@ int lttng_consumer_rotate_ready_streams(struct lttng_consumer_channel *channel, ASSERT_RCU_READ_LOCKED(); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; DBG("Consumer rotate ready streams in channel %" PRIu64, key); @@ -4798,7 +4798,7 @@ lttng_consumer_create_trace_chunk(const uint64_t *relayd_id, } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry_duplicate( the_consumer_data.channels_by_session_id_ht->ht, the_consumer_data.channels_by_session_id_ht->hash_fct(&session_id, @@ -4954,7 +4954,7 @@ lttng_consumer_close_trace_chunk(const uint64_t *relayd_id, * current chunk found in the session's channels. */ { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( the_consumer_data.channel_ht->ht, &iter.iter, channel, node.node) { int ret; @@ -5019,7 +5019,7 @@ lttng_consumer_trace_chunk_exists(const uint64_t *relayd_id, uint64_t session_id const bool is_local_trace = !relayd_id; struct consumer_relayd_sock_pair *relayd = nullptr; bool chunk_exists_local, chunk_exists_remote; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; if (relayd_id) { /* Only used for logging purposes. */ @@ -5086,7 +5086,7 @@ static int consumer_clear_monitored_channel(struct lttng_consumer_channel *chann ht = the_consumer_data.stream_per_chan_id_ht; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry_duplicate(ht->ht, ht->hash_fct(&channel->key, lttng_ht_seed), ht->match_fct, @@ -5154,7 +5154,7 @@ enum lttcomm_return_code lttng_consumer_open_channel_packets(struct lttng_consum } { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_list_for_each_entry (stream, &channel->streams.head, send_node) { enum consumer_stream_open_packet_status status; diff --git a/src/common/dynamic-buffer.cpp b/src/common/dynamic-buffer.cpp index b64e9676a..1fbb5e6cd 100644 --- a/src/common/dynamic-buffer.cpp +++ b/src/common/dynamic-buffer.cpp @@ -132,7 +132,7 @@ int lttng_dynamic_buffer_set_capacity(struct lttng_dynamic_buffer *buffer, size_ { int ret = 0; void *new_buf; - size_t new_capacity = demanded_capacity ? round_to_power_of_2(demanded_capacity) : 0; + const size_t new_capacity = demanded_capacity ? round_to_power_of_2(demanded_capacity) : 0; if (!buffer || demanded_capacity < buffer->size) { /* diff --git a/src/common/error-query.cpp b/src/common/error-query.cpp index 2410d9b1c..4b5f27e57 100644 --- a/src/common/error-query.cpp +++ b/src/common/error-query.cpp @@ -452,7 +452,7 @@ ssize_t lttng_error_query_result_create_from_payload(struct lttng_payload_view * { ssize_t used_size = 0; struct lttng_error_query_result_comm *header; - struct lttng_payload_view header_view = + const lttng_payload_view header_view = lttng_payload_view_from_view(view, 0, sizeof(*header)); const char *name; const char *description; @@ -466,7 +466,7 @@ ssize_t lttng_error_query_result_create_from_payload(struct lttng_payload_view * used_size += sizeof(*header); { - struct lttng_payload_view name_view = + const lttng_payload_view name_view = lttng_payload_view_from_view(view, used_size, header->name_len); if (!lttng_payload_view_is_valid(&name_view) || @@ -481,7 +481,7 @@ ssize_t lttng_error_query_result_create_from_payload(struct lttng_payload_view * } { - struct lttng_payload_view description_view = + const lttng_payload_view description_view = lttng_payload_view_from_view(view, used_size, header->description_len); if (!lttng_payload_view_is_valid(&description_view) || @@ -500,7 +500,7 @@ ssize_t lttng_error_query_result_create_from_payload(struct lttng_payload_view * case LTTNG_ERROR_QUERY_RESULT_TYPE_COUNTER: { struct lttng_error_query_result_counter_comm *counter; - struct lttng_payload_view counter_payload_view = + const lttng_payload_view counter_payload_view = lttng_payload_view_from_view(view, used_size, sizeof(*counter)); if (!lttng_payload_view_is_valid(&counter_payload_view)) { @@ -567,7 +567,7 @@ ssize_t lttng_error_query_results_create_from_payload(struct lttng_payload_view size_t result_index; ssize_t total_used_size = 0; struct lttng_error_query_results_comm *header; - struct lttng_payload_view header_view = + const lttng_payload_view header_view = lttng_payload_view_from_view(view, 0, sizeof(*header)); struct lttng_error_query_results *results = nullptr; @@ -778,7 +778,7 @@ ssize_t lttng_error_query_create_from_payload(struct lttng_payload_view *view, ssize_t used_size = 0; struct lttng_error_query_comm *header; struct lttng_trigger *trigger = nullptr; - struct lttng_payload_view header_view = + const lttng_payload_view header_view = lttng_payload_view_from_view(view, 0, sizeof(*header)); if (!lttng_payload_view_is_valid(&header_view)) { diff --git a/src/common/evaluation.cpp b/src/common/evaluation.cpp index 150e1c3f9..25c366f46 100644 --- a/src/common/evaluation.cpp +++ b/src/common/evaluation.cpp @@ -52,7 +52,7 @@ ssize_t lttng_evaluation_create_from_payload(const struct lttng_condition *condi { ssize_t ret, evaluation_size = 0; const struct lttng_evaluation_comm *evaluation_comm; - struct lttng_payload_view evaluation_comm_view = + const lttng_payload_view evaluation_comm_view = lttng_payload_view_from_view(src_view, 0, sizeof(*evaluation_comm)); struct lttng_payload_view evaluation_view = lttng_payload_view_from_view(src_view, sizeof(*evaluation_comm), -1); diff --git a/src/common/event-rule/event-rule.cpp b/src/common/event-rule/event-rule.cpp index 3e862b246..197d4b011 100644 --- a/src/common/event-rule/event-rule.cpp +++ b/src/common/event-rule/event-rule.cpp @@ -283,7 +283,7 @@ struct lttng_event *lttng_event_rule_generate_lttng_event(const struct lttng_eve bool lttng_event_rule_targets_agent_domain(const struct lttng_event_rule *rule) { bool targets_agent_domain = false; - enum lttng_domain_type type = lttng_event_rule_get_domain_type(rule); + const lttng_domain_type type = lttng_event_rule_get_domain_type(rule); switch (type) { case LTTNG_DOMAIN_JUL: diff --git a/src/common/event-rule/kernel-kprobe.cpp b/src/common/event-rule/kernel-kprobe.cpp index bae7bdfa7..badfa4e79 100644 --- a/src/common/event-rule/kernel-kprobe.cpp +++ b/src/common/event-rule/kernel-kprobe.cpp @@ -339,7 +339,7 @@ ssize_t lttng_event_rule_kernel_kprobe_create_from_payload(struct lttng_payload_ { /* Map the name. */ - struct lttng_payload_view current_payload_view = + const lttng_payload_view current_payload_view = lttng_payload_view_from_view(view, offset, kprobe_comm->name_len); if (!lttng_payload_view_is_valid(¤t_payload_view)) { diff --git a/src/common/event.cpp b/src/common/event.cpp index a6d48eaf7..e4b41b729 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -142,7 +142,7 @@ lttng_event_probe_attr_create_from_payload(struct lttng_payload_view *view, ssize_t ret, offset = 0; const struct lttng_event_probe_attr_comm *comm; struct lttng_event_probe_attr *local_attr = nullptr; - struct lttng_payload_view comm_view = + const lttng_payload_view comm_view = lttng_payload_view_from_view(view, offset, sizeof(*comm)); if (!lttng_payload_view_is_valid(&comm_view)) { @@ -164,7 +164,7 @@ lttng_event_probe_attr_create_from_payload(struct lttng_payload_view *view, { const char *name; - struct lttng_payload_view name_view = + const lttng_payload_view name_view = lttng_payload_view_from_view(view, offset, comm->symbol_name_len); if (!lttng_payload_view_is_valid(&name_view)) { @@ -204,7 +204,7 @@ lttng_event_function_attr_create_from_payload(struct lttng_payload_view *view, ssize_t ret, offset = 0; const struct lttng_event_function_attr_comm *comm; struct lttng_event_function_attr *local_attr = nullptr; - struct lttng_payload_view comm_view = + const lttng_payload_view comm_view = lttng_payload_view_from_view(view, offset, sizeof(*comm)); if (!lttng_payload_view_is_valid(&comm_view)) { @@ -223,7 +223,7 @@ lttng_event_function_attr_create_from_payload(struct lttng_payload_view *view, { const char *name; - struct lttng_payload_view name_view = + const lttng_payload_view name_view = lttng_payload_view_from_view(view, offset, comm->symbol_name_len); if (!lttng_payload_view_is_valid(&name_view)) { @@ -346,7 +346,7 @@ ssize_t lttng_event_create_from_payload(struct lttng_payload_view *view, assert(view); { - struct lttng_payload_view comm_view = + const lttng_payload_view comm_view = lttng_payload_view_from_view(view, offset, sizeof(*event_comm)); if (!lttng_payload_view_is_valid(&comm_view)) { @@ -441,7 +441,7 @@ deserialize_filter_expression: { const char *filter_expression_buffer; - struct lttng_buffer_view filter_expression_view = lttng_buffer_view_from_view( + const lttng_buffer_view filter_expression_view = lttng_buffer_view_from_view( &view->buffer, offset, event_comm->filter_expression_len); if (!lttng_buffer_view_is_valid(&filter_expression_view)) { @@ -480,7 +480,7 @@ deserialize_filter_expression: /* Bytecode */ { - struct lttng_payload_view bytecode_view = + const lttng_payload_view bytecode_view = lttng_payload_view_from_view(view, offset, event_comm->bytecode_len); if (!lttng_payload_view_is_valid(&bytecode_view)) { @@ -1019,7 +1019,7 @@ ssize_t lttng_event_context_create_from_payload(struct lttng_payload_view *view, ssize_t ret, offset = 0; const struct lttng_event_context_comm *comm; struct lttng_event_context *local_context = nullptr; - struct lttng_buffer_view comm_view = + const lttng_buffer_view comm_view = lttng_buffer_view_from_view(&view->buffer, offset, sizeof(*comm)); assert(event_ctx); @@ -1042,7 +1042,7 @@ ssize_t lttng_event_context_create_from_payload(struct lttng_payload_view *view, local_context->ctx = (lttng_event_context_type) comm->type; { - struct lttng_payload_view subtype_view = + const lttng_payload_view subtype_view = lttng_payload_view_from_view(view, offset, -1); switch (local_context->ctx) { diff --git a/src/common/fd-tracker/fd-tracker.cpp b/src/common/fd-tracker/fd-tracker.cpp index 7f4c2b5b2..1db2c4245 100644 --- a/src/common/fd-tracker/fd-tracker.cpp +++ b/src/common/fd-tracker/fd-tracker.cpp @@ -427,7 +427,7 @@ void fd_tracker_log(struct fd_tracker *tracker) DBG_NO_LOC(" Tracked unsuspendable file descriptors"); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( tracker->unsuspendable_fds, &iter, unsuspendable_fd, tracker_node) { @@ -604,7 +604,7 @@ int fd_tracker_open_unsuspendable_fd(struct fd_tracker *tracker, int ret, user_ret, i, fds_to_suspend; unsigned int active_fds; struct unsuspendable_fd **entries; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; entries = calloc(fd_count); if (!entries) { @@ -695,7 +695,7 @@ int fd_tracker_close_unsuspendable_fd(struct fd_tracker *tracker, { int i, ret, user_ret; int *fds = nullptr; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* * Maintain a local copy of fds_in as the user's callback may modify its diff --git a/src/common/fd-tracker/inode.cpp b/src/common/fd-tracker/inode.cpp index c98f6ad45..5d0dd2020 100644 --- a/src/common/fd-tracker/inode.cpp +++ b/src/common/fd-tracker/inode.cpp @@ -212,7 +212,7 @@ static void lttng_inode_destroy(struct lttng_inode *inode) return; } - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_del(inode->registry_ht, &inode->registry_node); if (inode->unlink_pending) { @@ -476,7 +476,7 @@ void lttng_inode_registry_destroy(struct lttng_inode_registry *registry) return; } if (registry->inodes) { - int ret = cds_lfht_destroy(registry->inodes, nullptr); + const int ret = cds_lfht_destroy(registry->inodes, nullptr); LTTNG_ASSERT(!ret); } @@ -496,7 +496,7 @@ lttng_inode_registry_get_inode(struct lttng_inode_registry *registry, struct cds_lfht_iter iter; struct cds_lfht_node *node; struct lttng_inode *inode = nullptr; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; ret = fstat(fd, &statbuf); if (ret < 0) { diff --git a/src/common/filter/filter-ast.hpp b/src/common/filter/filter-ast.hpp index 51a36326b..8448717d6 100644 --- a/src/common/filter/filter-ast.hpp +++ b/src/common/filter/filter-ast.hpp @@ -28,7 +28,7 @@ // the parameter name (of the reentrant 'yyparse' function) // data is a pointer to a 'SParserParam' structure -//#define YYPARSE_PARAM parser_ctx +// #define YYPARSE_PARAM parser_ctx #ifndef YY_TYPEDEF_YY_SCANNER_T #define YY_TYPEDEF_YY_SCANNER_T diff --git a/src/common/hashtable/hashtable.cpp b/src/common/hashtable/hashtable.cpp index be7e77342..a410fc41c 100644 --- a/src/common/hashtable/hashtable.cpp +++ b/src/common/hashtable/hashtable.cpp @@ -273,7 +273,7 @@ void lttng_ht_add_unique_str(struct lttng_ht *ht, struct lttng_ht_node_str *node LTTNG_ASSERT(node); /* RCU read lock protects from ABA. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; node_ptr = cds_lfht_add_unique(ht->ht, ht->hash_fct(node->key, lttng_ht_seed), ht->match_fct, @@ -292,7 +292,7 @@ void lttng_ht_add_str(struct lttng_ht *ht, struct lttng_ht_node_str *node) LTTNG_ASSERT(node); /* RCU read lock protects from ABA. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_add(ht->ht, ht->hash_fct(node->key, lttng_ht_seed), &node->node); } @@ -306,7 +306,7 @@ void lttng_ht_add_ulong(struct lttng_ht *ht, struct lttng_ht_node_ulong *node) LTTNG_ASSERT(node); /* RCU read lock protects from ABA. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_add(ht->ht, ht->hash_fct((void *) node->key, lttng_ht_seed), &node->node); } @@ -320,7 +320,7 @@ void lttng_ht_add_u64(struct lttng_ht *ht, struct lttng_ht_node_u64 *node) LTTNG_ASSERT(node); /* RCU read lock protects from ABA. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_add(ht->ht, ht->hash_fct(&node->key, lttng_ht_seed), &node->node); } @@ -335,7 +335,7 @@ void lttng_ht_add_unique_ulong(struct lttng_ht *ht, struct lttng_ht_node_ulong * LTTNG_ASSERT(node); /* RCU read lock protects from ABA. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; node_ptr = cds_lfht_add_unique(ht->ht, ht->hash_fct((void *) node->key, lttng_ht_seed), ht->match_fct, @@ -355,7 +355,7 @@ void lttng_ht_add_unique_u64(struct lttng_ht *ht, struct lttng_ht_node_u64 *node LTTNG_ASSERT(node); /* RCU read lock protects from ABA. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; node_ptr = cds_lfht_add_unique(ht->ht, ht->hash_fct(&node->key, lttng_ht_seed), ht->match_fct, @@ -375,7 +375,7 @@ void lttng_ht_add_unique_two_u64(struct lttng_ht *ht, struct lttng_ht_node_two_u LTTNG_ASSERT(node); /* RCU read lock protects from ABA. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; node_ptr = cds_lfht_add_unique(ht->ht, ht->hash_fct((void *) &node->key, lttng_ht_seed), ht->match_fct, @@ -396,7 +396,7 @@ struct lttng_ht_node_ulong *lttng_ht_add_replace_ulong(struct lttng_ht *ht, LTTNG_ASSERT(node); /* RCU read lock protects from ABA. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; node_ptr = cds_lfht_add_replace(ht->ht, ht->hash_fct((void *) node->key, lttng_ht_seed), ht->match_fct, @@ -421,7 +421,7 @@ struct lttng_ht_node_u64 *lttng_ht_add_replace_u64(struct lttng_ht *ht, LTTNG_ASSERT(node); /* RCU read lock protects from ABA. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; node_ptr = cds_lfht_add_replace(ht->ht, ht->hash_fct(&node->key, lttng_ht_seed), ht->match_fct, @@ -447,7 +447,7 @@ int lttng_ht_del(struct lttng_ht *ht, struct lttng_ht_iter *iter) LTTNG_ASSERT(iter); /* RCU read lock protects from ABA. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; ret = cds_lfht_del(ht->ht, iter->iter.node); return ret; } @@ -488,7 +488,7 @@ unsigned long lttng_ht_get_count(struct lttng_ht *ht) LTTNG_ASSERT(ht->ht); /* RCU read lock protects from ABA and allows RCU traversal. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_count_nodes(ht->ht, &scb, &count, &sca); return count; diff --git a/src/common/index/index.cpp b/src/common/index/index.cpp index 863a4c52b..e24c48a47 100644 --- a/src/common/index/index.cpp +++ b/src/common/index/index.cpp @@ -99,7 +99,7 @@ _lttng_index_file_create_from_trace_chunk(struct lttng_trace_chunk *chunk, chunk_status = (lttng_trace_chunk_status) lttng_trace_chunk_unlink_file( chunk, index_file_path); if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK && - !(chunk_status == LTTNG_TRACE_CHUNK_STATUS_ERROR && errno == ENOENT)) { + (chunk_status != LTTNG_TRACE_CHUNK_STATUS_ERROR || errno != ENOENT)) { goto error; } } diff --git a/src/common/ini-config/ini-config.cpp b/src/common/ini-config/ini-config.cpp index ebfe153c2..238962706 100644 --- a/src/common/ini-config/ini-config.cpp +++ b/src/common/ini-config/ini-config.cpp @@ -36,7 +36,7 @@ static int config_entry_handler_filter(struct handler_filter_args *args, const char *value) { int ret = 0; - struct config_entry entry = { section, name, value }; + const config_entry entry = { section, name, value }; LTTNG_ASSERT(args); diff --git a/src/common/ini-config/ini.cpp b/src/common/ini-config/ini.cpp index c17a8c0e8..e6fba384e 100644 --- a/src/common/ini-config/ini.cpp +++ b/src/common/ini-config/ini.cpp @@ -75,7 +75,7 @@ static char *find_char_or_comment(const char *s, char c) { int was_whitespace = 0; - while (*s && *s != c && !(was_whitespace && *s == ';')) { + while (*s && *s != c && (!was_whitespace || *s != ';')) { was_whitespace = isspace((unsigned char) (*s)); s++; } diff --git a/src/common/kernel-consumer/kernel-consumer.cpp b/src/common/kernel-consumer/kernel-consumer.cpp index 7e8de03f6..fe360ea69 100644 --- a/src/common/kernel-consumer/kernel-consumer.cpp +++ b/src/common/kernel-consumer/kernel-consumer.cpp @@ -52,7 +52,7 @@ extern int consumer_poll_timeout; int lttng_kconsumer_take_snapshot(struct lttng_consumer_stream *stream) { int ret = 0; - int infd = stream->wait_fd; + const int infd = stream->wait_fd; ret = kernctl_snapshot(infd); /* @@ -86,7 +86,7 @@ int lttng_kconsumer_sample_snapshot_positions(struct lttng_consumer_stream *stre int lttng_kconsumer_get_produced_snapshot(struct lttng_consumer_stream *stream, unsigned long *pos) { int ret; - int infd = stream->wait_fd; + const int infd = stream->wait_fd; ret = kernctl_snapshot_get_produced(infd, pos); if (ret != 0) { @@ -104,7 +104,7 @@ int lttng_kconsumer_get_produced_snapshot(struct lttng_consumer_stream *stream, int lttng_kconsumer_get_consumed_snapshot(struct lttng_consumer_stream *stream, unsigned long *pos) { int ret; - int infd = stream->wait_fd; + const int infd = stream->wait_fd; ret = kernctl_snapshot_get_consumed(infd, pos); if (ret != 0) { @@ -152,7 +152,7 @@ static int lttng_kconsumer_snapshot_channel(struct lttng_consumer_channel *chann /* Prevent channel modifications while we perform the snapshot.*/ pthread_mutex_lock(&channel->lock); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; /* Splice is not supported yet for channel snapshot. */ if (channel->output != CONSUMER_CHANNEL_MMAP) { @@ -354,7 +354,7 @@ static int lttng_kconsumer_snapshot_metadata(struct lttng_consumer_channel *meta DBG("Kernel consumer snapshot metadata with key %" PRIu64 " at path %s", key, path); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; metadata_stream = metadata_channel->metadata_stream; LTTNG_ASSERT(metadata_stream); @@ -454,14 +454,14 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, health_code_update(); /* relayd needs RCU read-side protection */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; switch (msg.cmd_type) { case LTTNG_CONSUMER_ADD_RELAYD_SOCKET: { - uint32_t major = msg.u.relayd_sock.major; - uint32_t minor = msg.u.relayd_sock.minor; - enum lttcomm_sock_proto protocol = + const uint32_t major = msg.u.relayd_sock.major; + const uint32_t minor = msg.u.relayd_sock.minor; + const lttcomm_sock_proto protocol = (enum lttcomm_sock_proto) msg.u.relayd_sock.relayd_socket_protocol; /* Session daemon status message are handled in the following call. */ @@ -542,7 +542,7 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, health_code_update(); if (ctx->on_recv_channel != nullptr) { - int ret_recv_channel = ctx->on_recv_channel(new_channel); + const int ret_recv_channel = ctx->on_recv_channel(new_channel); if (ret_recv_channel == 0) { ret_add_channel = consumer_add_channel(new_channel, ctx); } else if (ret_recv_channel < 0) { @@ -709,7 +709,7 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, pthread_mutex_lock(&new_stream->lock); if (ctx->on_recv_stream) { - int ret_recv_stream = ctx->on_recv_stream(new_stream); + const int ret_recv_stream = ctx->on_recv_stream(new_stream); if (ret_recv_stream < 0) { pthread_mutex_unlock(&new_stream->lock); pthread_mutex_unlock(&channel->lock); @@ -875,7 +875,7 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, } case LTTNG_CONSUMER_DESTROY_RELAYD: { - uint64_t index = msg.u.destroy_relayd.net_seq_idx; + const uint64_t index = msg.u.destroy_relayd.net_seq_idx; struct consumer_relayd_sock_pair *relayd; int ret_send_status; @@ -915,7 +915,7 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, case LTTNG_CONSUMER_DATA_PENDING: { int32_t ret_data_pending; - uint64_t id = msg.u.data_pending.session_id; + const uint64_t id = msg.u.data_pending.session_id; ssize_t ret_send; DBG("Kernel consumer data pending command for id %" PRIu64, id); @@ -941,7 +941,7 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, case LTTNG_CONSUMER_SNAPSHOT_CHANNEL: { struct lttng_consumer_channel *channel; - uint64_t key = msg.u.snapshot_channel.key; + const uint64_t key = msg.u.snapshot_channel.key; int ret_send_status; channel = consumer_find_channel(key); @@ -988,7 +988,7 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, } case LTTNG_CONSUMER_DESTROY_CHANNEL: { - uint64_t key = msg.u.destroy_channel.key; + const uint64_t key = msg.u.destroy_channel.key; struct lttng_consumer_channel *channel; int ret_send_status; @@ -1034,8 +1034,8 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, ssize_t ret; uint64_t count; struct lttng_consumer_channel *channel; - uint64_t id = msg.u.discarded_events.session_id; - uint64_t key = msg.u.discarded_events.channel_key; + const uint64_t id = msg.u.discarded_events.session_id; + const uint64_t key = msg.u.discarded_events.channel_key; DBG("Kernel consumer discarded events command for session id %" PRIu64 ", channel key %" PRIu64, @@ -1066,8 +1066,8 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, ssize_t ret; uint64_t count; struct lttng_consumer_channel *channel; - uint64_t id = msg.u.lost_packets.session_id; - uint64_t key = msg.u.lost_packets.channel_key; + const uint64_t id = msg.u.lost_packets.session_id; + const uint64_t key = msg.u.lost_packets.channel_key; DBG("Kernel consumer lost packets command for session id %" PRIu64 ", channel key %" PRIu64, @@ -1146,7 +1146,7 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, case LTTNG_CONSUMER_ROTATE_CHANNEL: { struct lttng_consumer_channel *channel; - uint64_t key = msg.u.rotate_channel.key; + const uint64_t key = msg.u.rotate_channel.key; int ret_send_status; DBG("Consumer rotate channel %" PRIu64, key); @@ -1192,7 +1192,7 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, case LTTNG_CONSUMER_CLEAR_CHANNEL: { struct lttng_consumer_channel *channel; - uint64_t key = msg.u.clear_channel.key; + const uint64_t key = msg.u.clear_channel.key; int ret_send_status; channel = consumer_find_channel(key); diff --git a/src/common/log-level-rule.cpp b/src/common/log-level-rule.cpp index 6673ddc8d..2962b7f8c 100644 --- a/src/common/log-level-rule.cpp +++ b/src/common/log-level-rule.cpp @@ -20,14 +20,14 @@ static bool is_log_level_rule_exactly_type(const struct lttng_log_level_rule *rule) { - enum lttng_log_level_rule_type type = lttng_log_level_rule_get_type(rule); + const lttng_log_level_rule_type type = lttng_log_level_rule_get_type(rule); return type == LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY; } static bool is_log_level_rule_at_least_as_severe_type(const struct lttng_log_level_rule *rule) { - enum lttng_log_level_rule_type type = lttng_log_level_rule_get_type(rule); + const lttng_log_level_rule_type type = lttng_log_level_rule_get_type(rule); return type == LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS; } diff --git a/src/common/lttng-elf.cpp b/src/common/lttng-elf.cpp index be1db0250..8094b4967 100644 --- a/src/common/lttng-elf.cpp +++ b/src/common/lttng-elf.cpp @@ -610,7 +610,7 @@ static int lttng_elf_get_section_hdr_by_name(struct lttng_elf *elf, for (i = 0; i < elf->ehdr->e_shnum; ++i) { bool name_equal; - int ret = lttng_elf_get_section_hdr(elf, i, section_hdr); + const int ret = lttng_elf_get_section_hdr(elf, i, section_hdr); if (ret) { break; @@ -823,10 +823,10 @@ int lttng_elf_get_symbol_offset(int fd, char *symbol, uint64_t *offset) /* Get the symbol at the current index. */ if (is_elf_32_bit(elf)) { - Elf32_Sym tmp = ((Elf32_Sym *) symbol_table_data)[sym_idx]; + const Elf32_Sym tmp = ((Elf32_Sym *) symbol_table_data)[sym_idx]; copy_sym(tmp, curr_sym); } else { - Elf64_Sym tmp = ((Elf64_Sym *) symbol_table_data)[sym_idx]; + const Elf64_Sym tmp = ((Elf64_Sym *) symbol_table_data)[sym_idx]; copy_sym(tmp, curr_sym); } diff --git a/src/common/pthread-lock.hpp b/src/common/pthread-lock.hpp index 7d037e472..5a57b9715 100644 --- a/src/common/pthread-lock.hpp +++ b/src/common/pthread-lock.hpp @@ -33,9 +33,9 @@ public: ~mutex() = default; /* "Not copyable" and "not moveable" Mutex requirements. */ - mutex(mutex const&) = delete; + mutex(const mutex&) = delete; mutex(mutex&&) = delete; - mutex& operator=(mutex const&) = delete; + mutex& operator=(const mutex&) = delete; mutex& operator=(mutex&&) = delete; void lock() diff --git a/src/common/reference.hpp b/src/common/reference.hpp index d98b2181d..7b1d0b8c1 100644 --- a/src/common/reference.hpp +++ b/src/common/reference.hpp @@ -76,7 +76,7 @@ private: return; } - typename CustomDeleter::deleter del; + const typename CustomDeleter::deleter del; del(_value); release(); } diff --git a/src/common/runas.cpp b/src/common/runas.cpp index 07d9e171f..ffbc02d35 100644 --- a/src/common/runas.cpp +++ b/src/common/runas.cpp @@ -788,9 +788,9 @@ send_fds_to_master(run_as_worker_data *worker, enum run_as_cmd cmd, struct run_a } for (i = 0; i < COMMAND_OUT_FD_COUNT(cmd); i++) { - int fd = COMMAND_OUT_FDS(cmd, run_as_ret)[i]; + const int fd = COMMAND_OUT_FDS(cmd, run_as_ret)[i]; if (fd >= 0) { - int ret_close = close(fd); + const int ret_close = close(fd); if (ret_close < 0) { PERROR("Failed to close result file descriptor (fd = %i)", fd); diff --git a/src/common/sessiond-comm/inet.cpp b/src/common/sessiond-comm/inet.cpp index 633685799..3471f6c0b 100644 --- a/src/common/sessiond-comm/inet.cpp +++ b/src/common/sessiond-comm/inet.cpp @@ -102,7 +102,7 @@ static int connect_no_timeout(struct lttcomm_sock *sock) static int connect_with_timeout(struct lttcomm_sock *sock) { - unsigned long timeout = lttcomm_get_network_timeout(); + const unsigned long timeout = lttcomm_get_network_timeout(); int ret, flags, connect_ret; struct timespec orig_time, cur_time; unsigned long diff_ms; diff --git a/src/common/sessiond-comm/inet6.cpp b/src/common/sessiond-comm/inet6.cpp index 289e19e98..0d1b6f15b 100644 --- a/src/common/sessiond-comm/inet6.cpp +++ b/src/common/sessiond-comm/inet6.cpp @@ -97,7 +97,7 @@ static int connect_no_timeout(struct lttcomm_sock *sock) static int connect_with_timeout(struct lttcomm_sock *sock) { - unsigned long timeout = lttcomm_get_network_timeout(); + const unsigned long timeout = lttcomm_get_network_timeout(); int ret, flags, connect_ret; struct timespec orig_time, cur_time; unsigned long diff_ms; diff --git a/src/common/sessiond-comm/sessiond-comm.cpp b/src/common/sessiond-comm/sessiond-comm.cpp index 593ab265c..c5236a432 100644 --- a/src/common/sessiond-comm/sessiond-comm.cpp +++ b/src/common/sessiond-comm/sessiond-comm.cpp @@ -126,7 +126,7 @@ const char *lttcomm_get_readable_code(enum lttcomm_return_code code) code = (lttcomm_return_code) -code; if (code != LTTCOMM_CONSUMERD_SUCCESS && - !(code >= LTTCOMM_CONSUMERD_COMMAND_SOCK_READY && code < LTTCOMM_NR)) { + (code < LTTCOMM_CONSUMERD_COMMAND_SOCK_READY || code >= LTTCOMM_NR)) { code = LTTCOMM_CONSUMERD_UNKNOWN_ERROR; } diff --git a/src/common/string-utils/string-utils.cpp b/src/common/string-utils/string-utils.cpp index 4f727e2e8..13302f134 100644 --- a/src/common/string-utils/string-utils.cpp +++ b/src/common/string-utils/string-utils.cpp @@ -275,7 +275,7 @@ int strutils_split(const char *input, } if (*s == delim) { - size_t last_len = s - last - 1; + const size_t last_len = s - last - 1; last = s; number_of_substrings++; @@ -375,8 +375,8 @@ int strutils_append_str(char **s, const char *append) { char *old = *s; char *new_str; - size_t oldlen = (old == nullptr) ? 0 : strlen(old); - size_t appendlen = strlen(append); + const size_t oldlen = (old == nullptr) ? 0 : strlen(old); + const size_t appendlen = strlen(append); new_str = zmalloc(oldlen + appendlen + 1); if (!new_str) { @@ -394,7 +394,7 @@ int strutils_append_str(char **s, const char *append) int strutils_appendf(char **s, const char *fmt, ...) { char *new_str; - size_t oldlen = (*s) ? strlen(*s) : 0; + const size_t oldlen = (*s) ? strlen(*s) : 0; size_t addlen = 0; int ret; va_list args; diff --git a/src/common/time.cpp b/src/common/time.cpp index ca29b2d61..6caaf27ba 100644 --- a/src/common/time.cpp +++ b/src/common/time.cpp @@ -47,9 +47,9 @@ int timespec_to_ms(struct timespec ts, unsigned long *ms) struct timespec timespec_abs_diff(struct timespec t1, struct timespec t2) { - uint64_t ts1 = (uint64_t) t1.tv_sec * (uint64_t) NSEC_PER_SEC + (uint64_t) t1.tv_nsec; - uint64_t ts2 = (uint64_t) t2.tv_sec * (uint64_t) NSEC_PER_SEC + (uint64_t) t2.tv_nsec; - uint64_t diff = std::max(ts1, ts2) - std::min(ts1, ts2); + const uint64_t ts1 = (uint64_t) t1.tv_sec * (uint64_t) NSEC_PER_SEC + (uint64_t) t1.tv_nsec; + const uint64_t ts2 = (uint64_t) t2.tv_sec * (uint64_t) NSEC_PER_SEC + (uint64_t) t2.tv_nsec; + const uint64_t diff = std::max(ts1, ts2) - std::min(ts1, ts2); struct timespec res; res.tv_sec = diff / (uint64_t) NSEC_PER_SEC; diff --git a/src/common/trace-chunk.cpp b/src/common/trace-chunk.cpp index 5da16a613..591768b92 100644 --- a/src/common/trace-chunk.cpp +++ b/src/common/trace-chunk.cpp @@ -257,7 +257,7 @@ static int fs_handle_untracked_close(struct fs_handle *_handle) { struct fs_handle_untracked *handle = lttng::utils::container_of(_handle, &fs_handle_untracked::parent); - int ret = close(handle->fd); + const int ret = close(handle->fd); fs_handle_untracked_destroy(handle); return ret; @@ -1828,7 +1828,7 @@ static void lttng_trace_chunk_release(struct urcu_ref *ref) element = lttng::utils::container_of(chunk, <tng_trace_chunk_registry_element::chunk); if (element->registry) { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_del(element->registry->ht, &element->trace_chunk_registry_ht_node); call_rcu(&element->rcu_node, free_lttng_trace_chunk_registry_element); } else { @@ -1878,7 +1878,7 @@ void lttng_trace_chunk_registry_destroy(struct lttng_trace_chunk_registry *regis return; } if (registry->ht) { - int ret = cds_lfht_destroy(registry->ht, nullptr); + const int ret = cds_lfht_destroy(registry->ht, nullptr); LTTNG_ASSERT(!ret); } free(registry); @@ -1944,7 +1944,7 @@ lttng_trace_chunk_registry_publish_chunk(struct lttng_trace_chunk_registry *regi element = lttng_trace_chunk_registry_element_create_from_chunk(chunk, session_id); pthread_mutex_unlock(&chunk->lock); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; if (!element) { goto end; } @@ -2034,7 +2034,7 @@ static struct lttng_trace_chunk *_lttng_trace_chunk_registry_find_chunk( struct lttng_trace_chunk *published_chunk = nullptr; struct cds_lfht_iter iter; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_lookup(registry->ht, element_hash, lttng_trace_chunk_registry_element_match, @@ -2065,7 +2065,7 @@ int lttng_trace_chunk_registry_chunk_exists(const struct lttng_trace_chunk_regis uint64_t chunk_id, bool *chunk_exists) { - int ret = 0; + const int ret = 0; lttng_trace_chunk_registry_element target_element; target_element.chunk.id.is_set = true; @@ -2076,7 +2076,7 @@ int lttng_trace_chunk_registry_chunk_exists(const struct lttng_trace_chunk_regis struct cds_lfht_node *published_node; struct cds_lfht_iter iter; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_lookup(registry->ht, element_hash, lttng_trace_chunk_registry_element_match, @@ -2110,7 +2110,7 @@ lttng_trace_chunk_registry_put_each_chunk(const struct lttng_trace_chunk_registr DBG("Releasing trace chunk registry to all trace chunks"); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry ( registry->ht, &iter, chunk_element, trace_chunk_registry_ht_node) { diff --git a/src/common/unix.cpp b/src/common/unix.cpp index 11ab18a98..ea81e1d13 100644 --- a/src/common/unix.cpp +++ b/src/common/unix.cpp @@ -410,7 +410,7 @@ ssize_t lttcomm_send_fds_unix_sock(int sock, const int *fds, size_t nb_fd) struct cmsghdr *cmptr; struct iovec iov[1]; ssize_t ret = -1; - unsigned int sizeof_fds = nb_fd * sizeof(int); + const unsigned int sizeof_fds = nb_fd * sizeof(int); char tmp[CMSG_SPACE(sizeof_fds)]; char dummy = 0; @@ -534,7 +534,7 @@ ssize_t lttcomm_send_fds_unix_sock_non_block(int sock, const int *fds, size_t nb struct cmsghdr *cmptr; struct iovec iov[1]; ssize_t ret = -1; - unsigned int sizeof_fds = nb_fd * sizeof(int); + const unsigned int sizeof_fds = nb_fd * sizeof(int); char tmp[CMSG_SPACE(sizeof_fds)]; char dummy = 0; @@ -620,7 +620,7 @@ ssize_t lttcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd) struct iovec iov[1]; ssize_t ret = 0; struct cmsghdr *cmsg; - size_t sizeof_fds = nb_fd * sizeof(int); + const size_t sizeof_fds = nb_fd * sizeof(int); #ifdef __linux__ /* Account for the struct ucred cmsg in the buffer size */ @@ -846,7 +846,7 @@ ssize_t lttcomm_recv_fds_unix_sock_non_block(int sock, int *fds, size_t nb_fd) struct iovec iov[1]; ssize_t ret = 0; struct cmsghdr *cmsg; - size_t sizeof_fds = nb_fd * sizeof(int); + const size_t sizeof_fds = nb_fd * sizeof(int); LTTNG_ASSERT(sock); LTTNG_ASSERT(fds); @@ -983,7 +983,7 @@ ssize_t lttcomm_send_creds_unix_sock(int sock, const void *buf, size_t len) ssize_t ret = -1; #if defined(__linux__) || defined(__CYGWIN__) struct cmsghdr *cmptr; - size_t sizeof_cred = sizeof(lttng_sock_cred); + const size_t sizeof_cred = sizeof(lttng_sock_cred); char anc_buf[CMSG_SPACE(sizeof_cred)]; lttng_sock_cred *creds; @@ -1048,7 +1048,7 @@ ssize_t lttcomm_recv_creds_unix_sock(int sock, void *buf, size_t len, lttng_sock size_t len_last; #if defined(__linux__) || defined(__CYGWIN__) struct cmsghdr *cmptr; - size_t sizeof_cred = sizeof(lttng_sock_cred); + const size_t sizeof_cred = sizeof(lttng_sock_cred); char anc_buf[CMSG_SPACE(sizeof_cred)]; #endif /* __linux__, __CYGWIN__ */ diff --git a/src/common/urcu.hpp b/src/common/urcu.hpp index 35bb2905c..017c9fad5 100644 --- a/src/common/urcu.hpp +++ b/src/common/urcu.hpp @@ -30,7 +30,7 @@ public: ~read_lock() = default; /* "Not copyable" and "not moveable" Mutex requirements. */ - read_lock(read_lock const&) = delete; + read_lock(const read_lock&) = delete; read_lock(read_lock&&) = delete; read_lock& operator=(read_lock&&) = delete; read_lock& operator=(const read_lock&) = delete; diff --git a/src/common/userspace-probe.cpp b/src/common/userspace-probe.cpp index 4a9c31812..426f12860 100644 --- a/src/common/userspace-probe.cpp +++ b/src/common/userspace-probe.cpp @@ -1436,7 +1436,7 @@ int lttng_userspace_probe_location_create_from_payload( int consumed = 0; int ret; struct lttng_userspace_probe_location_comm *probe_location_comm; - struct lttng_payload_view probe_location_comm_view = + const lttng_payload_view probe_location_comm_view = lttng_payload_view_from_view(view, 0, sizeof(*probe_location_comm)); LTTNG_ASSERT(view); @@ -1512,7 +1512,7 @@ end: static int lttng_userspace_probe_location_function_set_binary_fd_handle( struct lttng_userspace_probe_location *location, struct fd_handle *binary_fd) { - int ret = 0; + const int ret = 0; struct lttng_userspace_probe_location_function *function_location; LTTNG_ASSERT(location); @@ -1529,7 +1529,7 @@ static int lttng_userspace_probe_location_function_set_binary_fd_handle( static int lttng_userspace_probe_location_tracepoint_set_binary_fd_handle( struct lttng_userspace_probe_location *location, struct fd_handle *binary_fd) { - int ret = 0; + const int ret = 0; struct lttng_userspace_probe_location_tracepoint *tracepoint_location; LTTNG_ASSERT(location); diff --git a/src/common/ust-consumer/ust-consumer.cpp b/src/common/ust-consumer/ust-consumer.cpp index 3f40d03ed..93686e75a 100644 --- a/src/common/ust-consumer/ust-consumer.cpp +++ b/src/common/ust-consumer/ust-consumer.cpp @@ -667,7 +667,7 @@ static int flush_channel(uint64_t chan_key) DBG("UST consumer flush channel key %" PRIu64, chan_key); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; channel = consumer_find_channel(chan_key); if (!channel) { ERR("UST consumer flush channel %" PRIu64 " not found", chan_key); @@ -741,7 +741,7 @@ static int clear_quiescent_channel(uint64_t chan_key) DBG("UST consumer clear quiescent channel key %" PRIu64, chan_key); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; channel = consumer_find_channel(chan_key); if (!channel) { ERR("UST consumer clear quiescent channel %" PRIu64 " not found", chan_key); @@ -959,7 +959,7 @@ static int snapshot_metadata(struct lttng_consumer_channel *metadata_channel, DBG("UST consumer snapshot metadata with key %" PRIu64 " at path %s", key, path); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; LTTNG_ASSERT(!metadata_channel->monitor); @@ -1068,7 +1068,7 @@ static int snapshot_channel(struct lttng_consumer_channel *channel, LTTNG_ASSERT(ctx); ASSERT_RCU_READ_LOCKED(); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; if (relayd_id != (uint64_t) -1ULL) { use_relayd = 1; @@ -1395,14 +1395,14 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, health_code_update(); /* relayd needs RCU read-side lock */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; switch (msg.cmd_type) { case LTTNG_CONSUMER_ADD_RELAYD_SOCKET: { - uint32_t major = msg.u.relayd_sock.major; - uint32_t minor = msg.u.relayd_sock.minor; - enum lttcomm_sock_proto protocol = + const uint32_t major = msg.u.relayd_sock.major; + const uint32_t minor = msg.u.relayd_sock.minor; + const lttcomm_sock_proto protocol = (enum lttcomm_sock_proto) msg.u.relayd_sock.relayd_socket_protocol; /* Session daemon status message are handled in the following call. */ @@ -1420,7 +1420,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, } case LTTNG_CONSUMER_DESTROY_RELAYD: { - uint64_t index = msg.u.destroy_relayd.net_seq_idx; + const uint64_t index = msg.u.destroy_relayd.net_seq_idx; struct consumer_relayd_sock_pair *relayd; DBG("UST consumer destroying relayd %" PRIu64, index); @@ -1456,7 +1456,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, { int is_data_pending; ssize_t ret_send; - uint64_t id = msg.u.data_pending.session_id; + const uint64_t id = msg.u.data_pending.session_id; DBG("UST consumer data pending command for id %" PRIu64, id); @@ -1629,7 +1629,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, case LTTNG_CONSUMER_GET_CHANNEL: { int ret, relayd_err = 0; - uint64_t key = msg.u.get_channel.key; + const uint64_t key = msg.u.get_channel.key; struct lttng_consumer_channel *found_channel; found_channel = consumer_find_channel(key); @@ -1689,7 +1689,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, } case LTTNG_CONSUMER_DESTROY_CHANNEL: { - uint64_t key = msg.u.destroy_channel.key; + const uint64_t key = msg.u.destroy_channel.key; /* * Only called if streams have not been sent to stream @@ -1735,10 +1735,10 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, case LTTNG_CONSUMER_PUSH_METADATA: { int ret; - uint64_t len = msg.u.push_metadata.len; - uint64_t key = msg.u.push_metadata.key; - uint64_t offset = msg.u.push_metadata.target_offset; - uint64_t version = msg.u.push_metadata.version; + const uint64_t len = msg.u.push_metadata.len; + const uint64_t key = msg.u.push_metadata.key; + const uint64_t offset = msg.u.push_metadata.target_offset; + const uint64_t version = msg.u.push_metadata.version; struct lttng_consumer_channel *found_channel; DBG("UST consumer push metadata key %" PRIu64 " of len %" PRIu64, key, len); @@ -1814,7 +1814,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, case LTTNG_CONSUMER_SNAPSHOT_CHANNEL: { struct lttng_consumer_channel *found_channel; - uint64_t key = msg.u.snapshot_channel.key; + const uint64_t key = msg.u.snapshot_channel.key; int ret_send; found_channel = consumer_find_channel(key); @@ -1867,7 +1867,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, struct lttng_ht *ht; struct lttng_consumer_stream *stream; uint64_t id = msg.u.discarded_events.session_id; - uint64_t key = msg.u.discarded_events.channel_key; + const uint64_t key = msg.u.discarded_events.channel_key; DBG("UST consumer discarded events command for session id %" PRIu64, id); pthread_mutex_lock(&the_consumer_data.lock); @@ -1921,7 +1921,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, struct lttng_ht *ht; struct lttng_consumer_stream *stream; uint64_t id = msg.u.lost_packets.session_id; - uint64_t key = msg.u.lost_packets.channel_key; + const uint64_t key = msg.u.lost_packets.channel_key; DBG("UST consumer lost packets command for session id %" PRIu64, id); pthread_mutex_lock(&the_consumer_data.lock); @@ -2014,7 +2014,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, case LTTNG_CONSUMER_ROTATE_CHANNEL: { struct lttng_consumer_channel *found_channel; - uint64_t key = msg.u.rotate_channel.key; + const uint64_t key = msg.u.rotate_channel.key; int ret_send_status; found_channel = consumer_find_channel(key); @@ -2067,7 +2067,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, case LTTNG_CONSUMER_CLEAR_CHANNEL: { struct lttng_consumer_channel *found_channel; - uint64_t key = msg.u.clear_channel.key; + const uint64_t key = msg.u.clear_channel.key; int ret_send_status; found_channel = consumer_find_channel(key); @@ -3204,7 +3204,7 @@ void lttng_ustconsumer_close_all_metadata(struct lttng_ht *metadata_ht) DBG("UST consumer closing all metadata streams"); { - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; cds_lfht_for_each_entry (metadata_ht->ht, &iter.iter, stream, node.node) { health_code_update(); @@ -3243,7 +3243,7 @@ int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx, { struct lttcomm_metadata_request_msg request; struct lttcomm_consumer_msg msg; - enum lttcomm_return_code ret_code = LTTCOMM_CONSUMERD_SUCCESS; + const lttcomm_return_code ret_code = LTTCOMM_CONSUMERD_SUCCESS; uint64_t len, key, offset, version; int ret; diff --git a/src/common/utils.cpp b/src/common/utils.cpp index 62c9c22d5..f1be2c39e 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -475,7 +475,7 @@ end: * * @return 0 on success, -1 on failure. */ -int utils_parse_time_suffix(char const *const str, uint64_t *const time_us) +int utils_parse_time_suffix(const char *const str, uint64_t *const time_us) { int ret; uint64_t base_time; diff --git a/src/common/utils.hpp b/src/common/utils.hpp index 850c29ba8..36cb690d4 100644 --- a/src/common/utils.hpp +++ b/src/common/utils.hpp @@ -38,8 +38,8 @@ int utils_stream_file_path(const char *path_name, const char *suffix, char *out_stream_path, size_t stream_path_len); -int utils_parse_size_suffix(char const *const str, uint64_t *const size); -int utils_parse_time_suffix(char const *const str, uint64_t *const time_us); +int utils_parse_size_suffix(const char *const str, uint64_t *const size); +int utils_parse_time_suffix(const char *const str, uint64_t *const time_us); int utils_get_count_order_u32(uint32_t x); int utils_get_count_order_u64(uint64_t x); const char *utils_get_home_dir(); diff --git a/src/lib/lttng-ctl/clear.cpp b/src/lib/lttng-ctl/clear.cpp index 61b2e5041..49ab6cdf1 100644 --- a/src/lib/lttng-ctl/clear.cpp +++ b/src/lib/lttng-ctl/clear.cpp @@ -180,7 +180,7 @@ lttng_clear_handle_wait_for_completion(struct lttng_clear_handle *handle, int ti goto end; } if (has_timeout) { - int ret = lttng_clock_gettime(CLOCK_MONOTONIC, &initial_time); + const int ret = lttng_clock_gettime(CLOCK_MONOTONIC, &initial_time); if (ret) { status = LTTNG_CLEAR_HANDLE_STATUS_ERROR; goto end; diff --git a/src/lib/lttng-ctl/destruction-handle.cpp b/src/lib/lttng-ctl/destruction-handle.cpp index 34f58f7e0..e97364587 100644 --- a/src/lib/lttng-ctl/destruction-handle.cpp +++ b/src/lib/lttng-ctl/destruction-handle.cpp @@ -235,7 +235,7 @@ lttng_destruction_handle_wait_for_completion(struct lttng_destruction_handle *ha goto end; } if (has_timeout) { - int ret = lttng_clock_gettime(CLOCK_MONOTONIC, &initial_time); + const int ret = lttng_clock_gettime(CLOCK_MONOTONIC, &initial_time); if (ret) { status = LTTNG_DESTRUCTION_HANDLE_STATUS_ERROR; goto end; diff --git a/src/lib/lttng-ctl/lttng-ctl.cpp b/src/lib/lttng-ctl/lttng-ctl.cpp index bbc94828e..5057b75ef 100644 --- a/src/lib/lttng-ctl/lttng-ctl.cpp +++ b/src/lib/lttng-ctl/lttng-ctl.cpp @@ -1214,7 +1214,7 @@ serialize: { struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1); - int fd_count = lttng_payload_view_get_fd_handle_count(&view); + const int fd_count = lttng_payload_view_get_fd_handle_count(&view); int fd_to_send; if (fd_count < 0) { @@ -1397,7 +1397,7 @@ serialize: { struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1); - int fd_count = lttng_payload_view_get_fd_handle_count(&view); + const int fd_count = lttng_payload_view_get_fd_handle_count(&view); int fd_to_send; if (fd_count < 0) { @@ -1702,7 +1702,7 @@ int lttng_list_tracepoints(struct lttng_handle *handle, struct lttng_event **eve nb_events = (unsigned int) cmd_header->count; { - struct lttng_buffer_view events_view = + const lttng_buffer_view events_view = lttng_buffer_view_init(reception_buffer, 0, total_payload_received); struct lttng_payload_view events_payload_view = lttng_payload_view_from_buffer_view(&events_view, 0, -1); @@ -1912,7 +1912,7 @@ enum lttng_error_code lttng_create_session_ext(struct lttng_session_descriptor * !lttng_session_descriptor_is_output_destination_initialized(session_descriptor); if (sessiond_must_generate_ouput) { const char *home_dir = utils_get_home_dir(); - size_t home_dir_len = home_dir ? strlen(home_dir) + 1 : 0; + const size_t home_dir_len = home_dir ? strlen(home_dir) + 1 : 0; if (!home_dir || home_dir_len > LTTNG_PATH_MAX) { ret_code = LTTNG_ERR_FATAL; diff --git a/src/vendor/fmt/core.h b/src/vendor/fmt/core.h index 2eff064cd..bdac834d2 100644 --- a/src/vendor/fmt/core.h +++ b/src/vendor/fmt/core.h @@ -595,7 +595,7 @@ enum class type { custom_type }; -// Maps core type T to the corresponding type enum constant. +// Maps core type T to the corresponding type constant. template struct type_constant : std::integral_constant {}; diff --git a/tests/regression/kernel/select_poll_epoll.cpp b/tests/regression/kernel/select_poll_epoll.cpp index b6f0210d5..83f13567a 100644 --- a/tests/regression/kernel/select_poll_epoll.cpp +++ b/tests/regression/kernel/select_poll_epoll.cpp @@ -66,7 +66,7 @@ static void epoll_pwait_int_max(FILE *validation_output_file); static void ppoll_concurrent_write(FILE *validation_output_file); static void epoll_pwait_concurrent_munmap(FILE *validation_output_file); -typedef void (*test_case_cb)(FILE *output_file); +using test_case_cb = void (*)(FILE *); namespace { const struct test_case { @@ -142,7 +142,7 @@ struct ppoll_thread_data { }; } /* namespace */ -static void test_select_big(void) +static void test_select_big() { fd_set rfds, wfds, exfds; struct timeval tv; @@ -167,7 +167,7 @@ static void test_select_big(void) if (timeout > 0) { ret = select(fd2 + 1, &rfds, &wfds, &exfds, &tv); } else { - ret = select(fd2 + 1, &rfds, &wfds, &exfds, NULL); + ret = select(fd2 + 1, &rfds, &wfds, &exfds, nullptr); } if (ret == -1) { @@ -217,12 +217,12 @@ static void test_pselect_generic(long int syscall_id) } } -static void test_pselect(void) +static void test_pselect() { test_pselect_generic(SYS_pselect6); } -static void test_select(void) +static void test_select() { fd_set rfds; struct timeval tv; @@ -236,9 +236,9 @@ static void test_select(void) tv.tv_usec = timeout * MSEC_PER_USEC; if (timeout > 0) { - ret = select(1, &rfds, NULL, NULL, &tv); + ret = select(1, &rfds, nullptr, nullptr, &tv); } else { - ret = select(1, &rfds, NULL, NULL, NULL); + ret = select(1, &rfds, nullptr, nullptr, nullptr); } if (ret == -1) { @@ -251,7 +251,7 @@ static void test_select(void) } } -static void test_poll(void) +static void test_poll() { struct pollfd ufds[NB_FD]; char buf[BUF_SIZE]; @@ -300,7 +300,7 @@ static void test_ppoll_generic(long int syscall_id) } } -static void test_ppoll(void) +static void test_ppoll() { test_ppoll_generic(SYS_ppoll); } @@ -320,7 +320,7 @@ static void test_ppoll_big(FILE *validation_output_file __attribute__((unused))) ufds[i].events = POLLIN | POLLPRI; } - ret = ppoll(ufds, MAX_FDS, NULL, NULL); + ret = ppoll(ufds, MAX_FDS, nullptr, nullptr); if (ret < 0) { PERROR("ppoll"); @@ -418,9 +418,9 @@ static void test_epoll_pwait(FILE *validation_output_file) } if (timeout > 0) { - ret = epoll_pwait(epollfd, &epoll_event, 1, timeout, NULL); + ret = epoll_pwait(epollfd, &epoll_event, 1, timeout, nullptr); } else { - ret = epoll_pwait(epollfd, &epoll_event, 1, -1, NULL); + ret = epoll_pwait(epollfd, &epoll_event, 1, -1, nullptr); } if (ret == 1) { @@ -773,7 +773,7 @@ static void *ppoll_writer(void *arg) usleep(100); } - return NULL; + return nullptr; } static void do_ppoll(int *fds, struct pollfd *ufds) @@ -790,7 +790,7 @@ static void do_ppoll(int *fds, struct pollfd *ufds) ufds[i].events = POLLIN | POLLPRI; } - ret = ppoll(ufds, MAX_FDS, &ts, NULL); + ret = ppoll(ufds, MAX_FDS, &ts, nullptr); if (ret < 0) { PERROR("ppoll"); @@ -813,7 +813,7 @@ static void stress_ppoll(int *fds, int value) thread_data.value = value; stop_thread = 0; - ret = pthread_create(&writer, NULL, &ppoll_writer, (void *) &thread_data); + ret = pthread_create(&writer, nullptr, &ppoll_writer, (void *) &thread_data); if (ret != 0) { fprintf(stderr, "[error] pthread_create\n"); goto end; @@ -822,7 +822,7 @@ static void stress_ppoll(int *fds, int value) do_ppoll(fds, ufds); } stop_thread = 1; - ret = pthread_join(writer, NULL); + ret = pthread_join(writer, nullptr); if (ret) { fprintf(stderr, "[error] pthread_join\n"); goto end; @@ -870,14 +870,14 @@ static void ppoll_concurrent_write(FILE *validation_output_file __attribute__((u static void *epoll_pwait_writer(void *addr) { - srand(time(NULL)); + srand(time(nullptr)); while (!stop_thread) { usleep(rand() % 30); munmap(addr, MAX_FDS * sizeof(struct epoll_event)); } - return NULL; + return nullptr; } /* @@ -907,7 +907,7 @@ static void epoll_pwait_concurrent_munmap(FILE *validation_output_file) goto error; } - epoll_event = (struct epoll_event *) mmap(NULL, + epoll_event = (struct epoll_event *) mmap(nullptr, MAX_FDS * sizeof(struct epoll_event), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, @@ -932,13 +932,13 @@ static void epoll_pwait_concurrent_munmap(FILE *validation_output_file) } } stop_thread = 0; - ret = pthread_create(&writer, NULL, &epoll_pwait_writer, (void *) epoll_event); + ret = pthread_create(&writer, nullptr, &epoll_pwait_writer, (void *) epoll_event); if (ret != 0) { fprintf(stderr, "[error] pthread_create\n"); goto error_unmap; } - ret = epoll_pwait(epollfd, epoll_event, 1, 1, NULL); + ret = epoll_pwait(epollfd, epoll_event, 1, 1, nullptr); if (ret == 1) { ret = read(wait_fd, buf, BUF_SIZE); @@ -950,7 +950,7 @@ static void epoll_pwait_concurrent_munmap(FILE *validation_output_file) } stop_thread = 1; - ret = pthread_join(writer, NULL); + ret = pthread_join(writer, nullptr); if (ret) { fprintf(stderr, "[error] pthread_join\n"); goto error_unmap; @@ -977,7 +977,7 @@ end: return; } -static void print_list(void) +static void print_list() { printf("Test list (-t X):\n"); @@ -989,7 +989,7 @@ static void print_list(void) } } -static void print_test_syscalls(void) +static void print_test_syscalls() { const char *supported_syscalls[] = { #ifdef SYS_select @@ -1033,31 +1033,31 @@ int main(int argc, const char **argv) const char *test_name; poptContext optCon; struct rlimit open_lim; - FILE *test_validation_output_file = NULL; - const char *test_validation_output_file_path = NULL; + FILE *test_validation_output_file = nullptr; + const char *test_validation_output_file_path = nullptr; struct poptOption optionsTable[] = { - { "test", 't', POPT_ARG_STRING, &test_name, 0, "Name of test to run", NULL }, - { "list-tests", 'l', 0, 0, 'l', "List tests (-t X)", NULL }, + { "test", 't', POPT_ARG_STRING, &test_name, 0, "Name of test to run", nullptr }, + { "list-tests", 'l', 0, nullptr, 'l', "List tests (-t X)", nullptr }, { "list-supported-test-syscalls", 's', 0, - 0, + nullptr, 's', "List supported test syscalls", - NULL }, + nullptr }, { "validation-file", 'o', POPT_ARG_STRING, &test_validation_output_file_path, 0, "Test case output", - NULL }, - POPT_AUTOHELP{ NULL, 0, 0, NULL, 0, NULL, NULL } + nullptr }, + POPT_AUTOHELP{ nullptr, 0, 0, nullptr, 0, nullptr, nullptr } }; const struct test_case *test_case; size_t test_case_id; - optCon = poptGetContext(NULL, argc, argv, optionsTable, 0); + optCon = poptGetContext(nullptr, argc, argv, optionsTable, 0); if (argc < 2) { poptPrintUsage(optCon, stderr, 0); @@ -1106,7 +1106,7 @@ int main(int argc, const char **argv) * for the validation, disabling the buffering on the validation file * works. */ - setbuf(test_validation_output_file, NULL); + setbuf(test_validation_output_file, nullptr); wait_fd = STDIN_FILENO; /* Test case id is 1-based. */ diff --git a/tests/regression/tools/trigger/name/trigger_name.cpp b/tests/regression/tools/trigger/name/trigger_name.cpp index b878af486..025387f72 100644 --- a/tests/regression/tools/trigger/name/trigger_name.cpp +++ b/tests/regression/tools/trigger/name/trigger_name.cpp @@ -102,7 +102,7 @@ static int unregister_all_triggers() ret = lttng_unregister_trigger(trigger); if (ret) { const char *name; - enum lttng_trigger_status get_name_status = + const lttng_trigger_status get_name_status = lttng_trigger_get_name(trigger, &name); if (get_name_status == LTTNG_TRIGGER_STATUS_OK) { fail("Failed to unregister trigger: trigger name = '%s'", name); diff --git a/tests/regression/tools/trigger/utils/notification-client.cpp b/tests/regression/tools/trigger/utils/notification-client.cpp index 27bd100c6..5c9f6885b 100644 --- a/tests/regression/tools/trigger/utils/notification-client.cpp +++ b/tests/regression/tools/trigger/utils/notification-client.cpp @@ -24,18 +24,18 @@ static struct option long_options[] = { /* These options set a flag. */ - { "trigger", required_argument, 0, 't' }, - { "sync-after-notif-register", required_argument, 0, 'a' }, + { "trigger", required_argument, nullptr, 't' }, + { "sync-after-notif-register", required_argument, nullptr, 'a' }, /* Default alue for count is 1 */ - { "count", required_argument, 0, 'b' }, + { "count", required_argument, nullptr, 'b' }, /* * When end-trigger is present the reception loop is exited only when a * notification matching the end trigger is received. * Otherwise the loop is exited when the count of notification received * for `trigger` math the `count` argument. */ - { "end-trigger", required_argument, 0, 'c' }, - { 0, 0, 0, 0 } + { "end-trigger", required_argument, nullptr, 'c' }, + { nullptr, 0, nullptr, 0 } }; static bool action_list_contains_notify(const struct lttng_action *action_list) @@ -53,7 +53,7 @@ static bool action_list_contains_notify(const struct lttng_action *action_list) static bool is_trigger_name(const char *expected_trigger_name, struct lttng_notification *notification) { - const char *trigger_name = NULL; + const char *trigger_name = nullptr; enum lttng_trigger_status trigger_status; const struct lttng_trigger *trigger; bool names_match; @@ -88,13 +88,13 @@ static int _main(int argc, char **argv) int ret; int option; int option_index; - char *expected_trigger_name = NULL; - char *end_trigger_name = NULL; - struct lttng_triggers *triggers = NULL; + char *expected_trigger_name = nullptr; + char *end_trigger_name = nullptr; + struct lttng_triggers *triggers = nullptr; unsigned int count, i, subcription_count = 0; enum lttng_trigger_status trigger_status; - char *after_notif_register_file_path = NULL; - struct lttng_notification_channel *notification_channel = NULL; + char *after_notif_register_file_path = nullptr; + struct lttng_notification_channel *notification_channel = nullptr; int expected_notifications = 1, notification_count = 0; while ((option = getopt_long(argc, argv, "a:b:c:t:", long_options, &option_index)) != -1) { @@ -154,19 +154,19 @@ static int _main(int argc, char **argv) const struct lttng_action *action = lttng_trigger_get_const_action(trigger); const enum lttng_action_type action_type = lttng_action_get_type(action); enum lttng_notification_channel_status channel_status; - const char *trigger_name = NULL; + const char *trigger_name = nullptr; lttng_trigger_get_name(trigger, &trigger_name); if (strcmp(trigger_name, expected_trigger_name) != 0) { /* Might match the end event trigger */ - if (end_trigger_name != NULL && + if (end_trigger_name != nullptr && strcmp(trigger_name, end_trigger_name) != 0) { continue; } } - if (!((action_type == LTTNG_ACTION_TYPE_LIST && - action_list_contains_notify(action)) || - action_type == LTTNG_ACTION_TYPE_NOTIFY)) { + if ((action_type != LTTNG_ACTION_TYPE_LIST || + !action_list_contains_notify(action)) && + action_type != LTTNG_ACTION_TYPE_NOTIFY) { /* "The action of trigger is not notify, skipping. */ continue; } @@ -190,7 +190,7 @@ static int _main(int argc, char **argv) goto end; } - if (end_trigger_name != NULL && subcription_count != 2) { + if (end_trigger_name != nullptr && subcription_count != 2) { fprintf(stderr, "No matching end event trigger with a notify action found.\n"); ret = -1; goto end; @@ -232,7 +232,8 @@ static int _main(int argc, char **argv) } /* Early exit check. */ - if (end_trigger_name != NULL && is_trigger_name(end_trigger_name, notification)) { + if (end_trigger_name != nullptr && + is_trigger_name(end_trigger_name, notification)) { /* Exit the loop immediately. */ printf("Received end event notification from trigger %s\n", end_trigger_name); @@ -249,7 +250,7 @@ static int _main(int argc, char **argv) printf("Received event notification from trigger %s\n", expected_trigger_name); notification_count++; - if (end_trigger_name == NULL && expected_notifications == notification_count) { + if (end_trigger_name == nullptr && expected_notifications == notification_count) { /* * Here the loop exit is controlled by the number of * notification and not by the reception of the end diff --git a/tests/unit/test_action.cpp b/tests/unit/test_action.cpp index 52f6d26ca..d45dfb799 100644 --- a/tests/unit/test_action.cpp +++ b/tests/unit/test_action.cpp @@ -100,12 +100,12 @@ static void test_action_notify() lttng_payload_reset(&payload); } -static void test_action_list(void) +static void test_action_list() { int ret, action_idx; - struct lttng_action *list_action = NULL, *list_action_from_buffer = NULL, - *stop_session_action = NULL, *notify_action = NULL, - *start_session_action = NULL; + struct lttng_action *list_action = nullptr, *list_action_from_buffer = nullptr, + *stop_session_action = nullptr, *notify_action = nullptr, + *start_session_action = nullptr; struct lttng_payload payload; lttng_payload_init(&payload); @@ -140,7 +140,7 @@ static void test_action_list(void) action_idx = 0; for (auto action : lttng::ctl::const_action_list_view(list_action)) { - enum lttng_action_type inner_action_type = lttng_action_get_type(action); + const lttng_action_type inner_action_type = lttng_action_get_type(action); switch (action_idx) { case 0: ok(inner_action_type == LTTNG_ACTION_TYPE_START_SESSION, @@ -160,7 +160,7 @@ static void test_action_list(void) action_idx = 0; for (auto action : lttng::ctl::action_list_view(list_action)) { - enum lttng_action_type inner_action_type = lttng_action_get_type(action); + const lttng_action_type inner_action_type = lttng_action_get_type(action); switch (action_idx) { case 0: ok(inner_action_type == LTTNG_ACTION_TYPE_START_SESSION, @@ -186,7 +186,7 @@ static void test_action_list(void) lttng_payload_reset(&payload); } -static void test_action_rotate_session(void) +static void test_action_rotate_session() { int ret; enum lttng_action_status status; diff --git a/tests/unit/test_buffer_view.cpp b/tests/unit/test_buffer_view.cpp index 69812de43..703b1c3c1 100644 --- a/tests/unit/test_buffer_view.cpp +++ b/tests/unit/test_buffer_view.cpp @@ -19,8 +19,8 @@ int lttng_opt_mi; static void test_contains_string() { const char buf[] = { 'A', 'l', 'l', 'o', '\0' }; - struct lttng_buffer_view view = lttng_buffer_view_init(buf, 0, 5); - struct lttng_buffer_view view_minus_one = lttng_buffer_view_init(buf, 0, 4); + const lttng_buffer_view view = lttng_buffer_view_init(buf, 0, 5); + const lttng_buffer_view view_minus_one = lttng_buffer_view_init(buf, 0, 4); ok1(!lttng_buffer_view_contains_string(&view, buf, 4)); ok1(lttng_buffer_view_contains_string(&view, buf, 5)); diff --git a/tests/unit/test_fd_tracker.cpp b/tests/unit/test_fd_tracker.cpp index cdc622a04..b9924e3bc 100644 --- a/tests/unit/test_fd_tracker.cpp +++ b/tests/unit/test_fd_tracker.cpp @@ -167,8 +167,8 @@ static void untrack_std_fds(struct fd_tracker *tracker) }; for (i = 0; i < sizeof(files) / sizeof(*files); i++) { - int fd = files[i].fd; - int ret = fd_tracker_close_unsuspendable_fd( + const int fd = files[i].fd; + const int ret = fd_tracker_close_unsuspendable_fd( tracker, &files[i].fd, 1, noop_close, nullptr); ok(ret == 0, "Untrack unsuspendable fd %d (%s)", fd, files[i].name); @@ -299,7 +299,7 @@ static int open_pipes(void *data __attribute__((unused)), int *out_fds) const unsigned int pipe_count = TRACKER_FD_LIMIT / 2; for (i = 0; i < pipe_count; i++) { - int ret = pipe(&out_fds[i * 2]); + const int ret = pipe(&out_fds[i * 2]); if (ret) { return -errno; @@ -314,7 +314,7 @@ static int close_pipes(void *data __attribute__((unused)), int *fds) int *pipes = fds; for (i = 0; i < TRACKER_FD_LIMIT; i++) { - int ret = close(pipes[i]); + const int ret = close(pipes[i]); if (ret) { return -errno; diff --git a/tests/unit/test_log_level_rule.cpp b/tests/unit/test_log_level_rule.cpp index 209253267..4cd270411 100644 --- a/tests/unit/test_log_level_rule.cpp +++ b/tests/unit/test_log_level_rule.cpp @@ -145,7 +145,7 @@ static void test_log_level_rule_is_equal_at_least_as_severe_as() static void test_log_level_rule_exactly() { - int level = 9000; + const int level = 9000; int _level; struct lttng_log_level_rule *exactly = nullptr; enum lttng_log_level_rule_status status; @@ -167,7 +167,7 @@ static void test_log_level_rule_exactly() static void test_log_level_rule_at_least_as_severe_as() { - int level = 9000; + const int level = 9000; int _level; struct lttng_log_level_rule *at_least_as_severe_as = nullptr; enum lttng_log_level_rule_status status; diff --git a/tests/unit/test_payload.cpp b/tests/unit/test_payload.cpp index 419fc893d..9b9f77046 100644 --- a/tests/unit/test_payload.cpp +++ b/tests/unit/test_payload.cpp @@ -29,7 +29,7 @@ static void test_fd_push_pop_order() diag("Validating fd push/pop order"); for (i = 0; i < 3; i++) { - int fd = fcntl(STDOUT_FILENO, F_DUPFD, 0); + const int fd = fcntl(STDOUT_FILENO, F_DUPFD, 0); struct fd_handle *handle; LTTNG_ASSERT(fd >= 0); @@ -77,7 +77,7 @@ static void test_fd_push_pop_imbalance() diag("Validating fd pop imbalance"); for (i = 0; i < 10; i++) { struct fd_handle *handle; - int fd = fcntl(STDOUT_FILENO, F_DUPFD, 0); + const int fd = fcntl(STDOUT_FILENO, F_DUPFD, 0); LTTNG_ASSERT(fd >= 0); @@ -118,7 +118,7 @@ fail: static void test_fd_pop_fd_root_views() { int ret, i; - int fd = fcntl(STDOUT_FILENO, F_DUPFD, 0); + const int fd = fcntl(STDOUT_FILENO, F_DUPFD, 0); struct fd_handle *handle; struct lttng_payload payload; const char *const test_description = diff --git a/tests/unit/test_rate_policy.cpp b/tests/unit/test_rate_policy.cpp index 40ac0b4d6..6a12d3422 100644 --- a/tests/unit/test_rate_policy.cpp +++ b/tests/unit/test_rate_policy.cpp @@ -33,8 +33,8 @@ static void test_rate_policy_every_n() struct lttng_rate_policy *policy_b = nullptr; /* Interval of 100 */ struct lttng_rate_policy *policy_c = nullptr; /* Interval of 1 */ struct lttng_rate_policy *policy_from_buffer = nullptr; - uint64_t interval_a_b = 100; - uint64_t interval_c = 1; + const uint64_t interval_a_b = 100; + const uint64_t interval_c = 1; uint64_t interval_query = 0; struct lttng_payload payload; @@ -117,8 +117,8 @@ static void test_rate_policy_once_after_n() struct lttng_rate_policy *policy_b = nullptr; /* threshold of 100 */ struct lttng_rate_policy *policy_c = nullptr; /* threshold of 1 */ struct lttng_rate_policy *policy_from_buffer = nullptr; - uint64_t threshold_a_b = 100; - uint64_t threshold_c = 1; + const uint64_t threshold_a_b = 100; + const uint64_t threshold_c = 1; uint64_t threshold_query = 0; struct lttng_payload payload; diff --git a/tests/unit/test_relayd_backward_compat_group_by_session.cpp b/tests/unit/test_relayd_backward_compat_group_by_session.cpp index 527d41ac9..7c63da872 100644 --- a/tests/unit/test_relayd_backward_compat_group_by_session.cpp +++ b/tests/unit/test_relayd_backward_compat_group_by_session.cpp @@ -175,7 +175,7 @@ end: int main() { int i; - int num_test = sizeof(tests) / sizeof(struct test); + const int num_test = sizeof(tests) / sizeof(struct test); const time_t test_time = time(nullptr); plan_tests(NUM_TESTS_PER_TEST * num_test); diff --git a/tests/unit/test_unix_socket.cpp b/tests/unit/test_unix_socket.cpp index e0af6e296..95a6173b8 100644 --- a/tests/unit/test_unix_socket.cpp +++ b/tests/unit/test_unix_socket.cpp @@ -70,7 +70,7 @@ static void test_high_fd_count(unsigned int fd_count) for (i = 0; i < fd_count; i++) { struct fd_handle *handle; - int fd = fcntl(STDOUT_FILENO, F_DUPFD, 0); + const int fd = fcntl(STDOUT_FILENO, F_DUPFD, 0); if (fd < 0) { PERROR("Failed to create fd while creating test payload"); diff --git a/tests/unit/test_utils_expand_path.cpp b/tests/unit/test_utils_expand_path.cpp index 8809448ca..4f460963f 100644 --- a/tests/unit/test_utils_expand_path.cpp +++ b/tests/unit/test_utils_expand_path.cpp @@ -85,7 +85,7 @@ struct tree_symlink tree_symlinks[] = { }; const int num_tree_symlinks = sizeof(tree_symlinks) / sizeof(tree_symlinks[0]); -static struct symlink_test_input symlink_tests_inputs[] = { +struct symlink_test_input symlink_tests_inputs[] = { { "a/g/../l/.", "a/b/l" }, { "a/g/../l/./", "a/b/l/" }, { "a/g/../l/..", "a/b" }, { "a/g/../l/../", "a/b/" }, { "a/b/h/g/", "" }, }; diff --git a/tests/utils/bt2_plugins/event_name/event_name.cpp b/tests/utils/bt2_plugins/event_name/event_name.cpp index 170e37592..cd3567b30 100644 --- a/tests/utils/bt2_plugins/event_name/event_name.cpp +++ b/tests/utils/bt2_plugins/event_name/event_name.cpp @@ -56,15 +56,15 @@ public: { } - event_name_set(event_name_set&& original) : + event_name_set(event_name_set&& original) noexcept : lttng::utils::random_access_container_wrapper( - std::move(original._container)) + original._container) { } - event_name_set(const bt_value *names) : + explicit event_name_set(const bt_value *names) : lttng::utils::random_access_container_wrapper(names) @@ -102,9 +102,7 @@ struct event_name_iterator_data { { } - ~event_name_iterator_data() - { - } + ~event_name_iterator_data() = default; const lttng::bt2::message_iterator_ref upstream_iterator; const class event_name_filter& event_name_filter; @@ -161,7 +159,7 @@ event_name_initialize(bt_self_component_filter *self_comp, } try { - event_name_set event_names{ names_param }; + const event_name_set event_names{ names_param }; if (event_names.empty()) { BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT( bt_self_component_filter_as_self_component(self_comp), diff --git a/tests/utils/bt2_plugins/field_stats/field_stats.cpp b/tests/utils/bt2_plugins/field_stats/field_stats.cpp index dc8894fd8..e3be5558f 100644 --- a/tests/utils/bt2_plugins/field_stats/field_stats.cpp +++ b/tests/utils/bt2_plugins/field_stats/field_stats.cpp @@ -19,14 +19,15 @@ #include #include #include +#include class bad_alloc_with_msg : public std::bad_alloc { public: - explicit bad_alloc_with_msg(const std::string& msg) : _msg(msg) + explicit bad_alloc_with_msg(std::string msg) : _msg(std::move(msg)) { } - virtual const char *what() const noexcept override + const char *what() const noexcept override { return _msg.c_str(); } @@ -45,9 +46,7 @@ public: } } - ~field_stats() - { - } + ~field_stats() = default; lttng::bt2::message_iterator_ref upstream_iterator; lttng::bt2::event_class_const_ref event_class; diff --git a/tests/utils/testapp/gen-ust-events-constructor/01-tp-before-define.cpp b/tests/utils/testapp/gen-ust-events-constructor/01-tp-before-define.cpp index 52199240e..6e0eaa3df 100644 --- a/tests/utils/testapp/gen-ust-events-constructor/01-tp-before-define.cpp +++ b/tests/utils/testapp/gen-ust-events-constructor/01-tp-before-define.cpp @@ -7,14 +7,14 @@ #include "obj.h" #include "tp.h" -void test_constructor1(void) __attribute__((constructor)); -void test_constructor1(void) +void test_constructor1() __attribute__((constructor)); +void test_constructor1() { tracepoint(tp, constructor_c_across_units_before_define); } -void test_destructor1(void) __attribute__((destructor)); -void test_destructor1(void) +void test_destructor1() __attribute__((destructor)); +void test_destructor1() { tracepoint(tp, destructor_c_across_units_before_define); } diff --git a/tests/utils/testapp/gen-ust-events-constructor/02-define-tp.cpp b/tests/utils/testapp/gen-ust-events-constructor/02-define-tp.cpp index 9d550fcc8..777df2d95 100644 --- a/tests/utils/testapp/gen-ust-events-constructor/02-define-tp.cpp +++ b/tests/utils/testapp/gen-ust-events-constructor/02-define-tp.cpp @@ -6,17 +6,17 @@ #include "obj.h" -static void fct_constructor2(void); -static void fct_destructor2(void); +static void fct_constructor2(); +static void fct_destructor2(); -void test_constructor2_same_unit_before(void) __attribute__((constructor)); -void test_constructor2_same_unit_before(void) +void test_constructor2_same_unit_before() __attribute__((constructor)); +void test_constructor2_same_unit_before() { fct_constructor2(); } -void test_destructor2_same_unit_before(void) __attribute__((destructor)); -void test_destructor2_same_unit_before(void) +void test_destructor2_same_unit_before() __attribute__((destructor)); +void test_destructor2_same_unit_before() { fct_destructor2(); } @@ -28,24 +28,24 @@ Obj g_obj_same_unit_before_define("global - same unit before define"); Obj g_obj_same_unit_after_define("global - same unit after define"); -static void fct_constructor2(void) +static void fct_constructor2() { tracepoint(tp, constructor_c_same_unit_before_define); } -static void fct_destructor2(void) +static void fct_destructor2() { tracepoint(tp, destructor_c_same_unit_before_define); } -void test_constructor2_same_unit_after(void) __attribute__((constructor)); -void test_constructor2_same_unit_after(void) +void test_constructor2_same_unit_after() __attribute__((constructor)); +void test_constructor2_same_unit_after() { tracepoint(tp, constructor_c_same_unit_after_define); } -void test_destructor2_same_unit_after(void) __attribute__((destructor)); -void test_destructor2_same_unit_after(void) +void test_destructor2_same_unit_after() __attribute__((destructor)); +void test_destructor2_same_unit_after() { tracepoint(tp, destructor_c_same_unit_after_define); } diff --git a/tests/utils/testapp/gen-ust-events-constructor/03-tp-after-define.cpp b/tests/utils/testapp/gen-ust-events-constructor/03-tp-after-define.cpp index fba3c262e..e39cd3903 100644 --- a/tests/utils/testapp/gen-ust-events-constructor/03-tp-after-define.cpp +++ b/tests/utils/testapp/gen-ust-events-constructor/03-tp-after-define.cpp @@ -7,14 +7,14 @@ #include "obj.h" #include "tp.h" -void test_constructor3(void) __attribute__((constructor)); -void test_constructor3(void) +void test_constructor3() __attribute__((constructor)); +void test_constructor3() { tracepoint(tp, constructor_c_across_units_after_define); } -void test_destructor3(void) __attribute__((destructor)); -void test_destructor3(void) +void test_destructor3() __attribute__((destructor)); +void test_destructor3() { tracepoint(tp, destructor_c_across_units_after_define); } diff --git a/tests/utils/testapp/gen-ust-events-constructor/04-tp-provider.cpp b/tests/utils/testapp/gen-ust-events-constructor/04-tp-provider.cpp index bebf0d232..631700dfc 100644 --- a/tests/utils/testapp/gen-ust-events-constructor/04-tp-provider.cpp +++ b/tests/utils/testapp/gen-ust-events-constructor/04-tp-provider.cpp @@ -6,17 +6,17 @@ #include "obj.h" -static void fct_constructor4(void); -static void fct_destructor4(void); +static void fct_constructor4(); +static void fct_destructor4(); -void test_constructor4_same_unit_before(void) __attribute__((constructor)); -void test_constructor4_same_unit_before(void) +void test_constructor4_same_unit_before() __attribute__((constructor)); +void test_constructor4_same_unit_before() { fct_constructor4(); } -void test_destructor4_same_unit_before(void) __attribute__((destructor)); -void test_destructor4_same_unit_before(void) +void test_destructor4_same_unit_before() __attribute__((destructor)); +void test_destructor4_same_unit_before() { fct_destructor4(); } @@ -28,24 +28,24 @@ Obj g_obj_same_unit_before_provider("global - same unit before provider"); Obj g_obj_same_unit_after_provider("global - same unit after provider"); -static void fct_constructor4(void) +static void fct_constructor4() { tracepoint(tp, constructor_c_same_unit_before_provider); } -static void fct_destructor4(void) +static void fct_destructor4() { tracepoint(tp, destructor_c_same_unit_before_provider); } -void test_constructor4_same_unit_after(void) __attribute__((constructor)); -void test_constructor4_same_unit_after(void) +void test_constructor4_same_unit_after() __attribute__((constructor)); +void test_constructor4_same_unit_after() { tracepoint(tp, constructor_c_same_unit_after_provider); } -void test_destructor4_same_unit_after(void) __attribute__((destructor)); -void test_destructor4_same_unit_after(void) +void test_destructor4_same_unit_after() __attribute__((destructor)); +void test_destructor4_same_unit_after() { tracepoint(tp, destructor_c_same_unit_after_provider); } diff --git a/tests/utils/testapp/gen-ust-events-constructor/05-tp-after-provider.cpp b/tests/utils/testapp/gen-ust-events-constructor/05-tp-after-provider.cpp index 17d3a6e24..338304b43 100644 --- a/tests/utils/testapp/gen-ust-events-constructor/05-tp-after-provider.cpp +++ b/tests/utils/testapp/gen-ust-events-constructor/05-tp-after-provider.cpp @@ -7,14 +7,14 @@ #include "obj.h" #include "tp.h" -void test_constructor5(void) __attribute__((constructor)); -void test_constructor5(void) +void test_constructor5() __attribute__((constructor)); +void test_constructor5() { tracepoint(tp, constructor_c_across_units_after_provider); } -void test_destructor5(void) __attribute__((destructor)); -void test_destructor5(void) +void test_destructor5() __attribute__((destructor)); +void test_destructor5() { tracepoint(tp, destructor_c_across_units_after_provider); } diff --git a/tests/utils/testapp/gen-ust-events-constructor/main-a.cpp b/tests/utils/testapp/gen-ust-events-constructor/main-a.cpp index 118ce66bd..ca95ca428 100644 --- a/tests/utils/testapp/gen-ust-events-constructor/main-a.cpp +++ b/tests/utils/testapp/gen-ust-events-constructor/main-a.cpp @@ -12,24 +12,24 @@ extern "C" { #include "tp.h" /* Use tracepoints defined and provided by static archive. */ -void test_constructor_a(void) __attribute__((constructor)); -void test_constructor_a(void) +void test_constructor_a() __attribute__((constructor)); +void test_constructor_a() { tracepoint(tp_a_c, constructor_c_provider_static_archive); } -void test_destructor_a(void) __attribute__((destructor)); -void test_destructor_a(void) +void test_destructor_a() __attribute__((destructor)); +void test_destructor_a() { tracepoint(tp_a_c, destructor_c_provider_static_archive); } Obja g_obja_static_archive("global - static archive define and provider"); -int main(void) +int main() { - Obj l_obj("main() local"); - Obja l_obja("main() local - static archive define and provider"); + const Obj l_obj("main() local"); + const Obja l_obja("main() local - static archive define and provider"); tracepoint(tp, main); return 0; diff --git a/tests/utils/testapp/gen-ust-events-constructor/main.cpp b/tests/utils/testapp/gen-ust-events-constructor/main.cpp index 35240ac14..7b1015b5b 100644 --- a/tests/utils/testapp/gen-ust-events-constructor/main.cpp +++ b/tests/utils/testapp/gen-ust-events-constructor/main.cpp @@ -10,24 +10,24 @@ #include "tp.h" /* Use tracepoints defined and provided by shared libraries. */ -void test_constructor_so(void) __attribute__((constructor)); -void test_constructor_so(void) +void test_constructor_so() __attribute__((constructor)); +void test_constructor_so() { tracepoint(tp_so_c, constructor_c_provider_shared_library); } -void test_destructor_so(void) __attribute__((destructor)); -void test_destructor_so(void) +void test_destructor_so() __attribute__((destructor)); +void test_destructor_so() { tracepoint(tp_so_c, destructor_c_provider_shared_library); } Objso g_objso_shared_library("global - shared library define and provider"); -int main(void) +int main() { - Obj l_obj("main() local"); - Objso l_objso("main() local - shared library define and provider"); + const Obj l_obj("main() local"); + const Objso l_objso("main() local - shared library define and provider"); tracepoint(tp, main); return 0; diff --git a/tests/utils/testapp/gen-ust-events-constructor/obj-a.h b/tests/utils/testapp/gen-ust-events-constructor/obj-a.h index cd341d8c7..85eccde8f 100644 --- a/tests/utils/testapp/gen-ust-events-constructor/obj-a.h +++ b/tests/utils/testapp/gen-ust-events-constructor/obj-a.h @@ -10,13 +10,13 @@ struct Obj { const char *msg; - Obj(const char *msg); + explicit Obj(const char *msg); ~Obj(); }; struct Obja { const char *msg; - Obja(const char *msg); + explicit Obja(const char *msg); ~Obja(); }; diff --git a/tests/utils/testapp/gen-ust-events-constructor/obj.h b/tests/utils/testapp/gen-ust-events-constructor/obj.h index 0efe5ab4f..a906fb071 100644 --- a/tests/utils/testapp/gen-ust-events-constructor/obj.h +++ b/tests/utils/testapp/gen-ust-events-constructor/obj.h @@ -10,13 +10,13 @@ struct Obj { const char *msg; - Obj(const char *msg); + explicit Obj(const char *msg); ~Obj(); }; struct Objso { const char *msg; - Objso(const char *msg); + explicit Objso(const char *msg); ~Objso(); }; diff --git a/tests/utils/testapp/gen-ust-events/gen-ust-events.cpp b/tests/utils/testapp/gen-ust-events/gen-ust-events.cpp index 3b62ed0df..0e6b4812a 100644 --- a/tests/utils/testapp/gen-ust-events/gen-ust-events.cpp +++ b/tests/utils/testapp/gen-ust-events/gen-ust-events.cpp @@ -51,8 +51,8 @@ int main(int argc, char **argv) long values[] = { 1, 2, 3 }; char text[10] = "test"; char escape[10] = "\\*"; - double dbl = 2.0; - float flt = 2222.0; + const double dbl = 2.0; + const float flt = 2222.0; uint32_t net_values[] = { 1, 2, 3 }; int nr_iter = 100, ret = 0, first_event_file_created = 0; useconds_t nr_usec = 0; diff --git a/tests/utils/testapp/gen-ust-nevents/gen-ust-nevents.cpp b/tests/utils/testapp/gen-ust-nevents/gen-ust-nevents.cpp index b7c3974ee..791aa6754 100644 --- a/tests/utils/testapp/gen-ust-nevents/gen-ust-nevents.cpp +++ b/tests/utils/testapp/gen-ust-nevents/gen-ust-nevents.cpp @@ -37,8 +37,8 @@ int main(int argc, char **argv) int i, netint, ret = 0, option_index, option; long values[] = { 1, 2, 3 }; char text[10] = "test"; - double dbl = 2.0; - float flt = 2222.0; + const double dbl = 2.0; + const float flt = 2222.0; unsigned int nr_iter = 100; useconds_t nr_usec = 0; char *wait_before_first_event_file_path = nullptr; diff --git a/tests/utils/xml-utils/extract_xml.cpp b/tests/utils/xml-utils/extract_xml.cpp index 280f2ed02..2531d0832 100644 --- a/tests/utils/xml-utils/extract_xml.cpp +++ b/tests/utils/xml-utils/extract_xml.cpp @@ -180,7 +180,7 @@ static int extract_xpath(const char *xml_path, const xmlChar *xpath) LTTNG_ASSERT(xml_path); LTTNG_ASSERT(xpath); - ll::parser_ctx_uptr parserCtx{ xmlNewParserCtxt() }; + const ll::parser_ctx_uptr parserCtx{ xmlNewParserCtxt() }; if (!parserCtx) { fprintf(stderr, "ERR: could not allocate an XML parser context\n"); -- 2.34.1