Skip to content

Commit

Permalink
Merge pull request ros2#167 from ros2/uncrustify_master
Browse files Browse the repository at this point in the history
update style to match latest uncrustify
  • Loading branch information
dirk-thomas authored Sep 29, 2017
2 parents ef94e9f + 72bcb6b commit 29a01c3
Show file tree
Hide file tree
Showing 17 changed files with 451 additions and 380 deletions.
12 changes: 6 additions & 6 deletions rcl/include/rcl/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ rcl_set_default_ros_time_source(rcl_time_source_t * process_time_source);
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_difference_times(rcl_time_point_t * start, rcl_time_point_t * finish,
rcl_duration_t * delta);
rcl_difference_times(
rcl_time_point_t * start, rcl_time_point_t * finish, rcl_duration_t * delta);

/// Fill the time point with the current value of the associated clock.
/**
Expand Down Expand Up @@ -466,8 +466,8 @@ rcl_disable_ros_time_override(rcl_time_source_t * time_source);
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_is_enabled_ros_time_override(rcl_time_source_t * time_source,
bool * is_enabled);
rcl_is_enabled_ros_time_override(
rcl_time_source_t * time_source, bool * is_enabled);

/// Set the current time for this `RCL_ROS_TIME` time source.
/**
Expand All @@ -485,8 +485,8 @@ rcl_is_enabled_ros_time_override(rcl_time_source_t * time_source,
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_set_ros_time_override(rcl_time_source_t * time_source,
rcl_time_point_value_t time_value);
rcl_set_ros_time_override(
rcl_time_source_t * time_source, rcl_time_point_value_t time_value);

#if __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion rcl/src/rcl/rmw_implementation_identifier_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extern "C"
#pragma section(".CRT$XCU", read)
#define INITIALIZER2_(f, p) \
static void f(void); \
__declspec(allocate(".CRT$XCU")) void(*f ## _)(void) = f; \
__declspec(allocate(".CRT$XCU")) void (*f ## _)(void) = f; \
__pragma(comment(linker, "/include:" p #f "_")) \
static void f(void)
#ifdef _WIN64
Expand Down
4 changes: 2 additions & 2 deletions rcl/src/rcl/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ rcl_set_default_ros_time_source(rcl_time_source_t * process_time_source)
}

rcl_ret_t
rcl_difference_times(rcl_time_point_t * start, rcl_time_point_t * finish,
rcl_duration_t * delta)
rcl_difference_times(
rcl_time_point_t * start, rcl_time_point_t * finish, rcl_duration_t * delta)
{
if (start->time_source->type != finish->time_source->type) {
RCL_SET_ERROR_MSG(
Expand Down
21 changes: 12 additions & 9 deletions rcl/test/memory_tools/test_memory_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,22 @@
*/
TEST(TestMemoryTools, test_allocation_checking_tools) {
size_t unexpected_mallocs = 0;
auto on_unexpected_malloc = ([&unexpected_mallocs]() {
unexpected_mallocs++;
});
auto on_unexpected_malloc = (
[&unexpected_mallocs]() {
unexpected_mallocs++;
});
set_on_unexpected_malloc_callback(on_unexpected_malloc);
size_t unexpected_reallocs = 0;
auto on_unexpected_realloc = ([&unexpected_reallocs]() {
unexpected_reallocs++;
});
auto on_unexpected_realloc = (
[&unexpected_reallocs]() {
unexpected_reallocs++;
});
set_on_unexpected_realloc_callback(on_unexpected_realloc);
size_t unexpected_frees = 0;
auto on_unexpected_free = ([&unexpected_frees]() {
unexpected_frees++;
});
auto on_unexpected_free = (
[&unexpected_frees]() {
unexpected_frees++;
});
set_on_unexpected_free_callback(on_unexpected_free);
void * mem = nullptr;
void * remem = nullptr;
Expand Down
39 changes: 21 additions & 18 deletions rcl/test/rcl/client_fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ wait_for_client_to_be_ready(
RCUTILS_LOG_ERROR("Error in wait set init: %s", rcl_get_error_string_safe())
return false;
}
auto wait_set_exit = make_scope_exit([&wait_set]() {
if (rcl_wait_set_fini(&wait_set) != RCL_RET_OK) {
RCUTILS_LOG_ERROR("Error in wait set fini: %s", rcl_get_error_string_safe())
throw std::runtime_error("error while waiting for client");
}
});
auto wait_set_exit = make_scope_exit(
[&wait_set]() {
if (rcl_wait_set_fini(&wait_set) != RCL_RET_OK) {
RCUTILS_LOG_ERROR("Error in wait set fini: %s", rcl_get_error_string_safe())
throw std::runtime_error("error while waiting for client");
}
});
size_t iteration = 0;
do {
++iteration;
Expand Down Expand Up @@ -115,12 +116,13 @@ int main(int argc, char ** argv)
RCUTILS_LOG_ERROR("Error in node init: %s", rcl_get_error_string_safe())
return -1;
}
auto node_exit = make_scope_exit([&main_ret, &node]() {
if (rcl_node_fini(&node) != RCL_RET_OK) {
RCUTILS_LOG_ERROR("Error in node fini: %s", rcl_get_error_string_safe())
main_ret = -1;
}
});
auto node_exit = make_scope_exit(
[&main_ret, &node]() {
if (rcl_node_fini(&node) != RCL_RET_OK) {
RCUTILS_LOG_ERROR("Error in node fini: %s", rcl_get_error_string_safe())
main_ret = -1;
}
});

const rosidl_service_type_support_t * ts = ROSIDL_GET_SRV_TYPE_SUPPORT(
example_interfaces, AddTwoInts);
Expand All @@ -134,12 +136,13 @@ int main(int argc, char ** argv)
return -1;
}

