From 5c7248cd5bce45bf64d563fb4e130a63bf345f11 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 13 Jan 2023 19:34:42 -0500 Subject: [PATCH] clang-tidy: add most bugprone warnings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Most of the changes proposed by clang-tidy are explicit checks for the result of strcmp() and adding parentheses for all macro parameters. Change-Id: I6ce7384b6d96035454d5456ac920becbf2882e65 Signed-off-by: Jérémie Galarneau --- .clang-tidy | 51 ++++++++++++- doc/examples/rotation/rotate-client-example.c | 6 +- src/bin/lttng-crash/lttng-crash.cpp | 12 ++-- src/bin/lttng-relayd/live.cpp | 9 ++- src/bin/lttng-relayd/main.cpp | 14 +++- src/bin/lttng-sessiond/channel.cpp | 2 +- src/bin/lttng-sessiond/cmd.cpp | 14 ++-- .../ctf2-trace-class-visitor.cpp | 5 +- src/bin/lttng-sessiond/event.cpp | 2 +- src/bin/lttng-sessiond/main.cpp | 2 +- .../notification-thread-events.cpp | 4 +- src/bin/lttng-sessiond/timer.cpp | 20 +++--- src/bin/lttng-sessiond/trace-kernel.cpp | 4 +- src/bin/lttng-sessiond/trace-ust.cpp | 6 +- .../tsdl-trace-class-visitor.cpp | 6 +- src/bin/lttng-sessiond/ust-app.cpp | 6 +- src/bin/lttng-sessiond/ust-field-convert.cpp | 2 +- .../lttng-sessiond/ust-registry-channel.cpp | 2 +- src/bin/lttng/commands/add_context.cpp | 2 +- src/bin/lttng/commands/enable_events.cpp | 2 +- src/common/actions/rotate-session.cpp | 2 +- src/common/actions/snapshot-session.cpp | 2 +- src/common/actions/start-session.cpp | 2 +- src/common/actions/stop-session.cpp | 2 +- src/common/argpar/argpar.h | 2 +- src/common/conditions/buffer-usage.cpp | 4 +- src/common/conditions/event-rule-matches.cpp | 2 +- .../conditions/session-consumed-size.cpp | 2 +- src/common/conditions/session-rotation.cpp | 2 +- src/common/config/session-config.cpp | 11 +-- src/common/consumer/consumer-timer.hpp | 10 +-- src/common/consumer/consumer.cpp | 19 +++-- src/common/context.cpp | 2 +- src/common/defaults.hpp | 4 +- src/common/event-rule/jul-logging.cpp | 4 +- src/common/event-rule/kernel-kprobe.cpp | 2 +- src/common/event-rule/kernel-syscall.cpp | 4 +- src/common/event-rule/kernel-tracepoint.cpp | 4 +- src/common/event-rule/kernel-uprobe.cpp | 2 +- src/common/event-rule/log4j-logging.cpp | 4 +- src/common/event-rule/python-logging.cpp | 4 +- src/common/event-rule/user-tracepoint.cpp | 6 +- src/common/event.cpp | 2 +- src/common/fd-tracker/fd-tracker.cpp | 14 ++-- src/common/hashtable/utils.cpp | 72 +++++++++---------- src/common/ini-config/ini-config.cpp | 2 +- .../kernel-consumer/kernel-consumer.cpp | 7 +- src/common/kernel-probe.cpp | 2 +- src/common/lttng-elf.cpp | 56 +++++++-------- src/common/lttng-kernel-old.hpp | 6 +- src/common/lttng-kernel.hpp | 6 +- src/common/macros.hpp | 8 +-- src/common/optional.hpp | 5 +- src/common/runas.cpp | 35 ++++----- src/common/trace-chunk.cpp | 2 +- src/common/tracker.cpp | 10 +-- src/common/urcu.hpp | 6 +- src/common/userspace-probe.cpp | 10 +-- src/common/ust-consumer/ust-consumer.cpp | 3 +- src/lib/lttng-ctl/lttng-ctl.cpp | 12 ++-- src/lib/lttng-ctl/tracker.cpp | 59 +++++++-------- src/vendor/.clang-tidy | 1 + .../tools/trigger/utils/notification-client.c | 4 +- tests/unit/test_fd_tracker.cpp | 2 +- tests/unit/test_unix_socket.cpp | 2 +- 65 files changed, 340 insertions(+), 253 deletions(-) create mode 100644 src/vendor/.clang-tidy diff --git a/.clang-tidy b/.clang-tidy index f2bcc4397..666624f20 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -2,11 +2,58 @@ HeaderFilterRegex: '.*((include/.*-internal)|(src/common.*)|(src/bin.*)|(src/lib Checks: '-*, bugprone-argument-comment, bugprone-assert-side-effect, + bugprone-assignment-in-if-condition, + bugprone-bad-signal-to-kill-thread, + bugprone-bool-pointer-implicit-conversion, + bugprone-copy-constructor-init, bugprone-dangling-handle, + bugprone-exception-escape, + bugprone-fold-init-type, + bugprone-forward-declaration-namespace, + bugprone-forwarding-reference-overload, bugprone-inaccurate-erase, + bugprone-incorrect-roundings, + bugprone-infinite-loop, + bugprone-integer-division, + bugprone-macro-parentheses, + bugprone-macro-repeated-side-effects, + bugprone-misplaced-operator-in-strlen-in-alloc, + bugprone-misplaced-pointer-arithmetic-in-alloc, + bugprone-move-forwarding-reference, + bugprone-multiple-statement-macro, + bugprone-not-null-terminated-result, + bugprone-parent-virtual-call, + bugprone-posix-return, + bugprone-shared-ptr-array-mismatch, + bugprone-signal-handler, + bugprone-signed-char-misuse, + bugprone-sizeof-container, + bugprone-sizeof-expression, + bugprone-standalone-empty, bugprone-string-constructor, bugprone-string-integer-assignment, + bugprone-string-literal-with-embedded-nul, + bugprone-suspicious-enum-usage, + bugprone-suspicious-include, + bugprone-suspicious-memory-comparison + bugprone-suspicious-memset-usage, + bugprone-suspicious-missing-comma, + bugprone-suspicious-realloc-usage, + bugprone-suspicious-semicolon, + bugprone-suspicious-string-compare, + bugprone-swapped-arguments, + bugprone-terminating-continue, + bugprone-throw-keyword-missing, + bugprone-too-small-loop-variable, + bugprone-unchecked-optional-access bugprone-undefined-memory-manipulation, + bugprone-undelegated-constructor, + bugprone-unhandled-exception-at-new, + bugprone-unhandled-self-assignment, + bugprone-unused-raii, + bugprone-unused-return-value, + bugprone-use-after-move, + bugprone-virtual-near-miss, bugprone-unused-raii, bugprone-use-after-move, google-build-explicit-make-pair, @@ -35,4 +82,6 @@ Checks: '-*, FormatStyle: 'file' CheckOptions: - key: bugprone-assert-side-effect.AssertMacros - value: assert,LTTNG_ASSERT \ No newline at end of file + value: assert,LTTNG_ASSERT + - key: bugprone-signed-char-misuse.CharTypdefsToIgnore + value: 'int8_t' diff --git a/doc/examples/rotation/rotate-client-example.c b/doc/examples/rotation/rotate-client-example.c index a5ee70da3..86e5b04f2 100644 --- a/doc/examples/rotation/rotate-client-example.c +++ b/doc/examples/rotation/rotate-client-example.c @@ -37,6 +37,7 @@ #include #include #include +#include #define DEFAULT_DATA_AVAILABILITY_WAIT_TIME 200000 /* usec */ @@ -44,7 +45,10 @@ static volatile int quit = 0; static void sighandler(int signal __attribute__((unused))) { - printf("Signal caught, exiting\n"); + const char msg[] = "Signal caught, exiting\n"; + const int ret = write(STDOUT_FILENO, msg, sizeof(msg)); + + assert(ret == 0); /* NOLINT assert is not async signal safe */ quit = 1; } diff --git a/src/bin/lttng-crash/lttng-crash.cpp b/src/bin/lttng-crash/lttng-crash.cpp index bd5482363..d4e41e033 100644 --- a/src/bin/lttng-crash/lttng-crash.cpp +++ b/src/bin/lttng-crash/lttng-crash.cpp @@ -388,13 +388,13 @@ _crash_get_field(const struct lttng_crash_layout *layout, const char *ptr, size_ } #define crash_get_field(layout, map, name) \ - _crash_get_field(layout, (map) + (layout)->offset.name, layout->length.name) + _crash_get_field(layout, (map) + (layout)->offset.name, (layout)->length.name) -#define crash_get_array_field(layout, map, array_name, idx, field_name) \ - _crash_get_field(layout, \ - (map) + (layout)->offset.array_name + \ - (idx * (layout)->stride.array_name) + \ - (layout)->offset.field_name, \ +#define crash_get_array_field(layout, map, array_name, idx, field_name) \ + _crash_get_field(layout, \ + (map) + (layout)->offset.array_name + \ + ((idx) * (layout)->stride.array_name) + \ + (layout)->offset.field_name, \ (layout)->length.field_name) #define crash_get_hdr_raw_field(layout, hdr, name) ((hdr)->name) diff --git a/src/bin/lttng-relayd/live.cpp b/src/bin/lttng-relayd/live.cpp index f862709ac..786feaae8 100644 --- a/src/bin/lttng-relayd/live.cpp +++ b/src/bin/lttng-relayd/live.cpp @@ -904,7 +904,9 @@ static void *thread_dispatcher(void *data __attribute__((unused))) * the data will be read at some point in time * or wait to the end of the world :) */ - ret = lttng_write(live_conn_pipe[1], &conn, sizeof(conn)); + ret = lttng_write(live_conn_pipe[1], &conn, sizeof(conn)); /* NOLINT sizeof + used on a + pointer. */ if (ret < 0) { PERROR("write conn pipe"); connection_put(conn); @@ -2640,7 +2642,10 @@ restart: if (revents & LPOLLIN) { struct relay_connection *conn; - ret = lttng_read(live_conn_pipe[0], &conn, sizeof(conn)); + ret = lttng_read(live_conn_pipe[0], + &conn, + sizeof(conn)); /* NOLINT sizeof used on a + pointer. */ if (ret < 0) { goto error; } diff --git a/src/bin/lttng-relayd/main.cpp b/src/bin/lttng-relayd/main.cpp index e7598974d..9793e2778 100644 --- a/src/bin/lttng-relayd/main.cpp +++ b/src/bin/lttng-relayd/main.cpp @@ -490,7 +490,7 @@ static int config_entry_handler(const struct config_entry *entry, for (i = 0; i < (sizeof(long_options) / sizeof(struct option)) - 1; i++) { /* Ignore if entry name is not fully matched. */ - if (strcmp(entry->name, long_options[i].name)) { + if (strcmp(entry->name, long_options[i].name) != 0) { continue; } @@ -1320,7 +1320,12 @@ static void *relay_thread_dispatcher(void *data __attribute__((unused))) * the data will be read at some point in time * or wait to the end of the world :) */ - ret = lttng_write(relay_conn_pipe[1], &new_conn, sizeof(new_conn)); + ret = lttng_write(relay_conn_pipe[1], &new_conn, sizeof(new_conn)); /* NOLINT + sizeof + used + on a + pointer. + */ if (ret < 0) { PERROR("write connection pipe"); connection_put(new_conn); @@ -3961,7 +3966,10 @@ restart: if (revents & LPOLLIN) { struct relay_connection *conn; - ret = lttng_read(relay_conn_pipe[0], &conn, sizeof(conn)); + ret = lttng_read(relay_conn_pipe[0], + &conn, + sizeof(conn)); /* NOLINT sizeof used on a + pointer. */ if (ret < 0) { goto error; } diff --git a/src/bin/lttng-sessiond/channel.cpp b/src/bin/lttng-sessiond/channel.cpp index 96eed11c0..2e7ed527d 100644 --- a/src/bin/lttng-sessiond/channel.cpp +++ b/src/bin/lttng-sessiond/channel.cpp @@ -449,7 +449,7 @@ enum lttng_error_code channel_ust_create(struct ltt_ust_session *usess, /* Adding the channel to the channel hash table. */ rcu_read_lock(); - if (strncmp(uchan->name, DEFAULT_METADATA_NAME, sizeof(uchan->name))) { + if (strncmp(uchan->name, DEFAULT_METADATA_NAME, sizeof(uchan->name)) != 0) { lttng_ht_add_unique_str(usess->domain_global.channels, &uchan->node); chan_published = true; } else { diff --git a/src/bin/lttng-sessiond/cmd.cpp b/src/bin/lttng-sessiond/cmd.cpp index 388e056e0..8f274abcb 100644 --- a/src/bin/lttng-sessiond/cmd.cpp +++ b/src/bin/lttng-sessiond/cmd.cpp @@ -1435,19 +1435,23 @@ static enum lttng_error_code cmd_enable_channel_internal(struct ltt_session *ses * adhered to. */ if (domain->type == LTTNG_DOMAIN_JUL) { - if (strncmp(attr->name, DEFAULT_JUL_CHANNEL_NAME, LTTNG_SYMBOL_NAME_LEN)) { + if (strncmp(attr->name, + DEFAULT_JUL_CHANNEL_NAME, + LTTNG_SYMBOL_NAME_LEN - 1) != 0) { ret_code = LTTNG_ERR_INVALID_CHANNEL_NAME; goto error; } } else if (domain->type == LTTNG_DOMAIN_LOG4J) { - if (strncmp(attr->name, DEFAULT_LOG4J_CHANNEL_NAME, LTTNG_SYMBOL_NAME_LEN)) { + if (strncmp(attr->name, + DEFAULT_LOG4J_CHANNEL_NAME, + LTTNG_SYMBOL_NAME_LEN - 1) != 0) { ret_code = LTTNG_ERR_INVALID_CHANNEL_NAME; goto error; } } else if (domain->type == LTTNG_DOMAIN_PYTHON) { if (strncmp(attr->name, DEFAULT_PYTHON_CHANNEL_NAME, - LTTNG_SYMBOL_NAME_LEN)) { + LTTNG_SYMBOL_NAME_LEN - 1) != 0) { ret_code = LTTNG_ERR_INVALID_CHANNEL_NAME; goto error; } @@ -1935,11 +1939,11 @@ int cmd_add_context(struct command_ctx *cmd_ctx, * name, return an error. */ if (domain == LTTNG_DOMAIN_JUL && *channel_name && - strcmp(channel_name, DEFAULT_JUL_CHANNEL_NAME)) { + strcmp(channel_name, DEFAULT_JUL_CHANNEL_NAME) != 0) { ret = LTTNG_ERR_UST_CHAN_NOT_FOUND; goto error; } else if (domain == LTTNG_DOMAIN_LOG4J && *channel_name && - strcmp(channel_name, DEFAULT_LOG4J_CHANNEL_NAME)) { + strcmp(channel_name, DEFAULT_LOG4J_CHANNEL_NAME) != 0) { ret = LTTNG_ERR_UST_CHAN_NOT_FOUND; goto error; } diff --git a/src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp b/src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp index 6b6c6265b..24fe15792 100644 --- a/src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp +++ b/src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp @@ -103,7 +103,8 @@ const char *get_role_name(lst::static_length_blob_type::role role) namespace ctf2 { class trace_environment_visitor : public lst::trace_class_environment_visitor { public: - trace_environment_visitor() = default; + trace_environment_visitor() = default; /* NOLINT clang-tidy 14 identifies this as a move + constructor. */ void visit(const lst::environment_field& field) override { @@ -134,7 +135,7 @@ private: class field_visitor : public lttng::sessiond::trace::field_visitor, public lttng::sessiond::trace::type_visitor { public: - field_visitor() = default; + field_visitor() = default; /* NOLINT clang-tidy 14 identifies this as a move constructor. */ /* Only call once. */ json::json move_fragment() diff --git a/src/bin/lttng-sessiond/event.cpp b/src/bin/lttng-sessiond/event.cpp index 0dd1e387f..e81fa9417 100644 --- a/src/bin/lttng-sessiond/event.cpp +++ b/src/bin/lttng-sessiond/event.cpp @@ -80,7 +80,7 @@ int event_kernel_disable_event(struct ltt_kernel_channel *kchan, cds_list_for_each_entry (kevent, &kchan->events_list.head, list) { if (type != LTTNG_EVENT_ALL && kevent->type != type) continue; - if (event_name != nullptr && strcmp(event_name, kevent->event->name)) { + if (event_name != nullptr && strcmp(event_name, kevent->event->name) != 0) { continue; } found++; diff --git a/src/bin/lttng-sessiond/main.cpp b/src/bin/lttng-sessiond/main.cpp index 016333905..cc3285619 100644 --- a/src/bin/lttng-sessiond/main.cpp +++ b/src/bin/lttng-sessiond/main.cpp @@ -791,7 +791,7 @@ static int config_entry_handler(const struct config_entry *entry, for (i = 0; i < (sizeof(long_options) / sizeof(struct option)) - 1; i++) { /* Ignore if not fully matched. */ - if (strcmp(entry->name, long_options[i].name)) { + if (strcmp(entry->name, long_options[i].name) != 0) { continue; } diff --git a/src/bin/lttng-sessiond/notification-thread-events.cpp b/src/bin/lttng-sessiond/notification-thread-events.cpp index c9348cb3d..a560ad1c0 100644 --- a/src/bin/lttng-sessiond/notification-thread-events.cpp +++ b/src/bin/lttng-sessiond/notification-thread-events.cpp @@ -1416,10 +1416,10 @@ static bool buffer_usage_condition_applies_to_channel(const struct lttng_conditi status = lttng_condition_buffer_usage_get_channel_name(condition, &condition_channel_name); LTTNG_ASSERT((status == LTTNG_CONDITION_STATUS_OK) && condition_channel_name); - if (strcmp(channel_info->session_info->name, condition_session_name)) { + if (strcmp(channel_info->session_info->name, condition_session_name) != 0) { goto fail; } - if (strcmp(channel_info->name, condition_channel_name)) { + if (strcmp(channel_info->name, condition_channel_name) != 0) { goto fail; } diff --git a/src/bin/lttng-sessiond/timer.cpp b/src/bin/lttng-sessiond/timer.cpp index b99428041..243b56219 100644 --- a/src/bin/lttng-sessiond/timer.cpp +++ b/src/bin/lttng-sessiond/timer.cpp @@ -15,17 +15,17 @@ #include #include -#define LTTNG_SESSIOND_SIG_QS SIGRTMIN + 10 -#define LTTNG_SESSIOND_SIG_EXIT SIGRTMIN + 11 -#define LTTNG_SESSIOND_SIG_PENDING_ROTATION_CHECK SIGRTMIN + 12 -#define LTTNG_SESSIOND_SIG_SCHEDULED_ROTATION SIGRTMIN + 13 - -#define UINT_TO_PTR(value) \ - ({ \ - LTTNG_ASSERT(value <= UINTPTR_MAX); \ - (void *) (uintptr_t) value; \ +#define LTTNG_SESSIOND_SIG_QS (SIGRTMIN + 10) +#define LTTNG_SESSIOND_SIG_EXIT (SIGRTMIN + 11) +#define LTTNG_SESSIOND_SIG_PENDING_ROTATION_CHECK (SIGRTMIN + 12) +#define LTTNG_SESSIOND_SIG_SCHEDULED_ROTATION (SIGRTMIN + 13) + +#define UINT_TO_PTR(value) \ + ({ \ + LTTNG_ASSERT((value) <= UINTPTR_MAX); \ + (void *) (uintptr_t) (value); \ }) -#define PTR_TO_UINT(ptr) ((uintptr_t) ptr) +#define PTR_TO_UINT(ptr) ((uintptr_t) (ptr)) namespace { /* diff --git a/src/bin/lttng-sessiond/trace-kernel.cpp b/src/bin/lttng-sessiond/trace-kernel.cpp index 4cf8e6f86..e1d591761 100644 --- a/src/bin/lttng-sessiond/trace-kernel.cpp +++ b/src/bin/lttng-sessiond/trace-kernel.cpp @@ -85,7 +85,7 @@ struct ltt_kernel_event *trace_kernel_find_event(char *name, if (type != LTTNG_EVENT_ALL && ev->type != type) { continue; } - if (strcmp(name, ev->event->name)) { + if (strcmp(name, ev->event->name) != 0) { continue; } if ((ev->filter && !filter) || (!ev->filter && filter)) { @@ -125,7 +125,7 @@ struct ltt_kernel_event *trace_kernel_get_event_by_name(char *name, if (type != LTTNG_EVENT_ALL && ev->type != type) { continue; } - if (strcmp(name, ev->event->name)) { + if (strcmp(name, ev->event->name) != 0) { continue; } found = 1; diff --git a/src/bin/lttng-sessiond/trace-ust.cpp b/src/bin/lttng-sessiond/trace-ust.cpp index 285e57909..1505c3159 100644 --- a/src/bin/lttng-sessiond/trace-ust.cpp +++ b/src/bin/lttng-sessiond/trace-ust.cpp @@ -645,15 +645,15 @@ int trace_ust_match_context(const struct ltt_ust_context *uctx, } if (strncmp(uctx->ctx.u.perf_counter.name, ctx->u.perf_counter.name, - LTTNG_UST_ABI_SYM_NAME_LEN)) { + LTTNG_UST_ABI_SYM_NAME_LEN) != 0) { return 0; } break; case LTTNG_UST_ABI_CONTEXT_APP_CONTEXT: LTTNG_ASSERT(uctx->ctx.u.app_ctx.provider_name); LTTNG_ASSERT(uctx->ctx.u.app_ctx.ctx_name); - if (strcmp(uctx->ctx.u.app_ctx.provider_name, ctx->u.app_ctx.provider_name) || - strcmp(uctx->ctx.u.app_ctx.ctx_name, ctx->u.app_ctx.ctx_name)) { + if (strcmp(uctx->ctx.u.app_ctx.provider_name, ctx->u.app_ctx.provider_name) != 0 || + strcmp(uctx->ctx.u.app_ctx.ctx_name, ctx->u.app_ctx.ctx_name) != 0) { return 0; } default: diff --git a/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp b/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp index ec41be6c6..6136f5fc7 100644 --- a/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp +++ b/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp @@ -786,9 +786,7 @@ private: class tsdl_trace_environment_visitor : public lst::trace_class_environment_visitor { public: - tsdl_trace_environment_visitor() : _environment{ "env {\n" } - { - } + tsdl_trace_environment_visitor() = default; void visit(const lst::environment_field& field) override { @@ -810,7 +808,7 @@ public: } private: - std::string _environment; + std::string _environment{ "env {\n" }; }; } /* namespace */ diff --git a/src/bin/lttng-sessiond/ust-app.cpp b/src/bin/lttng-sessiond/ust-app.cpp index 37e7204ea..684dec869 100644 --- a/src/bin/lttng-sessiond/ust-app.cpp +++ b/src/bin/lttng-sessiond/ust-app.cpp @@ -2841,13 +2841,13 @@ static int ht_match_ust_app_ctx(struct cds_lfht_node *node, const void *_key) case LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER: if (strncmp(key->u.perf_counter.name, ctx->ctx.u.perf_counter.name, - sizeof(key->u.perf_counter.name))) { + sizeof(key->u.perf_counter.name)) != 0) { goto no_match; } break; case LTTNG_UST_ABI_CONTEXT_APP_CONTEXT: - if (strcmp(key->u.app_ctx.provider_name, ctx->ctx.u.app_ctx.provider_name) || - strcmp(key->u.app_ctx.ctx_name, ctx->ctx.u.app_ctx.ctx_name)) { + if (strcmp(key->u.app_ctx.provider_name, ctx->ctx.u.app_ctx.provider_name) != 0 || + strcmp(key->u.app_ctx.ctx_name, ctx->ctx.u.app_ctx.ctx_name) != 0) { goto no_match; } break; diff --git a/src/bin/lttng-sessiond/ust-field-convert.cpp b/src/bin/lttng-sessiond/ust-field-convert.cpp index 67fcdf1b2..62ac4825b 100644 --- a/src/bin/lttng-sessiond/ust-field-convert.cpp +++ b/src/bin/lttng-sessiond/ust-field-convert.cpp @@ -539,7 +539,7 @@ lst::type::cuptr create_sequence_nestable_type_from_ust_ctl_fields( lst::field_location::elements length_field_location_elements = current_field_location_elements; - length_field_location_elements.emplace_back(std::move(length_field_name)); + length_field_location_elements.emplace_back(length_field_name); lst::field_location length_field_location{ lookup_root, std::move(length_field_location_elements) }; diff --git a/src/bin/lttng-sessiond/ust-registry-channel.cpp b/src/bin/lttng-sessiond/ust-registry-channel.cpp index 3cf58e088..03532cd09 100644 --- a/src/bin/lttng-sessiond/ust-registry-channel.cpp +++ b/src/bin/lttng-sessiond/ust-registry-channel.cpp @@ -447,7 +447,7 @@ void lsu::registry_channel::add_event(int session_objd, const auto& event_ref = *event; /* Ownership transferred to _events hash table. */ - event.release(); + (void) event.release(); /* Request next event id if the node was successfully added. */ event_id = event_ref.id; diff --git a/src/bin/lttng/commands/add_context.cpp b/src/bin/lttng/commands/add_context.cpp index cc5e487df..79142cc65 100644 --- a/src/bin/lttng/commands/add_context.cpp +++ b/src/bin/lttng/commands/add_context.cpp @@ -976,7 +976,7 @@ static struct ctx_type *get_context_type(const char *ctx) } /* String starts with $app. */ - if (strncmp(ctx, app_ctx_prefix, sizeof(app_ctx_prefix) - 1)) { + if (strncmp(ctx, app_ctx_prefix, sizeof(app_ctx_prefix) - 1) != 0) { goto not_found; } diff --git a/src/bin/lttng/commands/enable_events.cpp b/src/bin/lttng/commands/enable_events.cpp index ef58bfa75..f9e464510 100644 --- a/src/bin/lttng/commands/enable_events.cpp +++ b/src/bin/lttng/commands/enable_events.cpp @@ -845,7 +845,7 @@ static int enable_events(char *session_name, char *event_list) switch (opt_event_type) { case LTTNG_EVENT_ALL: /* Enable tracepoints and syscalls */ /* If event name differs from *, select tracepoint. */ - if (strcmp(ev->name, "*")) { + if (strcmp(ev->name, "*") != 0) { ev->type = LTTNG_EVENT_TRACEPOINT; } break; diff --git a/src/common/actions/rotate-session.cpp b/src/common/actions/rotate-session.cpp index c2b962ab6..8997542e9 100644 --- a/src/common/actions/rotate-session.cpp +++ b/src/common/actions/rotate-session.cpp @@ -96,7 +96,7 @@ static bool lttng_action_rotate_session_is_equal(const struct lttng_action *_a, /* Action is not valid if this is not true. */ LTTNG_ASSERT(a->session_name); LTTNG_ASSERT(b->session_name); - if (strcmp(a->session_name, b->session_name)) { + if (strcmp(a->session_name, b->session_name) != 0) { goto end; } diff --git a/src/common/actions/snapshot-session.cpp b/src/common/actions/snapshot-session.cpp index 23d6f8a56..015a834dd 100644 --- a/src/common/actions/snapshot-session.cpp +++ b/src/common/actions/snapshot-session.cpp @@ -117,7 +117,7 @@ static bool lttng_action_snapshot_session_is_equal(const struct lttng_action *_a /* Action is not valid if this is not true. */ LTTNG_ASSERT(a->session_name); LTTNG_ASSERT(b->session_name); - if (strcmp(a->session_name, b->session_name)) { + if (strcmp(a->session_name, b->session_name) != 0) { goto end; } diff --git a/src/common/actions/start-session.cpp b/src/common/actions/start-session.cpp index aed2938c6..1004290fe 100644 --- a/src/common/actions/start-session.cpp +++ b/src/common/actions/start-session.cpp @@ -96,7 +96,7 @@ static bool lttng_action_start_session_is_equal(const struct lttng_action *_a, /* Action is not valid if this is not true. */ LTTNG_ASSERT(a->session_name); LTTNG_ASSERT(b->session_name); - if (strcmp(a->session_name, b->session_name)) { + if (strcmp(a->session_name, b->session_name) != 0) { goto end; } diff --git a/src/common/actions/stop-session.cpp b/src/common/actions/stop-session.cpp index 9db4a25fc..be8fd0aae 100644 --- a/src/common/actions/stop-session.cpp +++ b/src/common/actions/stop-session.cpp @@ -95,7 +95,7 @@ static bool lttng_action_stop_session_is_equal(const struct lttng_action *_a, /* Action is not valid if this is not true. */ LTTNG_ASSERT(a->session_name); LTTNG_ASSERT(b->session_name); - if (strcmp(a->session_name, b->session_name)) { + if (strcmp(a->session_name, b->session_name) != 0) { goto end; } diff --git a/src/common/argpar/argpar.h b/src/common/argpar/argpar.h index c528cc441..af9df9f5b 100644 --- a/src/common/argpar/argpar.h +++ b/src/common/argpar/argpar.h @@ -334,7 +334,7 @@ void argpar_item_destroy(const struct argpar_item *item); #define ARGPAR_ITEM_DESTROY_AND_RESET(_item) \ { \ argpar_item_destroy(_item); \ - _item = NULL; \ + ((_item)) = NULL; \ } /// @} diff --git a/src/common/conditions/buffer-usage.cpp b/src/common/conditions/buffer-usage.cpp index 4574d6242..c78528735 100644 --- a/src/common/conditions/buffer-usage.cpp +++ b/src/common/conditions/buffer-usage.cpp @@ -160,13 +160,13 @@ static bool lttng_condition_buffer_usage_is_equal(const struct lttng_condition * /* Condition is not valid if this is not true. */ LTTNG_ASSERT(a->session_name); LTTNG_ASSERT(b->session_name); - if (strcmp(a->session_name, b->session_name)) { + if (strcmp(a->session_name, b->session_name) != 0) { goto end; } LTTNG_ASSERT(a->channel_name); LTTNG_ASSERT(b->channel_name); - if (strcmp(a->channel_name, b->channel_name)) { + if (strcmp(a->channel_name, b->channel_name) != 0) { goto end; } diff --git a/src/common/conditions/event-rule-matches.cpp b/src/common/conditions/event-rule-matches.cpp index d951ccd3c..d86d2ad7b 100644 --- a/src/common/conditions/event-rule-matches.cpp +++ b/src/common/conditions/event-rule-matches.cpp @@ -528,7 +528,7 @@ static uint64_t uint_from_buffer(const struct lttng_buffer_view *view, size_t si switch (size) { case 1: - ret = (uint64_t) *uint_view.data; + ret = (unsigned char) *uint_view.data; break; case sizeof(uint32_t): { diff --git a/src/common/conditions/session-consumed-size.cpp b/src/common/conditions/session-consumed-size.cpp index 9a5c96e87..1e9cb4379 100644 --- a/src/common/conditions/session-consumed-size.cpp +++ b/src/common/conditions/session-consumed-size.cpp @@ -120,7 +120,7 @@ static bool lttng_condition_session_consumed_size_is_equal(const struct lttng_co LTTNG_ASSERT(a->session_name); LTTNG_ASSERT(b->session_name); - if (strcmp(a->session_name, b->session_name)) { + if (strcmp(a->session_name, b->session_name) != 0) { goto end; } diff --git a/src/common/conditions/session-rotation.cpp b/src/common/conditions/session-rotation.cpp index c62b5b38a..20af727cf 100644 --- a/src/common/conditions/session-rotation.cpp +++ b/src/common/conditions/session-rotation.cpp @@ -133,7 +133,7 @@ static bool lttng_condition_session_rotation_is_equal(const struct lttng_conditi goto end; } - if (a->session_name && b->session_name && strcmp(a->session_name, b->session_name)) { + if (a->session_name && b->session_name && strcmp(a->session_name, b->session_name) != 0) { goto end; } diff --git a/src/common/config/session-config.cpp b/src/common/config/session-config.cpp index 95edd7aa4..9af61fa93 100644 --- a/src/common/config/session-config.cpp +++ b/src/common/config/session-config.cpp @@ -1260,7 +1260,7 @@ static int create_session(const char *name, } if (strcmp((const char *) consumer_output_node->name, - config_element_consumer_output)) { + config_element_consumer_output) != 0) { WARN("Invalid output type, expected %s node", config_element_consumer_output); ret = -LTTNG_ERR_LOAD_INVALID_CONFIG; @@ -3035,7 +3035,7 @@ static int process_session_rotation_schedules_node(xmlNodePtr schedules_node, time_us_node = xmlFirstElementChild(child); if (!time_us_node || strcmp((const char *) time_us_node->name, - config_element_rotation_schedule_periodic_time_us)) { + config_element_rotation_schedule_periodic_time_us) != 0) { ret = -LTTNG_ERR_LOAD_INVALID_CONFIG; goto end; } @@ -3061,7 +3061,7 @@ static int process_session_rotation_schedules_node(xmlNodePtr schedules_node, bytes_node = xmlFirstElementChild(child); if (!bytes_node || strcmp((const char *) bytes_node->name, - config_element_rotation_schedule_size_threshold_bytes)) { + config_element_rotation_schedule_size_threshold_bytes) != 0) { ret = -LTTNG_ERR_LOAD_INVALID_CONFIG; goto end; } @@ -3208,7 +3208,7 @@ static int process_session_node(xmlNodePtr session_node, goto error; } - if (session_name && strcmp((char *) name, session_name)) { + if (session_name && strcmp((char *) name, session_name) != 0) { /* This is not the session we are looking for */ ret = -LTTNG_ERR_NO_SESSION; goto error; @@ -3573,7 +3573,8 @@ static int load_session_from_path(const char *path, /* Does the file end with .lttng? */ if (strcmp(DEFAULT_SESSION_CONFIG_FILE_EXTENSION, result->d_name + file_name_len - - sizeof(DEFAULT_SESSION_CONFIG_FILE_EXTENSION) + 1)) { + sizeof(DEFAULT_SESSION_CONFIG_FILE_EXTENSION) + 1) != + 0) { continue; } diff --git a/src/common/consumer/consumer-timer.hpp b/src/common/consumer/consumer-timer.hpp index b38460f60..656ebe036 100644 --- a/src/common/consumer/consumer-timer.hpp +++ b/src/common/consumer/consumer-timer.hpp @@ -14,11 +14,11 @@ #include "consumer.hpp" -#define LTTNG_CONSUMER_SIG_SWITCH SIGRTMIN + 10 -#define LTTNG_CONSUMER_SIG_TEARDOWN SIGRTMIN + 11 -#define LTTNG_CONSUMER_SIG_LIVE SIGRTMIN + 12 -#define LTTNG_CONSUMER_SIG_MONITOR SIGRTMIN + 13 -#define LTTNG_CONSUMER_SIG_EXIT SIGRTMIN + 14 +#define LTTNG_CONSUMER_SIG_SWITCH ((SIGRTMIN + 10)) +#define LTTNG_CONSUMER_SIG_TEARDOWN ((SIGRTMIN + 11)) +#define LTTNG_CONSUMER_SIG_LIVE ((SIGRTMIN + 12)) +#define LTTNG_CONSUMER_SIG_MONITOR ((SIGRTMIN + 13)) +#define LTTNG_CONSUMER_SIG_EXIT ((SIGRTMIN + 14)) #define CLOCKID CLOCK_MONOTONIC diff --git a/src/common/consumer/consumer.cpp b/src/common/consumer/consumer.cpp index eb7e6375e..4d64b0ea2 100644 --- a/src/common/consumer/consumer.cpp +++ b/src/common/consumer/consumer.cpp @@ -104,7 +104,8 @@ static void notify_thread_lttng_pipe(struct lttng_pipe *pipe) LTTNG_ASSERT(pipe); - (void) lttng_pipe_write(pipe, &null_stream, sizeof(null_stream)); + (void) lttng_pipe_write(pipe, &null_stream, sizeof(null_stream)); /* NOLINT sizeof used on a + pointer. */ } static void notify_health_quit_pipe(int *pipe) @@ -2375,8 +2376,11 @@ void *consumer_thread_metadata_poll(void *data) pipe_len = lttng_pipe_read(ctx->consumer_metadata_pipe, &stream, - sizeof(stream)); - if (pipe_len < sizeof(stream)) { + sizeof(stream)); /* NOLINT sizeof + used on a + pointer. */ + if (pipe_len < sizeof(stream)) { /* NOLINT sizeof used on a + pointer. */ if (pipe_len < 0) { PERROR("read metadata stream"); } @@ -2643,9 +2647,12 @@ void *consumer_thread_data_poll(void *data) ssize_t pipe_readlen; DBG("consumer_data_pipe wake up"); - pipe_readlen = lttng_pipe_read( - ctx->consumer_data_pipe, &new_stream, sizeof(new_stream)); - if (pipe_readlen < sizeof(new_stream)) { + pipe_readlen = lttng_pipe_read(ctx->consumer_data_pipe, + &new_stream, + sizeof(new_stream)); /* NOLINT sizeof used on + a pointer. */ + if (pipe_readlen < sizeof(new_stream)) { /* NOLINT sizeof used on a pointer. + */ PERROR("Consumer data pipe"); /* Continue so we can at least handle the current stream(s). */ continue; diff --git a/src/common/context.cpp b/src/common/context.cpp index 60e30ad29..14763c00d 100644 --- a/src/common/context.cpp +++ b/src/common/context.cpp @@ -29,7 +29,7 @@ int parse_application_context(const char *str, char **out_provider_name, char ** } /* String starts with $app. */ - if (strncmp(str, app_ctx_prefix, sizeof(app_ctx_prefix) - 1)) { + if (strncmp(str, app_ctx_prefix, sizeof(app_ctx_prefix) - 1) != 0) { goto not_found; } diff --git a/src/common/defaults.hpp b/src/common/defaults.hpp index 4588fe768..cae1ec5fc 100644 --- a/src/common/defaults.hpp +++ b/src/common/defaults.hpp @@ -177,7 +177,7 @@ * than enough. We might end up with quantum computing in a cell phone when * reaching this limit. */ -#define DEFAULT_STREAM_NAME_LEN LTTNG_SYMBOL_NAME_LEN + 8 +#define DEFAULT_STREAM_NAME_LEN (LTTNG_SYMBOL_NAME_LEN + 8) /* Default channel attributes */ #define DEFAULT_CHANNEL_NAME "channel0" @@ -199,7 +199,7 @@ #define DEFAULT_PYTHON_EVENT_COMPONENT "lttng_python" #define DEFAULT_PYTHON_EVENT_NAME DEFAULT_PYTHON_EVENT_COMPONENT ":*" -#define DEFAULT_CHANNEL_OVERWRITE -1 +#define DEFAULT_CHANNEL_OVERWRITE (-1) #define DEFAULT_CHANNEL_TRACEFILE_SIZE CONFIG_DEFAULT_CHANNEL_TRACEFILE_SIZE #define DEFAULT_CHANNEL_TRACEFILE_COUNT CONFIG_DEFAULT_CHANNEL_TRACEFILE_COUNT diff --git a/src/common/event-rule/jul-logging.cpp b/src/common/event-rule/jul-logging.cpp index bff0aa6b6..3db273744 100644 --- a/src/common/event-rule/jul-logging.cpp +++ b/src/common/event-rule/jul-logging.cpp @@ -145,12 +145,12 @@ static bool lttng_event_rule_jul_logging_is_equal(const struct lttng_event_rule /* Long check. */ LTTNG_ASSERT(a->pattern); LTTNG_ASSERT(b->pattern); - if (strcmp(a->pattern, b->pattern)) { + if (strcmp(a->pattern, b->pattern) != 0) { goto end; } if (a->filter_expression && b->filter_expression) { - if (strcmp(a->filter_expression, b->filter_expression)) { + if (strcmp(a->filter_expression, b->filter_expression) != 0) { goto end; } } else if (!!a->filter_expression != !!b->filter_expression) { diff --git a/src/common/event-rule/kernel-kprobe.cpp b/src/common/event-rule/kernel-kprobe.cpp index 712136ebd..bae7bdfa7 100644 --- a/src/common/event-rule/kernel-kprobe.cpp +++ b/src/common/event-rule/kernel-kprobe.cpp @@ -138,7 +138,7 @@ static bool lttng_event_rule_kernel_kprobe_is_equal(const struct lttng_event_rul /* Long check */ LTTNG_ASSERT(a->name); LTTNG_ASSERT(b->name); - if (strcmp(a->name, b->name)) { + if (strcmp(a->name, b->name) != 0) { goto end; } diff --git a/src/common/event-rule/kernel-syscall.cpp b/src/common/event-rule/kernel-syscall.cpp index b65729cbb..23a432aac 100644 --- a/src/common/event-rule/kernel-syscall.cpp +++ b/src/common/event-rule/kernel-syscall.cpp @@ -120,12 +120,12 @@ static bool lttng_event_rule_kernel_syscall_is_equal(const struct lttng_event_ru LTTNG_ASSERT(a->pattern); LTTNG_ASSERT(b->pattern); - if (strcmp(a->pattern, b->pattern)) { + if (strcmp(a->pattern, b->pattern) != 0) { goto end; } if (a->filter_expression && b->filter_expression) { - if (strcmp(a->filter_expression, b->filter_expression)) { + if (strcmp(a->filter_expression, b->filter_expression) != 0) { goto end; } } else if (!!a->filter_expression != !!b->filter_expression) { diff --git a/src/common/event-rule/kernel-tracepoint.cpp b/src/common/event-rule/kernel-tracepoint.cpp index 77dd51ed0..50dda01b7 100644 --- a/src/common/event-rule/kernel-tracepoint.cpp +++ b/src/common/event-rule/kernel-tracepoint.cpp @@ -127,12 +127,12 @@ static bool lttng_event_rule_kernel_tracepoint_is_equal(const struct lttng_event /* Long check. */ LTTNG_ASSERT(a->pattern); LTTNG_ASSERT(b->pattern); - if (strcmp(a->pattern, b->pattern)) { + if (strcmp(a->pattern, b->pattern) != 0) { goto end; } if (a->filter_expression && b->filter_expression) { - if (strcmp(a->filter_expression, b->filter_expression)) { + if (strcmp(a->filter_expression, b->filter_expression) != 0) { goto end; } } else if (!!a->filter_expression != !!b->filter_expression) { diff --git a/src/common/event-rule/kernel-uprobe.cpp b/src/common/event-rule/kernel-uprobe.cpp index 9c4078982..6e750576c 100644 --- a/src/common/event-rule/kernel-uprobe.cpp +++ b/src/common/event-rule/kernel-uprobe.cpp @@ -123,7 +123,7 @@ static bool lttng_event_rule_kernel_uprobe_is_equal(const struct lttng_event_rul /* uprobe is invalid if this is not true. */ LTTNG_ASSERT(a->name); LTTNG_ASSERT(b->name); - if (strcmp(a->name, b->name)) { + if (strcmp(a->name, b->name) != 0) { goto end; } diff --git a/src/common/event-rule/log4j-logging.cpp b/src/common/event-rule/log4j-logging.cpp index fec9589ad..5655cd3bc 100644 --- a/src/common/event-rule/log4j-logging.cpp +++ b/src/common/event-rule/log4j-logging.cpp @@ -145,12 +145,12 @@ static bool lttng_event_rule_log4j_logging_is_equal(const struct lttng_event_rul /* Long check. */ LTTNG_ASSERT(a->pattern); LTTNG_ASSERT(b->pattern); - if (strcmp(a->pattern, b->pattern)) { + if (strcmp(a->pattern, b->pattern) != 0) { goto end; } if (a->filter_expression && b->filter_expression) { - if (strcmp(a->filter_expression, b->filter_expression)) { + if (strcmp(a->filter_expression, b->filter_expression) != 0) { goto end; } } else if (!!a->filter_expression != !!b->filter_expression) { diff --git a/src/common/event-rule/python-logging.cpp b/src/common/event-rule/python-logging.cpp index 2f2187267..eb23b337b 100644 --- a/src/common/event-rule/python-logging.cpp +++ b/src/common/event-rule/python-logging.cpp @@ -145,12 +145,12 @@ static bool lttng_event_rule_python_logging_is_equal(const struct lttng_event_ru /* Long check. */ LTTNG_ASSERT(a->pattern); LTTNG_ASSERT(b->pattern); - if (strcmp(a->pattern, b->pattern)) { + if (strcmp(a->pattern, b->pattern) != 0) { goto end; } if (a->filter_expression && b->filter_expression) { - if (strcmp(a->filter_expression, b->filter_expression)) { + if (strcmp(a->filter_expression, b->filter_expression) != 0) { goto end; } } else if (!!a->filter_expression != !!b->filter_expression) { diff --git a/src/common/event-rule/user-tracepoint.cpp b/src/common/event-rule/user-tracepoint.cpp index 20993e12b..55b1c2505 100644 --- a/src/common/event-rule/user-tracepoint.cpp +++ b/src/common/event-rule/user-tracepoint.cpp @@ -208,12 +208,12 @@ static bool lttng_event_rule_user_tracepoint_is_equal(const struct lttng_event_r /* Long check. */ LTTNG_ASSERT(a->pattern); LTTNG_ASSERT(b->pattern); - if (strcmp(a->pattern, b->pattern)) { + if (strcmp(a->pattern, b->pattern) != 0) { goto end; } if (a->filter_expression && b->filter_expression) { - if (strcmp(a->filter_expression, b->filter_expression)) { + if (strcmp(a->filter_expression, b->filter_expression) != 0) { goto end; } } else if (!!a->filter_expression != !!b->filter_expression) { @@ -234,7 +234,7 @@ static bool lttng_event_rule_user_tracepoint_is_equal(const struct lttng_event_r status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_at_index( _b, i, &exclusion_b); LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK); - if (strcmp(exclusion_a, exclusion_b)) { + if (strcmp(exclusion_a, exclusion_b) != 0) { goto end; } } diff --git a/src/common/event.cpp b/src/common/event.cpp index b00cda83b..c0d128f53 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -368,7 +368,7 @@ ssize_t lttng_event_create_from_payload(struct lttng_payload_view *view, local_event->type = (enum lttng_event_type) event_comm->event_type; local_event->loglevel_type = (enum lttng_loglevel_type) event_comm->loglevel_type; local_event->loglevel = event_comm->loglevel; - local_event->enabled = event_comm->enabled; + local_event->enabled = !!event_comm->enabled; local_event->pid = event_comm->pid; local_event->flags = (enum lttng_event_flag) event_comm->flags; diff --git a/src/common/fd-tracker/fd-tracker.cpp b/src/common/fd-tracker/fd-tracker.cpp index e610118e9..e7ea6e9ef 100644 --- a/src/common/fd-tracker/fd-tracker.cpp +++ b/src/common/fd-tracker/fd-tracker.cpp @@ -27,22 +27,22 @@ #include /* Tracker lock must be taken by the user. */ -#define TRACKED_COUNT(tracker) \ - (tracker->count.suspendable.active + tracker->count.suspendable.suspended + \ - tracker->count.unsuspendable) +#define TRACKED_COUNT(tracker) \ + ((tracker)->count.suspendable.active + (tracker)->count.suspendable.suspended + \ + (tracker)->count.unsuspendable) /* Tracker lock must be taken by the user. */ -#define ACTIVE_COUNT(tracker) (tracker->count.suspendable.active + tracker->count.unsuspendable) +#define ACTIVE_COUNT(tracker) ((tracker)->count.suspendable.active + (tracker)->count.unsuspendable) /* Tracker lock must be taken by the user. */ -#define SUSPENDED_COUNT(tracker) (tracker->count.suspendable.suspended) +#define SUSPENDED_COUNT(tracker) ((tracker)->count.suspendable.suspended) /* Tracker lock must be taken by the user. */ #define SUSPENDABLE_COUNT(tracker) \ - (tracker->count.suspendable.active + tracker->count.suspendable.suspended) + ((tracker)->count.suspendable.active + (tracker)->count.suspendable.suspended) /* Tracker lock must be taken by the user. */ -#define UNSUSPENDABLE_COUNT(tracker) (tracker->count.unsuspendable) +#define UNSUSPENDABLE_COUNT(tracker) ((tracker)->count.unsuspendable) struct fd_tracker { pthread_mutex_t lock; diff --git a/src/common/hashtable/utils.cpp b/src/common/hashtable/utils.cpp index 305660c80..5b9344b15 100644 --- a/src/common/hashtable/utils.cpp +++ b/src/common/hashtable/utils.cpp @@ -117,26 +117,26 @@ * on, and rotates are much kinder to the top and bottom bits, so I used * rotates. */ -#define mix(a, b, c) \ - { \ - a -= c; \ - a ^= rot(c, 4); \ - c += b; \ - b -= a; \ - b ^= rot(a, 6); \ - a += c; \ - c -= b; \ - c ^= rot(b, 8); \ - b += a; \ - a -= c; \ - a ^= rot(c, 16); \ - c += b; \ - b -= a; \ - b ^= rot(a, 19); \ - a += c; \ - c -= b; \ - c ^= rot(b, 4); \ - b += a; \ +#define mix(a, b, c) \ + { \ + (a) -= (c); \ + (a) ^= rot(c, 4); \ + (c) += (b); \ + (b) -= (a); \ + (b) ^= rot(a, 6); \ + (a) += (c); \ + (c) -= (b); \ + (c) ^= rot(b, 8); \ + (b) += (a); \ + (a) -= (c); \ + (a) ^= rot(c, 16); \ + (c) += (b); \ + (b) -= (a); \ + (b) ^= rot(a, 19); \ + (a) += (c); \ + (c) -= (b); \ + (c) ^= rot(b, 4); \ + (b) += (a); \ } /* @@ -162,22 +162,22 @@ * 10 8 15 26 3 22 24 * 11 8 15 26 3 22 24 */ -#define final(a, b, c) \ - { \ - c ^= b; \ - c -= rot(b, 14); \ - a ^= c; \ - a -= rot(c, 11); \ - b ^= a; \ - b -= rot(a, 25); \ - c ^= b; \ - c -= rot(b, 16); \ - a ^= c; \ - a -= rot(c, 4); \ - b ^= a; \ - b -= rot(a, 14); \ - c ^= b; \ - c -= rot(b, 24); \ +#define final(a, b, c) \ + { \ + (c) ^= (b); \ + (c) -= rot(b, 14); \ + (a) ^= (c); \ + (a) -= rot(c, 11); \ + (b) ^= (a); \ + (b) -= rot(a, 25); \ + (c) ^= (b); \ + (c) -= rot(b, 16); \ + (a) ^= (c); \ + (a) -= rot(c, 4); \ + (b) ^= (a); \ + (b) -= rot(a, 14); \ + (c) ^= (b); \ + (c) -= rot(b, 24); \ } /* diff --git a/src/common/ini-config/ini-config.cpp b/src/common/ini-config/ini-config.cpp index 11f4e5193..ebfe153c2 100644 --- a/src/common/ini-config/ini-config.cpp +++ b/src/common/ini-config/ini-config.cpp @@ -46,7 +46,7 @@ static int config_entry_handler_filter(struct handler_filter_args *args, } if (args->section) { - if (strcmp(args->section, section)) { + if (strcmp(args->section, section) != 0) { goto end; } } diff --git a/src/common/kernel-consumer/kernel-consumer.cpp b/src/common/kernel-consumer/kernel-consumer.cpp index 3b42438d8..f520736b4 100644 --- a/src/common/kernel-consumer/kernel-consumer.cpp +++ b/src/common/kernel-consumer/kernel-consumer.cpp @@ -783,7 +783,12 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, health_code_update(); - ret_pipe_write = lttng_pipe_write(stream_pipe, &new_stream, sizeof(new_stream)); + ret_pipe_write = + lttng_pipe_write(stream_pipe, &new_stream, sizeof(new_stream)); /* NOLINT + sizeof + used on a + pointer. + */ if (ret_pipe_write < 0) { ERR("Consumer write %s stream to pipe %d", new_stream->metadata_flag ? "metadata" : "data", diff --git a/src/common/kernel-probe.cpp b/src/common/kernel-probe.cpp index daf0dc005..d1b6744d9 100644 --- a/src/common/kernel-probe.cpp +++ b/src/common/kernel-probe.cpp @@ -540,7 +540,7 @@ lttng_kernel_probe_location_symbol_is_equal(const struct lttng_kernel_probe_loca LTTNG_ASSERT(a->symbol_name); LTTNG_ASSERT(b->symbol_name); - if (strcmp(a->symbol_name, b->symbol_name)) { + if (strcmp(a->symbol_name, b->symbol_name) != 0) { goto end; } diff --git a/src/common/lttng-elf.cpp b/src/common/lttng-elf.cpp index 108686042..be1db0250 100644 --- a/src/common/lttng-elf.cpp +++ b/src/common/lttng-elf.cpp @@ -33,7 +33,7 @@ #define NOTE_STAPSDT_SECTION_NAME ".note.stapsdt" #define NOTE_STAPSDT_NAME "stapsdt" #define NOTE_STAPSDT_TYPE 3 -#define MAX_SECTION_DATA_SIZE 512 * 1024 * 1024 +#define MAX_SECTION_DATA_SIZE (512 * 1024 * 1024) #if BYTE_ORDER == LITTLE_ENDIAN #define NATIVE_ELF_ENDIANNESS ELFDATA2LSB @@ -41,25 +41,25 @@ #define NATIVE_ELF_ENDIANNESS ELFDATA2MSB #endif -#define next_4bytes_boundary(x) (typeof(x)) ((((uint64_t) x) + 3) & ~0x03) - -#define bswap(x) \ - do { \ - switch (sizeof(x)) { \ - case 8: \ - x = be64toh((uint64_t) x); \ - break; \ - case 4: \ - x = be32toh((uint32_t) x); \ - break; \ - case 2: \ - x = be16toh((uint16_t) x); \ - break; \ - case 1: \ - break; \ - default: \ - abort(); \ - } \ +#define next_4bytes_boundary(x) (typeof(x)) ((((uint64_t) (x)) + 3) & ~0x03) + +#define bswap(x) \ + do { \ + switch (sizeof(x)) { \ + case 8: \ + (x) = be64toh((uint64_t) (x)); \ + break; \ + case 4: \ + (x) = be32toh((uint32_t) (x)); \ + break; \ + case 2: \ + (x) = be16toh((uint16_t) (x)); \ + break; \ + case 1: \ + break; \ + default: \ + abort(); \ + } \ } while (0) #define bswap_shdr(shdr) \ @@ -124,14 +124,14 @@ (dst_ehdr).e_shstrndx = (src_ehdr).e_shstrndx; \ } while (0) -#define copy_sym(src_sym, dst_sym) \ - do { \ - dst_sym.st_name = src_sym.st_name; \ - dst_sym.st_info = src_sym.st_info; \ - dst_sym.st_other = src_sym.st_other; \ - dst_sym.st_shndx = src_sym.st_shndx; \ - dst_sym.st_value = src_sym.st_value; \ - dst_sym.st_size = src_sym.st_size; \ +#define copy_sym(src_sym, dst_sym) \ + do { \ + (dst_sym).st_name = (src_sym).st_name; \ + (dst_sym).st_info = (src_sym).st_info; \ + (dst_sym).st_other = (src_sym).st_other; \ + (dst_sym).st_shndx = (src_sym).st_shndx; \ + (dst_sym).st_value = (src_sym).st_value; \ + (dst_sym).st_size = (src_sym).st_size; \ } while (0) #ifndef ELFCLASSNUM diff --git a/src/common/lttng-kernel-old.hpp b/src/common/lttng-kernel-old.hpp index 2ffb75483..4e13cb4a7 100644 --- a/src/common/lttng-kernel-old.hpp +++ b/src/common/lttng-kernel-old.hpp @@ -27,7 +27,7 @@ struct lttng_kernel_abi_old_perf_counter_ctx { /* Event/Channel context */ #define LTTNG_KERNEL_ABI_OLD_CONTEXT_PADDING1 16 -#define LTTNG_KERNEL_ABI_OLD_CONTEXT_PADDING2 LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32 +#define LTTNG_KERNEL_ABI_OLD_CONTEXT_PADDING2 ((LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32)) struct lttng_kernel_abi_old_context { enum lttng_kernel_abi_context_type ctx; char padding[LTTNG_KERNEL_ABI_OLD_CONTEXT_PADDING1]; @@ -61,7 +61,7 @@ struct lttng_kernel_abi_old_function { }; #define LTTNG_KERNEL_ABI_OLD_EVENT_PADDING1 16 -#define LTTNG_KERNEL_ABI_OLD_EVENT_PADDING2 LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32 +#define LTTNG_KERNEL_ABI_OLD_EVENT_PADDING2 ((LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32)) struct lttng_kernel_abi_old_event { char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN]; enum lttng_kernel_abi_instrumentation instrumentation; @@ -85,7 +85,7 @@ struct lttng_kernel_abi_old_tracer_version { /* * kernel channel */ -#define LTTNG_KERNEL_ABI_OLD_CHANNEL_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32 +#define LTTNG_KERNEL_ABI_OLD_CHANNEL_PADDING1 ((LTTNG_SYMBOL_NAME_LEN + 32)) struct lttng_kernel_abi_old_channel { int overwrite; /* 1: overwrite, 0: discard */ uint64_t subbuf_size; /* bytes */ diff --git a/src/common/lttng-kernel.hpp b/src/common/lttng-kernel.hpp index 6b1f7985d..1363ba584 100644 --- a/src/common/lttng-kernel.hpp +++ b/src/common/lttng-kernel.hpp @@ -86,7 +86,7 @@ struct lttng_kernel_abi_perf_counter_ctx { /* Event/Channel context */ #define LTTNG_KERNEL_ABI_CONTEXT_PADDING1 16 -#define LTTNG_KERNEL_ABI_CONTEXT_PADDING2 LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32 +#define LTTNG_KERNEL_ABI_CONTEXT_PADDING2 ((LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32)) struct lttng_kernel_abi_context { enum lttng_kernel_abi_context_type ctx; char padding[LTTNG_KERNEL_ABI_CONTEXT_PADDING1]; @@ -159,7 +159,7 @@ struct lttng_kernel_abi_function { } LTTNG_PACKED; #define LTTNG_KERNEL_ABI_EVENT_PADDING1 8 -#define LTTNG_KERNEL_ABI_EVENT_PADDING2 LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32 +#define LTTNG_KERNEL_ABI_EVENT_PADDING2 ((LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32)) struct lttng_kernel_abi_event { char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN]; enum lttng_kernel_abi_instrumentation instrumentation; @@ -281,7 +281,7 @@ struct lttng_kernel_abi_syscall_mask { /* * kernel channel */ -#define LTTNG_KERNEL_ABI_CHANNEL_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32 +#define LTTNG_KERNEL_ABI_CHANNEL_PADDING1 ((LTTNG_SYMBOL_NAME_LEN + 32)) struct lttng_kernel_abi_channel { uint64_t subbuf_size; /* bytes */ uint64_t num_subbuf; /* power of 2 */ diff --git a/src/common/macros.hpp b/src/common/macros.hpp index cfe6eb528..031d2a056 100644 --- a/src/common/macros.hpp +++ b/src/common/macros.hpp @@ -39,7 +39,7 @@ * memory using malloc(), we must use generic accessors for compat in order to * *not* use a function to access members and not the variable name. */ -#define LTTNG_REF(x) ((typeof(*x) *)(x)) +#define LTTNG_REF(x) ((typeof(*(x)) *) (x)) #ifdef NDEBUG /* @@ -88,7 +88,7 @@ template T *zmalloc() { static_assert (can_malloc::value, "type can be malloc'ed"); - return (T *) zmalloc_internal(sizeof(T)); + return (T *) zmalloc_internal(sizeof(T)); /* NOLINT sizeof potentially used on a pointer. */ } /* @@ -111,7 +111,7 @@ template T *calloc(size_t nmemb) { static_assert (can_malloc::value, "type can be malloc'ed"); - return (T *) zmalloc_internal(nmemb * sizeof(T)); + return (T *) zmalloc_internal(nmemb * sizeof(T)); /* NOLINT sizeof potentially used on a pointer. */ } /* @@ -243,7 +243,7 @@ void *memmove(T *d, const U *s, size_t n) = delete; #define member_sizeof(type, field) sizeof(((type *) 0)->field) -#define ASSERT_LOCKED(lock) LTTNG_ASSERT(pthread_mutex_trylock(&lock)) +#define ASSERT_LOCKED(lock) LTTNG_ASSERT(pthread_mutex_trylock(&(lock))) #define ASSERT_RCU_READ_LOCKED(lock) LTTNG_ASSERT(rcu_read_ongoing()) /* Attribute suitable to tag functions as having printf()-like arguments. */ diff --git a/src/common/optional.hpp b/src/common/optional.hpp index f34c5991f..4bb774739 100644 --- a/src/common/optional.hpp +++ b/src/common/optional.hpp @@ -88,7 +88,10 @@ /* * Initialize an optional field as 'set' with a given value. */ -#define LTTNG_OPTIONAL_INIT_VALUE(val) { .is_set = 1, .value = val } +#define LTTNG_OPTIONAL_INIT_VALUE(val) \ + { \ + .is_set = 1, .value = (val) \ + } /* Set the value of an optional field. */ #define LTTNG_OPTIONAL_SET(field_ptr, val) \ diff --git a/src/common/runas.cpp b/src/common/runas.cpp index d253ee054..7651470c8 100644 --- a/src/common/runas.cpp +++ b/src/common/runas.cpp @@ -177,30 +177,31 @@ struct run_as_ret { bool _error; } LTTNG_PACKED; -#define COMMAND_IN_FDS(data_ptr) \ - ({ \ - int *fds = NULL; \ - if (command_properties[data_ptr->cmd].in_fds_offset != -1) { \ - fds = (int *) ((char *) data_ptr + \ - command_properties[data_ptr->cmd].in_fds_offset); \ - } \ - fds; \ +#define COMMAND_IN_FDS(data_ptr) \ + ({ \ + int *fds = NULL; \ + if (command_properties[(data_ptr)->cmd].in_fds_offset != -1) { \ + fds = (int *) ((char *) (data_ptr) + \ + command_properties[(data_ptr)->cmd].in_fds_offset); \ + } \ + fds; \ }) -#define COMMAND_OUT_FDS(cmd, ret_ptr) \ - ({ \ - int *fds = NULL; \ - if (command_properties[cmd].out_fds_offset != -1) { \ - fds = (int *) ((char *) ret_ptr + command_properties[cmd].out_fds_offset); \ - } \ - fds; \ +#define COMMAND_OUT_FDS(cmd, ret_ptr) \ + ({ \ + int *fds = NULL; \ + if (command_properties[cmd].out_fds_offset != -1) { \ + fds = (int *) ((char *) (ret_ptr) + \ + command_properties[cmd].out_fds_offset); \ + } \ + fds; \ }) -#define COMMAND_IN_FD_COUNT(data_ptr) ({ command_properties[data_ptr->cmd].in_fd_count; }) +#define COMMAND_IN_FD_COUNT(data_ptr) ({ command_properties[(data_ptr)->cmd].in_fd_count; }) #define COMMAND_OUT_FD_COUNT(cmd) ({ command_properties[cmd].out_fd_count; }) -#define COMMAND_USE_CWD_FD(data_ptr) command_properties[data_ptr->cmd].use_cwd_fd +#define COMMAND_USE_CWD_FD(data_ptr) command_properties[(data_ptr)->cmd].use_cwd_fd struct run_as_command_properties { /* Set to -1 when not applicable. */ diff --git a/src/common/trace-chunk.cpp b/src/common/trace-chunk.cpp index 2be4224f9..d48ebc6be 100644 --- a/src/common/trace-chunk.cpp +++ b/src/common/trace-chunk.cpp @@ -1545,7 +1545,7 @@ static int lttng_trace_chunk_move_to_completed_post_release(struct lttng_trace_c * the creation of the next chunk. This happens if a rotation is * performed while tracing is stopped. */ - if (!trace_chunk->path || strcmp(trace_chunk->path, DEFAULT_CHUNK_TMP_OLD_DIRECTORY)) { + if (!trace_chunk->path || strcmp(trace_chunk->path, DEFAULT_CHUNK_TMP_OLD_DIRECTORY) != 0) { status = lttng_trace_chunk_rename_path_no_lock(trace_chunk, DEFAULT_CHUNK_TMP_OLD_DIRECTORY); if (status != LTTNG_TRACE_CHUNK_STATUS_OK) { diff --git a/src/common/tracker.cpp b/src/common/tracker.cpp index 1f292a3f0..dba84293d 100644 --- a/src/common/tracker.cpp +++ b/src/common/tracker.cpp @@ -39,11 +39,11 @@ struct process_attr_tracker_value_comm { ((as_type) (std::is_signed::value ? (value_ptr)->u._signed : \ (value_ptr)->u._unsigned)) -#define SET_INTEGRAL_COMM_VALUE(comm_value, val) \ - if (std::is_signed::value) { \ - (comm_value)->u._signed = (typeof((comm_value)->u._signed)) val; \ - } else { \ - (comm_value)->u._unsigned = (typeof((comm_value)->u._unsigned)) val; \ +#define SET_INTEGRAL_COMM_VALUE(comm_value, val) \ + if (std::is_signed::value) { \ + (comm_value)->u._signed = (typeof((comm_value)->u._signed)) (val); \ + } else { \ + (comm_value)->u._unsigned = (typeof((comm_value)->u._unsigned)) (val); \ } static inline bool is_virtual_process_attr(enum lttng_process_attr process_attr) diff --git a/src/common/urcu.hpp b/src/common/urcu.hpp index d121ecd9f..abbf71679 100644 --- a/src/common/urcu.hpp +++ b/src/common/urcu.hpp @@ -57,15 +57,13 @@ public: */ class read_lock_guard { public: - read_lock_guard() : _guard(_lock) - { - } + read_lock_guard() = default; read_lock_guard(const read_lock_guard &) = delete; private: details::read_lock _lock; - std::lock_guard _guard; + std::lock_guard _guard{_lock}; }; using unique_read_lock = std::unique_lock; diff --git a/src/common/userspace-probe.cpp b/src/common/userspace-probe.cpp index 8be0e0724..4a9c31812 100644 --- a/src/common/userspace-probe.cpp +++ b/src/common/userspace-probe.cpp @@ -236,13 +236,13 @@ lttng_userspace_probe_location_function_is_equal(const struct lttng_userspace_pr LTTNG_ASSERT(a->function_name); LTTNG_ASSERT(b->function_name); - if (strcmp(a->function_name, b->function_name)) { + if (strcmp(a->function_name, b->function_name) != 0) { goto end; } LTTNG_ASSERT(a->binary_path); LTTNG_ASSERT(b->binary_path); - if (strcmp(a->binary_path, b->binary_path)) { + if (strcmp(a->binary_path, b->binary_path) != 0) { goto end; } @@ -356,19 +356,19 @@ lttng_userspace_probe_location_tracepoint_is_equal(const struct lttng_userspace_ LTTNG_ASSERT(a->probe_name); LTTNG_ASSERT(b->probe_name); - if (strcmp(a->probe_name, b->probe_name)) { + if (strcmp(a->probe_name, b->probe_name) != 0) { goto end; } LTTNG_ASSERT(a->provider_name); LTTNG_ASSERT(b->provider_name); - if (strcmp(a->provider_name, b->provider_name)) { + if (strcmp(a->provider_name, b->provider_name) != 0) { goto end; } LTTNG_ASSERT(a->binary_path); LTTNG_ASSERT(b->binary_path); - if (strcmp(a->binary_path, b->binary_path)) { + if (strcmp(a->binary_path, b->binary_path) != 0) { goto end; } diff --git a/src/common/ust-consumer/ust-consumer.cpp b/src/common/ust-consumer/ust-consumer.cpp index 5339553cb..d0b39a887 100644 --- a/src/common/ust-consumer/ust-consumer.cpp +++ b/src/common/ust-consumer/ust-consumer.cpp @@ -167,7 +167,8 @@ static int send_stream_to_thread(struct lttng_consumer_stream *stream, stream->globally_visible = 1; cds_list_del_init(&stream->send_node); - ret = lttng_pipe_write(stream_pipe, &stream, sizeof(stream)); + ret = lttng_pipe_write(stream_pipe, &stream, sizeof(stream)); /* NOLINT sizeof used on a + pointer. */ if (ret < 0) { ERR("Consumer write %s stream to pipe %d", stream->metadata_flag ? "metadata" : "data", diff --git a/src/lib/lttng-ctl/lttng-ctl.cpp b/src/lib/lttng-ctl/lttng-ctl.cpp index b9311a07e..15a699e24 100644 --- a/src/lib/lttng-ctl/lttng-ctl.cpp +++ b/src/lib/lttng-ctl/lttng-ctl.cpp @@ -52,12 +52,12 @@ #include #include -#define COPY_DOMAIN_PACKED(dst, src) \ - do { \ - struct lttng_domain _tmp_domain; \ - \ - lttng_ctl_copy_lttng_domain(&_tmp_domain, &src); \ - dst = _tmp_domain; \ +#define COPY_DOMAIN_PACKED(dst, src) \ + do { \ + struct lttng_domain _tmp_domain; \ + \ + lttng_ctl_copy_lttng_domain(&_tmp_domain, &(src)); \ + (dst) = _tmp_domain; \ } while (0) /* Socket to session daemon for communication */ diff --git a/src/lib/lttng-ctl/tracker.cpp b/src/lib/lttng-ctl/tracker.cpp index 6b7469fdf..a31b5a189 100644 --- a/src/lib/lttng-ctl/tracker.cpp +++ b/src/lib/lttng-ctl/tracker.cpp @@ -465,35 +465,36 @@ end: return type; } -#define DEFINE_LTTNG_PROCESS_ATTR_VALUES_GETTER(value_type_name, value_type, expected_value_type) \ - enum lttng_process_attr_values_status \ - lttng_process_attr_values_get_##value_type_name##_at_index( \ - const struct lttng_process_attr_values *values, \ - unsigned int index, \ - value_type *out_value) \ - { \ - enum lttng_process_attr_values_status status = \ - LTTNG_PROCESS_ATTR_VALUES_STATUS_OK; \ - const struct process_attr_value *value; \ - \ - if (!values) { \ - status = LTTNG_PROCESS_ATTR_VALUES_STATUS_INVALID; \ - goto end; \ - } \ - \ - if (_lttng_process_attr_values_get_count(values) <= index) { \ - status = LTTNG_PROCESS_ATTR_VALUES_STATUS_INVALID; \ - goto end; \ - } \ - \ - value = lttng_process_attr_tracker_values_get_at_index(values, index); \ - if (value->type != LTTNG_PROCESS_ATTR_VALUE_TYPE_##expected_value_type) { \ - status = LTTNG_PROCESS_ATTR_VALUES_STATUS_INVALID_TYPE; \ - goto end; \ - } \ - *out_value = value->value.value_type_name; \ - end: \ - return status; \ +#define DEFINE_LTTNG_PROCESS_ATTR_VALUES_GETTER(value_type_name, value_type, expected_value_type) \ + enum lttng_process_attr_values_status \ + lttng_process_attr_values_get_##value_type_name##_at_index( \ + const struct lttng_process_attr_values *values, \ + unsigned int index, \ + value_type *out_value) /* NOLINT clang-tidy sees value_type as a value and \ + adds parentheses */ \ + { \ + enum lttng_process_attr_values_status status = \ + LTTNG_PROCESS_ATTR_VALUES_STATUS_OK; \ + const struct process_attr_value *value; \ + \ + if (!values) { \ + status = LTTNG_PROCESS_ATTR_VALUES_STATUS_INVALID; \ + goto end; \ + } \ + \ + if (_lttng_process_attr_values_get_count(values) <= index) { \ + status = LTTNG_PROCESS_ATTR_VALUES_STATUS_INVALID; \ + goto end; \ + } \ + \ + value = lttng_process_attr_tracker_values_get_at_index(values, index); \ + if (value->type != LTTNG_PROCESS_ATTR_VALUE_TYPE_##expected_value_type) { \ + status = LTTNG_PROCESS_ATTR_VALUES_STATUS_INVALID_TYPE; \ + goto end; \ + } \ + *out_value = value->value.value_type_name; \ + end: \ + return status; \ } DEFINE_LTTNG_PROCESS_ATTR_VALUES_GETTER(pid, pid_t, PID); diff --git a/src/vendor/.clang-tidy b/src/vendor/.clang-tidy new file mode 100644 index 000000000..91aebac05 --- /dev/null +++ b/src/vendor/.clang-tidy @@ -0,0 +1 @@ +Checks: '-*,llvm-twine-local' diff --git a/tests/regression/tools/trigger/utils/notification-client.c b/tests/regression/tools/trigger/utils/notification-client.c index 3d8aec46d..11e920696 100644 --- a/tests/regression/tools/trigger/utils/notification-client.c +++ b/tests/regression/tools/trigger/utils/notification-client.c @@ -173,11 +173,11 @@ int main(int argc, char **argv) const char *trigger_name = NULL; lttng_trigger_get_name(trigger, &trigger_name); - if (strcmp(trigger_name, expected_trigger_name)) { + if (strcmp(trigger_name, expected_trigger_name) != 0) { /* Might match the end event trigger */ if (end_trigger_name != NULL && strcmp(trigger_name, - end_trigger_name)) { + end_trigger_name) != 0) { continue; } } diff --git a/tests/unit/test_fd_tracker.cpp b/tests/unit/test_fd_tracker.cpp index 9e40c83c2..cdc622a04 100644 --- a/tests/unit/test_fd_tracker.cpp +++ b/tests/unit/test_fd_tracker.cpp @@ -704,7 +704,7 @@ skip_write: break; } - if (strcmp(file_contents, read_buf)) { + if (strcmp(file_contents, read_buf) != 0) { content_ok = false; diag("File content doesn't match the expectated string"); (void) close(fd); diff --git a/tests/unit/test_unix_socket.cpp b/tests/unit/test_unix_socket.cpp index 361dbe36a..ea02c2ec2 100644 --- a/tests/unit/test_unix_socket.cpp +++ b/tests/unit/test_unix_socket.cpp @@ -27,7 +27,7 @@ #define HIGH_FD_COUNT LTTCOMM_MAX_SEND_FDS #define MESSAGE_COUNT 4 -#define LARGE_PAYLOAD_SIZE 4 * 1024 +#define LARGE_PAYLOAD_SIZE (4 * 1024) #define LARGE_PAYLOAD_RECV_SIZE 100 static const int TEST_COUNT = 37; -- 2.34.1