From d6f723667ae57ad290b508c5949f4d9d22c5a829 Mon Sep 17 00:00:00 2001 From: Christian Eltzschig Date: Fri, 20 Dec 2024 14:31:10 +0100 Subject: [PATCH] [#555] Fix clang-tidy warnings --- examples/c/discovery/src/main.c | 1 + .../cxx/event_based_communication/src/pubsub_event.hpp | 2 +- examples/cxx/health_monitoring/src/central_daemon.cpp | 6 +++++- examples/cxx/health_monitoring/src/subscriber.cpp | 6 +++++- iceoryx2-ffi/cxx/src/port_factory_event.cpp | 3 +-- iceoryx2-ffi/cxx/src/service.cpp | 9 +++------ iceoryx2-ffi/cxx/tests/src/waitset_tests.cpp | 2 ++ 7 files changed, 18 insertions(+), 11 deletions(-) diff --git a/examples/c/discovery/src/main.c b/examples/c/discovery/src/main.c index 81e5aacac..d84ba740a 100644 --- a/examples/c/discovery/src/main.c +++ b/examples/c/discovery/src/main.c @@ -14,6 +14,7 @@ #include iox2_callback_progression_e list_callback(const iox2_static_config_t* static_details, void* callback_context) { + (void) callback_context; printf("Found Service: %s, ServiceID: %s\n", static_details->name, static_details->id); return iox2_callback_progression_e_CONTINUE; } diff --git a/examples/cxx/event_based_communication/src/pubsub_event.hpp b/examples/cxx/event_based_communication/src/pubsub_event.hpp index e180c1f12..8a11f4a73 100644 --- a/examples/cxx/event_based_communication/src/pubsub_event.hpp +++ b/examples/cxx/event_based_communication/src/pubsub_event.hpp @@ -26,7 +26,7 @@ enum class PubSubEvent : uint8_t { SentSample = 4, ReceivedSample = 5, SentHistory = 6, - Unknown + Unknown = 7 }; namespace iox { diff --git a/examples/cxx/health_monitoring/src/central_daemon.cpp b/examples/cxx/health_monitoring/src/central_daemon.cpp index 468904068..e90091b81 100644 --- a/examples/cxx/health_monitoring/src/central_daemon.cpp +++ b/examples/cxx/health_monitoring/src/central_daemon.cpp @@ -23,7 +23,9 @@ using namespace iox2; constexpr iox::units::Duration CYCLE_TIME = iox::units::Duration::fromMilliseconds(100); +namespace { void find_and_cleanup_dead_nodes(); +} auto main() -> int { auto service_name_1 = ServiceName::create("service_1").expect(""); @@ -93,14 +95,16 @@ auto main() -> int { return 0; } +namespace { void find_and_cleanup_dead_nodes() { Node::list(Config::global_config(), [](auto node_state) { node_state.dead([](auto view) { std::cout << "detected dead node: "; - view.details().and_then([](auto details) { std::cout << details.name().to_string().c_str(); }); + view.details().and_then([](const auto& details) { std::cout << details.name().to_string().c_str(); }); std::cout << std::endl; view.remove_stale_resources().expect(""); }); return CallbackProgression::Continue; }).expect(""); } +} // namespace diff --git a/examples/cxx/health_monitoring/src/subscriber.cpp b/examples/cxx/health_monitoring/src/subscriber.cpp index 58943d321..8d1506f9c 100644 --- a/examples/cxx/health_monitoring/src/subscriber.cpp +++ b/examples/cxx/health_monitoring/src/subscriber.cpp @@ -25,10 +25,12 @@ constexpr iox::units::Duration REACTION_BUFFER = iox::units::Duration::fromMilli constexpr iox::units::Duration CYCLE_TIME_1 = iox::units::Duration::fromMilliseconds(1000) + REACTION_BUFFER; constexpr iox::units::Duration CYCLE_TIME_2 = iox::units::Duration::fromMilliseconds(1500) + REACTION_BUFFER; +namespace { void find_and_cleanup_dead_nodes(); void handle_incoming_events(Listener& listener, const Subscriber& subscriber, const ServiceName& service_name); +} // namespace auto main() -> int { auto service_name_1 = ServiceName::create("service_1").expect(""); @@ -94,6 +96,7 @@ auto main() -> int { return 0; } +namespace { void handle_incoming_events(Listener& listener, const Subscriber& subscriber, const ServiceName& service_name) { @@ -119,10 +122,11 @@ void find_and_cleanup_dead_nodes() { Node::list(Config::global_config(), [](auto node_state) { node_state.dead([](auto view) { std::cout << "detected dead node: "; - view.details().and_then([](auto details) { std::cout << details.name().to_string().c_str(); }); + view.details().and_then([](const auto& details) { std::cout << details.name().to_string().c_str(); }); std::cout << std::endl; view.remove_stale_resources().expect(""); }); return CallbackProgression::Continue; }).expect(""); } +} // namespace diff --git a/iceoryx2-ffi/cxx/src/port_factory_event.cpp b/iceoryx2-ffi/cxx/src/port_factory_event.cpp index b6803a040..be7e2fd03 100644 --- a/iceoryx2-ffi/cxx/src/port_factory_event.cpp +++ b/iceoryx2-ffi/cxx/src/port_factory_event.cpp @@ -79,9 +79,8 @@ auto PortFactoryEvent::dynamic_config() const -> const DynamicConfigEvent& { } template -auto PortFactoryEvent::nodes(const iox::function)>& callback) const +auto PortFactoryEvent::nodes([[maybe_unused]] const iox::function)>& callback) const -> iox::expected { - static_cast(callback); IOX_TODO(); } diff --git a/iceoryx2-ffi/cxx/src/service.cpp b/iceoryx2-ffi/cxx/src/service.cpp index 97d5ddbcc..9df8a59d0 100644 --- a/iceoryx2-ffi/cxx/src/service.cpp +++ b/iceoryx2-ffi/cxx/src/service.cpp @@ -38,13 +38,10 @@ auto Service::does_exist(const ServiceName& service_name, } template -auto Service::details(const ServiceName& service_name, - const ConfigView config, - const MessagingPattern messaging_pattern) +auto Service::details([[maybe_unused]] const ServiceName& service_name, + [[maybe_unused]] const ConfigView config, + [[maybe_unused]] const MessagingPattern messaging_pattern) -> iox::expected>, ServiceDetailsError> { - static_cast(service_name); - static_cast(config); - static_cast(messaging_pattern); IOX_TODO(); } diff --git a/iceoryx2-ffi/cxx/tests/src/waitset_tests.cpp b/iceoryx2-ffi/cxx/tests/src/waitset_tests.cpp index e18b07da7..1014e7abb 100644 --- a/iceoryx2-ffi/cxx/tests/src/waitset_tests.cpp +++ b/iceoryx2-ffi/cxx/tests/src/waitset_tests.cpp @@ -284,6 +284,8 @@ TYPED_TEST(WaitSetTest, triggering_everything_works) { std::vector> listeners; std::vector> guards; + guards.reserve(NUMBER_OF_INTERVALS + NUMBER_OF_NOTIFICATIONS + NUMBER_OF_DEADLINES); + listeners.reserve(NUMBER_OF_NOTIFICATIONS + NUMBER_OF_DEADLINES); for (uint64_t idx = 0; idx < NUMBER_OF_INTERVALS; ++idx) { guards.emplace_back(sut.attach_interval(Duration::fromNanoseconds(1)).expect(""));