From: Jérémie Galarneau Date: Thu, 13 Apr 2023 18:41:43 +0000 (-0400) Subject: Clean-up: use const reference where possible X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=5b9eda8a30a21a1c9de4572dd2b397c7cf923fa1;p=lttng-tools.git Clean-up: use const reference where possible These exceptions can all be caught by const reference. Signed-off-by: Jérémie Galarneau Change-Id: I11a4f5018c838d77212340efa6f94d5d1c005ed6 --- diff --git a/src/bin/lttng-sessiond/cmd.cpp b/src/bin/lttng-sessiond/cmd.cpp index e89bcd15e..79cb6fed8 100644 --- a/src/bin/lttng-sessiond/cmd.cpp +++ b/src/bin/lttng-sessiond/cmd.cpp @@ -3435,7 +3435,7 @@ int cmd_destroy_session(struct ltt_session *session, int *sock_fd) try { the_rotation_thread_handle->unsubscribe_session_consumed_size_rotation( *session); - } catch (std::exception& e) { + } catch (const std::exception& e) { /* Continue the destruction of the session anyway. */ ERR("Failed to unsubscribe rotation thread notification channel from consumed size condition during session destruction: %s", e.what()); @@ -5898,7 +5898,7 @@ int cmd_rotation_set_schedule(struct ltt_session *session, try { the_rotation_thread_handle->subscribe_session_consumed_size_rotation( *session, new_value); - } catch (std::exception& e) { + } catch (const std::exception& e) { ERR("Failed to enable consumed-size notification in ROTATION_SET_SCHEDULE command: %s", e.what()); ret = LTTNG_ERR_UNK; @@ -5908,7 +5908,7 @@ int cmd_rotation_set_schedule(struct ltt_session *session, try { the_rotation_thread_handle ->unsubscribe_session_consumed_size_rotation(*session); - } catch (std::exception& e) { + } catch (const std::exception& e) { ERR("Failed to disable consumed-size notification in ROTATION_SET_SCHEDULE command: %s", e.what()); ret = LTTNG_ERR_UNK; diff --git a/src/bin/lttng-sessiond/ust-app.cpp b/src/bin/lttng-sessiond/ust-app.cpp index bdc7d6d20..b9091424b 100644 --- a/src/bin/lttng-sessiond/ust-app.cpp +++ b/src/bin/lttng-sessiond/ust-app.cpp @@ -6612,7 +6612,7 @@ static int handle_app_register_channel_notification(int sock, goto reply; } } - } catch (std::exception& ex) { + } catch (const std::exception& ex) { ERR("Failed to handle application context: %s", ex.what()); ret_code = -EINVAL; goto reply; diff --git a/src/common/random.cpp b/src/common/random.cpp index 5a038a563..ec74688ec 100644 --- a/src/common/random.cpp +++ b/src/common/random.cpp @@ -170,7 +170,7 @@ lttng::random::seed_t lttng::random::produce_best_effort_random_seed() { try { return lttng::random::produce_true_random_seed(); - } catch (std::exception& e) { + } catch (const std::exception& e) { WARN("%s", fmt::format( "Failed to produce a random seed using getrandom(), falling back to pseudo-random device seed generation which will block until its pool is initialized: {}", @@ -184,7 +184,7 @@ lttng::random::seed_t lttng::random::produce_best_effort_random_seed() * under some containerized environments. */ produce_random_seed_from_urandom(); - } catch (std::exception& e) { + } catch (const std::exception& e) { WARN("%s", fmt::format("Failed to produce a random seed from the urandom device: {}", e.what()) diff --git a/src/common/uuid.cpp b/src/common/uuid.cpp index ddf0fb509..8aa42a4e6 100644 --- a/src/common/uuid.cpp +++ b/src/common/uuid.cpp @@ -83,7 +83,7 @@ int lttng_uuid_generate(lttng_uuid& uuid_out) if (!lttng_uuid_is_init) { try { srand(lttng::random::produce_best_effort_random_seed()); - } catch (std::exception& e) { + } catch (const std::exception& e) { ERR("Failed to initialize random seed during generation of UUID: %s", e.what()); ret = -1;