From ba1220fab9184c36474fa4f45a00707944c0656b Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 16 Jan 2025 17:24:43 +0000 Subject: [PATCH] Clean-up: clang-format fixes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: Ie5d2d6072290aaaedfe5990eed4f7c9baff02561 Signed-off-by: Jérémie Galarneau --- src/bin/lttng-relayd/health-relayd.cpp | 1 - src/bin/lttng-relayd/live.cpp | 2 +- src/bin/lttng-relayd/main.cpp | 43 ++++++++++++---------- src/bin/lttng-relayd/utils.hpp | 2 +- src/bin/lttng/commands/enable_channels.cpp | 23 ++++++++---- src/common/defaults.hpp | 12 +++--- src/common/utils.cpp | 5 ++- 7 files changed, 51 insertions(+), 37 deletions(-) diff --git a/src/bin/lttng-relayd/health-relayd.cpp b/src/bin/lttng-relayd/health-relayd.cpp index 9f131029e..1c357d50c 100644 --- a/src/bin/lttng-relayd/health-relayd.cpp +++ b/src/bin/lttng-relayd/health-relayd.cpp @@ -65,7 +65,6 @@ int send_unix_sock(int sock, void *buf, size_t len) return lttcomm_send_unix_sock(sock, buf, len); } - void parse_health_env() { const char *health_path; diff --git a/src/bin/lttng-relayd/live.cpp b/src/bin/lttng-relayd/live.cpp index 4c703421c..1fb4a25a6 100644 --- a/src/bin/lttng-relayd/live.cpp +++ b/src/bin/lttng-relayd/live.cpp @@ -880,7 +880,7 @@ static void *thread_listener(void *data __attribute__((unused))) health_code_update(); try { live_control_sock = init_socket(live_uri, "Live listener"); - } catch(const lttng::runtime_error& ex) { + } catch (const lttng::runtime_error& ex) { ERR("Failed to initialize live socket: %s", ex.what()); goto error_sock_control; } diff --git a/src/bin/lttng-relayd/main.cpp b/src/bin/lttng-relayd/main.cpp index e4c121538..687904512 100644 --- a/src/bin/lttng-relayd/main.cpp +++ b/src/bin/lttng-relayd/main.cpp @@ -214,12 +214,7 @@ static struct option long_options[] = { nullptr, 'b', }, - { - "pid-file", - 1, - nullptr, - 'P' - }, + { "pid-file", 1, nullptr, 'P' }, { "group", 1, @@ -272,12 +267,7 @@ static struct option long_options[] = { }, { "disallow-clear", 0, nullptr, 'x' }, { "dynamic-port-allocation", 0, nullptr, '\0' }, - { - "sig-parent", - 0, - nullptr, - 'S' - }, + { "sig-parent", 0, nullptr, 'S' }, { nullptr, 0, @@ -1071,7 +1061,10 @@ static struct lttcomm_sock *relay_socket_create(struct lttng_uri *uri, const cha goto error; } - DBG("Bound %s socket fd %d to port %d", name, sock->fd, ntohs(sock->sockaddr.addr.sin.sin_port)); + DBG("Bound %s socket fd %d to port %d", + name, + sock->fd, + ntohs(sock->sockaddr.addr.sin.sin_port)); ret = sock->ops->listen(sock, -1); if (ret < 0) { goto error; @@ -1145,13 +1138,19 @@ static void *relay_thread_listener(void *data __attribute__((unused))) create_lttng_rundir_with_perm(rundir_path.get()); create_lttng_rundir_with_perm(relayd_rundir_path.get()); - ret = snprintf(relayd_control_port_path, sizeof(relayd_control_port_path), DEFAULT_RELAYD_CONTROL_PORT_PATH, relayd_rundir_path.get()); + ret = snprintf(relayd_control_port_path, + sizeof(relayd_control_port_path), + DEFAULT_RELAYD_CONTROL_PORT_PATH, + relayd_rundir_path.get()); if (ret < 0) { ERR("Failed to format relayd_control_port_path"); goto error_sock_control; } - ret = snprintf(relayd_data_port_path, sizeof(relayd_data_port_path), DEFAULT_RELAYD_DATA_PORT_PATH, relayd_rundir_path.get()); + ret = snprintf(relayd_data_port_path, + sizeof(relayd_data_port_path), + DEFAULT_RELAYD_DATA_PORT_PATH, + relayd_rundir_path.get()); if (ret < 0) { ERR("Failed to format relayd_data_port_path"); goto error_sock_control; @@ -1165,8 +1164,11 @@ static void *relay_thread_listener(void *data __attribute__((unused))) } if (auto _ret = utils_create_value_file(ntohs(control_sock->sockaddr.addr.sin.sin_port), - relayd_control_port_path)) { - ERR_FMT("Failed to create control port path file: port={}, path=`{}`, ret={}", ntohs(control_sock->sockaddr.addr.sin.sin_port), relayd_control_port_path, _ret); + relayd_control_port_path)) { + ERR_FMT("Failed to create control port path file: port={}, path=`{}`, ret={}", + ntohs(control_sock->sockaddr.addr.sin.sin_port), + relayd_control_port_path, + _ret); goto error_create_poll; goto error_sock_relay; } @@ -1177,8 +1179,11 @@ static void *relay_thread_listener(void *data __attribute__((unused))) } if (auto _ret = utils_create_value_file(ntohs(data_sock->sockaddr.addr.sin.sin_port), - relayd_data_port_path)) { - ERR_FMT("Failed to create data port path file: port={}, path=`{}`, ret={}", ntohs(data_sock->sockaddr.addr.sin.sin_port), relayd_data_port_path, _ret); + relayd_data_port_path)) { + ERR_FMT("Failed to create data port path file: port={}, path=`{}`, ret={}", + ntohs(data_sock->sockaddr.addr.sin.sin_port), + relayd_data_port_path, + _ret); goto error_create_poll; } diff --git a/src/bin/lttng-relayd/utils.hpp b/src/bin/lttng-relayd/utils.hpp index c42ee82ae..c5ed07d48 100644 --- a/src/bin/lttng-relayd/utils.hpp +++ b/src/bin/lttng-relayd/utils.hpp @@ -11,6 +11,6 @@ */ char *create_output_path(const char *path_name); -void create_lttng_rundir_with_perm(const char* rundir); +void create_lttng_rundir_with_perm(const char *rundir); #endif /* RELAYD_UTILS_H */ diff --git a/src/bin/lttng/commands/enable_channels.cpp b/src/bin/lttng/commands/enable_channels.cpp index bbce3e4b6..13553e68c 100644 --- a/src/bin/lttng/commands/enable_channels.cpp +++ b/src/bin/lttng/commands/enable_channels.cpp @@ -135,15 +135,20 @@ static void set_default_attr(struct lttng_domain *dom) } } -static bool system_has_memory_for_channel_buffers(char *session_name, struct lttng_channel *channel, uint64_t *bytes_required, uint64_t *bytes_available) { +static bool system_has_memory_for_channel_buffers(char *session_name, + struct lttng_channel *channel, + uint64_t *bytes_required, + uint64_t *bytes_available) +{ /* * Verify that the amount of memory required to create the requested * buffer is available on the system at the moment. */ - unsigned long total_buffer_size_needed_per_cpu {0}; - const auto spec = lttng::cli::session_spec(lttng::cli::session_spec::type::NAME, session_name); + unsigned long total_buffer_size_needed_per_cpu{ 0 }; + const auto spec = + lttng::cli::session_spec(lttng::cli::session_spec::type::NAME, session_name); const auto sessions = list_sessions(spec); - int ncpus {0}; + int ncpus{ 0 }; if (sessions.size() <= 0) { /* Session not found */ @@ -153,20 +158,24 @@ static bool system_has_memory_for_channel_buffers(char *session_name, struct ltt if (channel->attr.num_subbuf > UINT64_MAX / channel->attr.subbuf_size) { /* Overflow */ - ERR_FMT("Integer overflow calculating total buffer size per CPU on channel '{}': num_subbuf={}, subbuf_size={}", channel->name, channel->attr.num_subbuf, channel->attr.subbuf_size) + ERR_FMT("Integer overflow calculating total buffer size per CPU on channel '{}': num_subbuf={}, subbuf_size={}", + channel->name, + channel->attr.num_subbuf, + channel->attr.subbuf_size) return false; } total_buffer_size_needed_per_cpu = channel->attr.num_subbuf * channel->attr.subbuf_size; try { ncpus = utils_get_cpu_count(); - } catch (const std::exception &ex) { + } catch (const std::exception& ex) { ERR_FMT("Exception when getting CPU count: {}", ex.what()); return false; } /* In snapshot mode, an extra set of buffers is required. */ - const auto _bytes_required = static_cast(total_buffer_size_needed_per_cpu * ncpus + sessions[0].snapshot_mode); + const auto _bytes_required = static_cast( + total_buffer_size_needed_per_cpu * ncpus + sessions[0].snapshot_mode); if (bytes_required != nullptr) { *bytes_required = _bytes_required; } diff --git a/src/common/defaults.hpp b/src/common/defaults.hpp index 5c296a389..6e4ef94ea 100644 --- a/src/common/defaults.hpp +++ b/src/common/defaults.hpp @@ -83,11 +83,11 @@ #define DEFAULT_USTCONSUMERD32_ERR_SOCK_PATH DEFAULT_USTCONSUMERD32_PATH "/error" /* Relayd path */ -#define DEFAULT_RELAYD_RUNDIR "%s" -#define DEFAULT_RELAYD_PATH DEFAULT_RELAYD_RUNDIR "/relayd" -#define DEFAULT_RELAYD_CONTROL_PORT_PATH DEFAULT_LTTNG_EXPLICIT_RUNDIR "/control.port" -#define DEFAULT_RELAYD_DATA_PORT_PATH DEFAULT_LTTNG_EXPLICIT_RUNDIR "/data.port" -#define DEFAULT_RELAYD_LIVE_PORT_PATH DEFAULT_LTTNG_EXPLICIT_RUNDIR "/live.port" +#define DEFAULT_RELAYD_RUNDIR "%s" +#define DEFAULT_RELAYD_PATH DEFAULT_RELAYD_RUNDIR "/relayd" +#define DEFAULT_RELAYD_CONTROL_PORT_PATH DEFAULT_LTTNG_EXPLICIT_RUNDIR "/control.port" +#define DEFAULT_RELAYD_DATA_PORT_PATH DEFAULT_LTTNG_EXPLICIT_RUNDIR "/data.port" +#define DEFAULT_RELAYD_LIVE_PORT_PATH DEFAULT_LTTNG_EXPLICIT_RUNDIR "/live.port" #define DEFAULT_RELAYD_MIN_FD_POOL_SIZE 100 /* @@ -383,7 +383,7 @@ */ #define DEFAULT_ROTATE_PENDING_TIMER CONFIG_DEFAULT_ROTATE_PENDING_TIMER -#define DEFAULT_LINUX_POSSIBLE_CPU_PATH "/sys/devices/system/cpu/possible" +#define DEFAULT_LINUX_POSSIBLE_CPU_PATH "/sys/devices/system/cpu/possible" #define DEFAULT_LINUX_POSSIBLE_CPU_MASK_LENGTH 4096 /* diff --git a/src/common/utils.cpp b/src/common/utils.cpp index 78d7beb5a..288840445 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -1470,13 +1470,14 @@ unsigned int utils_get_cpu_count() LTTNG_MAY_THROW return get_max_possible_cpu_id() + 1; } -/** +/* * Returns LTTNG_OK if the system as num_bytes available. * * If bytes_available is not NULL, the best estimate of the available memory * will be recorded at that address. */ -enum lttng_error_code utils_check_enough_available_memory(uint64_t num_bytes, uint64_t *bytes_available) +enum lttng_error_code utils_check_enough_available_memory(uint64_t num_bytes, + uint64_t *bytes_available) { int ret; enum lttng_error_code ret_code; -- 2.39.5