From ff01a57416330247403e58bf4e28d4771a46ce35 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Sat, 28 Jan 2023 13:10:39 -0500 Subject: [PATCH] Clean-up: replace uses of `int found` as bool by `bool found` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau Change-Id: I95c4cefdc0836203d3bf8e6b9c273cf5f1cbf3fc --- src/bin/lttng-sessiond/trace-kernel.cpp | 12 ++++++++---- src/bin/lttng/commands/clear.cpp | 6 +++--- src/bin/lttng/commands/destroy.cpp | 6 +++--- src/bin/lttng/commands/help.cpp | 4 ++-- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/bin/lttng-sessiond/trace-kernel.cpp b/src/bin/lttng-sessiond/trace-kernel.cpp index e1d591761..e695f1295 100644 --- a/src/bin/lttng-sessiond/trace-kernel.cpp +++ b/src/bin/lttng-sessiond/trace-kernel.cpp @@ -76,7 +76,7 @@ struct ltt_kernel_event *trace_kernel_find_event(char *name, struct lttng_bytecode *filter) { struct ltt_kernel_event *ev; - int found = 0; + bool found = false; LTTNG_ASSERT(name); LTTNG_ASSERT(channel); @@ -97,9 +97,11 @@ struct ltt_kernel_event *trace_kernel_find_event(char *name, continue; } } - found = 1; + + found = true; break; } + if (found) { DBG("Found event %s for channel %s", name, channel->channel->name); return ev; @@ -116,7 +118,7 @@ struct ltt_kernel_event *trace_kernel_get_event_by_name(char *name, enum lttng_event_type type) { struct ltt_kernel_event *ev; - int found = 0; + bool found = false; LTTNG_ASSERT(name); LTTNG_ASSERT(channel); @@ -128,9 +130,11 @@ struct ltt_kernel_event *trace_kernel_get_event_by_name(char *name, if (strcmp(name, ev->event->name) != 0) { continue; } - found = 1; + + found = true; break; } + if (found) { DBG("Found event %s for channel %s", name, channel->channel->name); return ev; diff --git a/src/bin/lttng/commands/clear.cpp b/src/bin/lttng/commands/clear.cpp index f26e6e5b9..1637cf240 100644 --- a/src/bin/lttng/commands/clear.cpp +++ b/src/bin/lttng/commands/clear.cpp @@ -156,7 +156,7 @@ int cmd_clear(int argc, const char **argv) const char *leftover = nullptr; struct lttng_session *sessions = nullptr; int count; - int found; + bool found; pc = poptGetContext(nullptr, argc, argv, long_options, 0); poptReadDefaultConfig(pc, 0); @@ -251,10 +251,10 @@ int cmd_clear(int argc, const char **argv) } } else { /* Find the corresponding lttng_session struct */ - found = 0; + found = false; for (i = 0; i < count; i++) { if (strncmp(sessions[i].name, session_name, NAME_MAX) == 0) { - found = 1; + found = true; command_ret = clear_session(&sessions[i]); if (command_ret) { ERR("%s", lttng_strerror(command_ret)); diff --git a/src/bin/lttng/commands/destroy.cpp b/src/bin/lttng/commands/destroy.cpp index 270cefffc..83e23ab75 100644 --- a/src/bin/lttng/commands/destroy.cpp +++ b/src/bin/lttng/commands/destroy.cpp @@ -269,7 +269,7 @@ int cmd_destroy(int argc, const char **argv) struct lttng_session *sessions = nullptr; int count; - int found; + bool found; pc = poptGetContext(nullptr, argc, argv, long_options, 0); poptReadDefaultConfig(pc, 0); @@ -354,10 +354,10 @@ int cmd_destroy(int argc, const char **argv) } /* Find the corresponding lttng_session struct */ - found = 0; + found = false; for (i = 0; i < count; i++) { if (strncmp(sessions[i].name, session_name, NAME_MAX) == 0) { - found = 1; + found = true; command_ret = destroy_session(&sessions[i]); if (command_ret) { success = 0; diff --git a/src/bin/lttng/commands/help.cpp b/src/bin/lttng/commands/help.cpp index 00af516de..57b73a6b0 100644 --- a/src/bin/lttng/commands/help.cpp +++ b/src/bin/lttng/commands/help.cpp @@ -50,7 +50,7 @@ int cmd_help(int argc, const char **argv, const struct cmd_struct commands[]) const char *arg_cmd_name; static poptContext pc; const struct cmd_struct *cmd; - int found = 0; + bool found = false; const char *cmd_argv[2]; pc = poptGetContext(nullptr, argc, argv, long_options, 0); @@ -95,7 +95,7 @@ int cmd_help(int argc, const char **argv, const struct cmd_struct commands[]) while (cmd->name != nullptr) { if (strcmp(cmd->name, arg_cmd_name) == 0) { - found = 1; + found = true; break; } -- 2.34.1