From 1004b7191b421c7c07acf964d0110d93bb022699 Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Tue, 25 May 2021 15:57:59 -0400 Subject: [PATCH] Cleanup: rename `get_domain_str()` -> `lttng_domain_type_str()` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Both functions currently exist in the code base and accomplish the same goal. Let's keep only one of them. Signed-off-by: Francis Deslauriers Signed-off-by: Jérémie Galarneau Change-Id: I2254b846f0b5bdc883c86d970fde7daffa9e6155 --- src/bin/lttng/commands/add_context.c | 7 +++-- src/bin/lttng/commands/add_trigger.c | 1 + src/bin/lttng/commands/disable_channels.c | 4 ++- src/bin/lttng/commands/disable_events.c | 5 ++-- src/bin/lttng/commands/enable_channels.c | 5 +++- src/bin/lttng/commands/enable_events.c | 17 ++++++------ src/bin/lttng/commands/list.c | 3 ++- src/bin/lttng/utils.c | 33 ----------------------- src/bin/lttng/utils.h | 1 - src/common/mi-lttng.c | 1 - 10 files changed, 27 insertions(+), 50 deletions(-) diff --git a/src/bin/lttng/commands/add_context.c b/src/bin/lttng/commands/add_context.c index b33eb1d14..de066e6dc 100644 --- a/src/bin/lttng/commands/add_context.c +++ b/src/bin/lttng/commands/add_context.c @@ -19,6 +19,7 @@ #include +#include #include #include "../command.h" @@ -810,11 +811,13 @@ static int add_context(char *session_name) } else { if (opt_channel_name) { MSG("%s context %s added to channel %s", - get_domain_str(dom.type), type->opt->symbol, + lttng_domain_type_str(dom.type), + type->opt->symbol, opt_channel_name); } else { MSG("%s context %s added to all channels", - get_domain_str(dom.type), type->opt->symbol); + lttng_domain_type_str(dom.type), + type->opt->symbol); } success = 1; } diff --git a/src/bin/lttng/commands/add_trigger.c b/src/bin/lttng/commands/add_trigger.c index 00f8f47e3..8fb79d378 100644 --- a/src/bin/lttng/commands/add_trigger.c +++ b/src/bin/lttng/commands/add_trigger.c @@ -18,6 +18,7 @@ #include "common/mi-lttng.h" #include "common/string-utils/string-utils.h" #include "common/utils.h" +#include /* For lttng_event_rule_type_str(). */ #include #include diff --git a/src/bin/lttng/commands/disable_channels.c b/src/bin/lttng/commands/disable_channels.c index 344be237d..f75c5feb0 100644 --- a/src/bin/lttng/commands/disable_channels.c +++ b/src/bin/lttng/commands/disable_channels.c @@ -16,6 +16,7 @@ #include #include +#include #include "../command.h" @@ -155,7 +156,8 @@ static int disable_channels(char *session_name) } else { MSG("%s channel %s disabled for session %s", - get_domain_str(dom.type), channel_name, session_name); + lttng_domain_type_str(dom.type), + channel_name, session_name); enabled = 0; success = 1; } diff --git a/src/bin/lttng/commands/disable_events.c b/src/bin/lttng/commands/disable_events.c index a42c3a3cd..0bfd0c506 100644 --- a/src/bin/lttng/commands/disable_events.c +++ b/src/bin/lttng/commands/disable_events.c @@ -16,6 +16,7 @@ #include #include +#include #include "../command.h" @@ -226,7 +227,7 @@ static int disable_events(char *session_name) enabled = 0; success = 1; MSG("All %s events of type %s are disabled in channel %s", - get_domain_str(dom.type), + lttng_domain_type_str(dom.type), print_event_type(opt_event_type), print_channel_name(channel_name)); } @@ -265,7 +266,7 @@ static int disable_events(char *session_name) enabled = 1; } else { MSG("%s %s of type %s disabled in channel %s for session %s", - get_domain_str(dom.type), + lttng_domain_type_str(dom.type), event_name, print_event_type(opt_event_type), print_channel_name(channel_name), diff --git a/src/bin/lttng/commands/enable_channels.c b/src/bin/lttng/commands/enable_channels.c index fa65b1eaa..dd79926f8 100644 --- a/src/bin/lttng/commands/enable_channels.c +++ b/src/bin/lttng/commands/enable_channels.c @@ -21,6 +21,8 @@ #include #include +#include + #include "../command.h" #include "../utils.h" @@ -304,7 +306,8 @@ static int enable_channel(char *session_name) } } else { MSG("%s channel %s enabled for session %s", - get_domain_str(dom.type), channel_name, session_name); + lttng_domain_type_str(dom.type), + channel_name, session_name); success = 1; } diff --git a/src/bin/lttng/commands/enable_events.c b/src/bin/lttng/commands/enable_events.c index 0704b1475..948663412 100644 --- a/src/bin/lttng/commands/enable_events.c +++ b/src/bin/lttng/commands/enable_events.c @@ -25,6 +25,7 @@ /* Mi dependancy */ #include +#include #include #include "../command.h" @@ -486,7 +487,7 @@ static int enable_events(char *session_name) case LTTNG_DOMAIN_LOG4J: case LTTNG_DOMAIN_PYTHON: ERR("Event name exclusions are not yet implemented for %s events", - get_domain_str(dom.type)); + lttng_domain_type_str(dom.type)); ret = CMD_ERROR; goto error; case LTTNG_DOMAIN_UST: @@ -656,7 +657,7 @@ static int enable_events(char *session_name) goto end; } MSG("All %s tracepoints%s are enabled in channel %s for loglevel %s", - get_domain_str(dom.type), + lttng_domain_type_str(dom.type), exclusion_string, print_channel_name(channel_name), opt_loglevel); @@ -670,7 +671,7 @@ static int enable_events(char *session_name) goto end; } MSG("All %s tracepoints%s are enabled in channel %s", - get_domain_str(dom.type), + lttng_domain_type_str(dom.type), exclusion_string, print_channel_name(channel_name)); free(exclusion_string); @@ -679,7 +680,7 @@ static int enable_events(char *session_name) case LTTNG_EVENT_SYSCALL: if (opt_kernel) { MSG("All %s system calls are enabled in channel %s", - get_domain_str(dom.type), + lttng_domain_type_str(dom.type), print_channel_name(channel_name)); } break; @@ -693,7 +694,7 @@ static int enable_events(char *session_name) goto end; } MSG("All %s events%s are enabled in channel %s for loglevel %s", - get_domain_str(dom.type), + lttng_domain_type_str(dom.type), exclusion_string, print_channel_name(channel_name), opt_loglevel); @@ -707,7 +708,7 @@ static int enable_events(char *session_name) goto end; } MSG("All %s events%s are enabled in channel %s", - get_domain_str(dom.type), + lttng_domain_type_str(dom.type), exclusion_string, print_channel_name(channel_name)); free(exclusion_string); @@ -1059,7 +1060,7 @@ static int enable_events(char *session_name) case LTTNG_DOMAIN_KERNEL: case LTTNG_DOMAIN_UST: MSG("%s event %s%s created in channel %s", - get_domain_str(dom.type), + lttng_domain_type_str(dom.type), event_name, exclusion_string, print_channel_name(channel_name)); @@ -1072,7 +1073,7 @@ static int enable_events(char *session_name) * name for agent domains. */ MSG("%s event %s%s enabled", - get_domain_str(dom.type), + lttng_domain_type_str(dom.type), event_name, exclusion_string); break; diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index 4f4fcb5ef..34a9c8aa0 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "../command.h" @@ -576,7 +577,7 @@ static int list_agent_events(void) goto error; } - agent_domain_str = get_domain_str(domain.type); + agent_domain_str = lttng_domain_type_str(domain.type); DBG("Getting %s tracing events", agent_domain_str); diff --git a/src/bin/lttng/utils.c b/src/bin/lttng/utils.c index b363cfed0..e83694399 100644 --- a/src/bin/lttng/utils.c +++ b/src/bin/lttng/utils.c @@ -26,11 +26,6 @@ #include "utils.h" #include "command.h" -static const char *str_kernel = "Kernel"; -static const char *str_ust = "UST"; -static const char *str_jul = "JUL"; -static const char *str_log4j = "LOG4J"; -static const char *str_python = "Python"; static const char *str_all = "ALL"; static const char *str_tracepoint = "Tracepoint"; static const char *str_syscall = "Syscall"; @@ -298,34 +293,6 @@ int get_count_order_ulong(unsigned long x) return fls_ulong(x - 1); } -const char *get_domain_str(enum lttng_domain_type domain) -{ - const char *str_dom; - - switch (domain) { - case LTTNG_DOMAIN_KERNEL: - str_dom = str_kernel; - break; - case LTTNG_DOMAIN_UST: - str_dom = str_ust; - break; - case LTTNG_DOMAIN_JUL: - str_dom = str_jul; - break; - case LTTNG_DOMAIN_LOG4J: - str_dom = str_log4j; - break; - case LTTNG_DOMAIN_PYTHON: - str_dom = str_python; - break; - default: - /* Should not have an unknown domain or else define it. */ - assert(0); - } - - return str_dom; -} - const char *get_event_type_str(enum lttng_event_type type) { const char *str_event_type; diff --git a/src/bin/lttng/utils.h b/src/bin/lttng/utils.h index 97fb202ba..ba893edda 100644 --- a/src/bin/lttng/utils.h +++ b/src/bin/lttng/utils.h @@ -45,7 +45,6 @@ int get_count_order_u64(uint64_t x); */ int get_count_order_ulong(unsigned long x); -const char *get_domain_str(enum lttng_domain_type domain); const char *get_event_type_str(enum lttng_event_type event_type); int print_missing_or_multiple_domains(unsigned int domain_count, diff --git a/src/common/mi-lttng.c b/src/common/mi-lttng.c index aaca5946c..663d38a7d 100644 --- a/src/common/mi-lttng.c +++ b/src/common/mi-lttng.c @@ -710,7 +710,6 @@ const char *mi_lttng_eventfieldtype_string(enum lttng_event_field_type val) LTTNG_HIDDEN const char *mi_lttng_domaintype_string(enum lttng_domain_type value) { - /* Note: This is a *duplicate* of get_domain_str from bin/lttng/utils.c */ switch (value) { case LTTNG_DOMAIN_KERNEL: return config_domain_type_kernel; -- 2.34.1