Skip to content

Commit fd58bdd

Browse files
authored
Remove unnecessary lambda captures in the tests. (#2289)
* Remove unnecessary lambda captures in the tests. This was pointed out by compiling with clang. Signed-off-by: Chris Lalancette <[email protected]>
1 parent e7f0639 commit fd58bdd

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

rclcpp/test/rclcpp/executors/test_events_executor.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ TEST_F(TestEventsExecutor, run_pub_sub)
6060
executor.add_node(node);
6161

6262
bool spin_exited = false;
63-
std::thread spinner([&spin_exited, &executor, this]() {
63+
std::thread spinner([&spin_exited, &executor]() {
6464
executor.spin();
6565
spin_exited = true;
6666
});
@@ -107,7 +107,7 @@ TEST_F(TestEventsExecutor, run_clients_servers)
107107
executor.add_node(node);
108108

109109
bool spin_exited = false;
110-
std::thread spinner([&spin_exited, &executor, this]() {
110+
std::thread spinner([&spin_exited, &executor]() {
111111
executor.spin();
112112
spin_exited = true;
113113
});
@@ -346,7 +346,7 @@ TEST_F(TestEventsExecutor, cancel_while_timers_running)
346346
});
347347

348348

349-
std::thread spinner([&executor, this]() {executor.spin();});
349+
std::thread spinner([&executor]() {executor.spin();});
350350

351351
std::this_thread::sleep_for(10ms);
352352
// Call cancel while t1 callback is still being executed
@@ -373,7 +373,7 @@ TEST_F(TestEventsExecutor, cancel_while_timers_waiting)
373373
executor.add_node(node);
374374

375375
auto start = std::chrono::steady_clock::now();
376-
std::thread spinner([&executor, this]() {executor.spin();});
376+
std::thread spinner([&executor]() {executor.spin();});
377377

378378
std::this_thread::sleep_for(10ms);
379379
executor.cancel();
@@ -395,7 +395,7 @@ TEST_F(TestEventsExecutor, destroy_entities)
395395
2ms, [&]() {publisher->publish(std::make_unique<test_msgs::msg::Empty>());});
396396
EventsExecutor executor_pub;
397397
executor_pub.add_node(node_pub);
398-
std::thread spinner([&executor_pub, this]() {executor_pub.spin();});
398+
std::thread spinner([&executor_pub]() {executor_pub.spin();});
399399

400400
// Create a node with two different subscriptions to the topic
401401
auto node_sub = std::make_shared<rclcpp::Node>("node_sub");

rclcpp/test/rclcpp/executors/test_executors.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ TYPED_TEST(TestIntraprocessExecutors, testIntraprocessRetrigger) {
779779
// that publishers aren't continuing to publish.
780780
// This was previously broken in that intraprocess guard conditions were only triggered on
781781
// publish and the test was added to prevent future regressions.
782-
const size_t kNumMessages = 100;
782+
static constexpr size_t kNumMessages = 100;
783783

784784
using ExecutorType = TypeParam;
785785
ExecutorType executor;
@@ -808,11 +808,9 @@ TYPED_TEST(TestIntraprocessExecutors, testIntraprocessRetrigger) {
808808
// Fire a timer every 10ms up to 5 seconds waiting for subscriptions to be read.
809809
loops = 0;
810810
auto timer = this->node->create_wall_timer(
811-
std::chrono::milliseconds(10), [this, &executor, &loops, &kNumMessages]() {
811+
std::chrono::milliseconds(10), [this, &executor, &loops]() {
812812
loops++;
813-
if (kNumMessages == this->callback_count.load() ||
814-
loops == 500)
815-
{
813+
if (kNumMessages == this->callback_count.load() || loops == 500) {
816814
executor.cancel();
817815
}
818816
});

0 commit comments

Comments
 (0)