auto client_exit = make_scope_exit([&client, &main_ret, &node]() {
if (rcl_client_fini(&client, &node)) {
RCUTILS_LOG_ERROR("Error in client fini: %s", rcl_get_error_string_safe())
main_ret = -1;
}
});
auto client_exit = make_scope_exit(
[&client, &main_ret, &node]() {
if (rcl_client_fini(&client, &node)) {
RCUTILS_LOG_ERROR("Error in client fini: %s", rcl_get_error_string_safe())
main_ret = -1;
}
});

// Wait until server is available
if (!wait_for_server_to_be_available(&node, &client, 1000, 100)) {
Expand Down
53 changes: 29 additions & 24 deletions rcl/test/rcl/service_fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ wait_for_service_to_be_ready(
RCUTILS_LOG_ERROR("Error in wait set init: %s", rcl_get_error_string_safe())
return false;
}
auto wait_set_exit = make_scope_exit([&wait_set]() {
if (rcl_wait_set_fini(&wait_set) != RCL_RET_OK) {
RCUTILS_LOG_ERROR("Error in wait set fini: %s", rcl_get_error_string_safe())
throw std::runtime_error("error waiting for service to be ready");
}
});
auto wait_set_exit = make_scope_exit(
[&wait_set]() {
if (rcl_wait_set_fini(&wait_set) != RCL_RET_OK) {
RCUTILS_LOG_ERROR("Error in wait set fini: %s", rcl_get_error_string_safe())
throw std::runtime_error("error waiting for service to be ready");
}
});
size_t iteration = 0;
do {
++iteration;
Expand Down Expand Up @@ -89,12 +90,13 @@ int main(int argc, char ** argv)
RCUTILS_LOG_ERROR("Error in node init: %s", rcl_get_error_string_safe())
return -1;
}
auto node_exit = make_scope_exit([&main_ret, &node]() {
if (rcl_node_fini(&node) != RCL_RET_OK) {
RCUTILS_LOG_ERROR("Error in node fini: %s", rcl_get_error_string_safe())
main_ret = -1;
}
});
auto node_exit = make_scope_exit(
[&main_ret, &node]() {
if (rcl_node_fini(&node) != RCL_RET_OK) {
RCUTILS_LOG_ERROR("Error in node fini: %s", rcl_get_error_string_safe())
main_ret = -1;
}
});

const rosidl_service_type_support_t * ts = ROSIDL_GET_SRV_TYPE_SUPPORT(
example_interfaces, AddTwoInts);
Expand All @@ -108,19 +110,21 @@ int main(int argc, char ** argv)
return -1;
}

auto service_exit = make_scope_exit([&main_ret, &service, &node]() {
if (rcl_service_fini(&service, &node)) {
RCUTILS_LOG_ERROR("Error in service fini: %s", rcl_get_error_string_safe())
main_ret = -1;
}
});
auto service_exit = make_scope_exit(
[&main_ret, &service, &node]() {
if (rcl_service_fini(&service, &node)) {
RCUTILS_LOG_ERROR("Error in service fini: %s", rcl_get_error_string_safe())
main_ret = -1;
}
});

// Initialize a response.
example_interfaces__srv__AddTwoInts_Response service_response;
example_interfaces__srv__AddTwoInts_Response__init(&service_response);
auto response_exit = make_scope_exit([&service_response]() {
example_interfaces__srv__AddTwoInts_Response__fini(&service_response);
});
auto response_exit = make_scope_exit(
[&service_response]() {
example_interfaces__srv__AddTwoInts_Response__fini(&service_response);
});

// Block until a client request comes in.

Expand All @@ -132,9 +136,10 @@ int main(int argc, char ** argv)
// Take the pending request.
example_interfaces__srv__AddTwoInts_Request service_request;
example_interfaces__srv__AddTwoInts_Request__init(&service_request);
auto request_exit = make_scope_exit([&service_request]() {
example_interfaces__srv__AddTwoInts_Request__fini(&service_request);
});
auto request_exit = make_scope_exit(
[&service_request]() {
example_interfaces__srv__AddTwoInts_Request__fini(&service_request);
});
rmw_request_id_t header;
// TODO(jacquelinekay) May have to check for timeout error codes
if (rcl_take_request(&service, &header, &service_request) != RCL_RET_OK) {
Expand Down
11 changes: 6 additions & 5 deletions rcl/test/rcl/test_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ TEST_F(TestClientFixture, test_client_nominal) {
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
EXPECT_EQ(strcmp(rcl_client_get_service_name(&client), expected_topic_name), 0);

auto client_exit = make_scope_exit([&client, this]() {
stop_memory_checking();
rcl_ret_t ret = rcl_client_fini(&client, this->node_ptr);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
});
auto client_exit = make_scope_exit(
[&client, this]() {
stop_memory_checking();
rcl_ret_t ret = rcl_client_fini(&client, this->node_ptr);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
});

// Initialize the client request.
example_interfaces__srv__AddTwoInts_Request req;
Expand Down
87 changes: 45 additions & 42 deletions rcl/test/rcl/test_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,38 +421,39 @@ TEST_F(CLASSNAME(TestGraphFixture, RMW_IMPLEMENTATION), test_graph_guard_conditi
// Create a thread to sleep for a time, then create a publisher, sleep more, then a subscriber,
// sleep more, destroy the subscriber, sleep more, and then destroy the publisher.
std::promise<bool> topic_changes_promise;
std::thread topic_thread([this, &topic_changes_promise]() {
// sleep
std::this_thread::sleep_for(std::chrono::milliseconds(100));
// create the publisher
rcl_publisher_t pub = rcl_get_zero_initialized_publisher();
rcl_publisher_options_t pub_ops = rcl_publisher_get_default_options();
rcl_ret_t ret = rcl_publisher_init(
&pub, this->node_ptr, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, String),
"/chatter_test_graph_guard_condition_topics", &pub_ops);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
// sleep
std::this_thread::sleep_for(std::chrono::milliseconds(100));
// create the subscription
rcl_subscription_t sub = rcl_get_zero_initialized_subscription();
rcl_subscription_options_t sub_ops = rcl_subscription_get_default_options();
ret = rcl_subscription_init(
&sub, this->node_ptr, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, String),
"/chatter_test_graph_guard_condition_topics", &sub_ops);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
// sleep
std::this_thread::sleep_for(std::chrono::milliseconds(100));
// destroy the subscription
ret = rcl_subscription_fini(&sub, this->node_ptr);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
// sleep
std::this_thread::sleep_for(std::chrono::milliseconds(100));
// destroy the publication
ret = rcl_publisher_fini(&pub, this->node_ptr);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
// notify that the thread is done
topic_changes_promise.set_value(true);
});
std::thread topic_thread(
[this, &topic_changes_promise]() {
// sleep
std::this_thread::sleep_for(std::chrono::milliseconds(100));
// create the publisher
rcl_publisher_t pub = rcl_get_zero_initialized_publisher();
rcl_publisher_options_t pub_ops = rcl_publisher_get_default_options();
rcl_ret_t ret = rcl_publisher_init(
&pub, this->node_ptr, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, String),
"/chatter_test_graph_guard_condition_topics", &pub_ops);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
// sleep
std::this_thread::sleep_for(std::chrono::milliseconds(100));
// create the subscription
rcl_subscription_t sub = rcl_get_zero_initialized_subscription();
rcl_subscription_options_t sub_ops = rcl_subscription_get_default_options();
ret = rcl_subscription_init(
&sub, this->node_ptr, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, String),
"/chatter_test_graph_guard_condition_topics", &sub_ops);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
// sleep
std::this_thread::sleep_for(std::chrono::milliseconds(100));
// destroy the subscription
ret = rcl_subscription_fini(&sub, this->node_ptr);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
// sleep
std::this_thread::sleep_for(std::chrono::milliseconds(100));
// destroy the publication
ret = rcl_publisher_fini(&pub, this->node_ptr);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
// notify that the thread is done
topic_changes_promise.set_value(true);
});
// Wait for the graph state to change, expecting it to do so at least 4 times,
// once for each change in the topics thread.
const rcl_guard_condition_t * graph_guard_condition =
Expand Down Expand Up @@ -493,11 +494,12 @@ TEST_F(CLASSNAME(TestGraphFixture, RMW_IMPLEMENTATION), test_rcl_service_server_
rcl_client_options_t client_options = rcl_client_get_default_options();
ret = rcl_client_init(&client, this->node_ptr, ts, service_name, &client_options);
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
auto client_exit = make_scope_exit([&client, this]() {
stop_memory_checking();
rcl_ret_t ret = rcl_client_fini(&client, this->node_ptr);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
});
auto client_exit = make_scope_exit(
[&client, this]() {
stop_memory_checking();
rcl_ret_t ret = rcl_client_fini(&client, this->node_ptr);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
});
// Check, knowing there is no service server (created by us at least).
bool is_available;
ret = rcl_service_server_is_available(this->node_ptr, &client, &is_available);
Expand Down Expand Up @@ -561,11 +563,12 @@ TEST_F(CLASSNAME(TestGraphFixture, RMW_IMPLEMENTATION), test_rcl_service_server_
rcl_service_options_t service_options = rcl_service_get_default_options();
ret = rcl_service_init(&service, this->node_ptr, ts, service_name, &service_options);
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
auto service_exit = make_scope_exit([&service, this]() {
stop_memory_checking();
rcl_ret_t ret = rcl_service_fini(&service, this->node_ptr);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
});
auto service_exit = make_scope_exit(
[&service, this]() {
stop_memory_checking();
rcl_ret_t ret = rcl_service_fini(&service, this->node_ptr);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
});
// Wait for and then assert that it is available.
wait_for_service_state_to_change(true, is_available);
ASSERT_TRUE(is_available);
Expand Down
Loading

0 comments on commit 29a01c3

Please sign in to comment.