initialize memory before sending a message (#277)

* initialize memory before sending a message

* add todo referencing ticket

* wrap todo
This commit is contained in:
Dirk Thomas 2018-08-14 16:58:30 -07:00 committed by GitHub
parent e2f7c26123
commit 1e5bf4ac29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View file

@ -158,6 +158,9 @@ int main(int argc, char ** argv)
// Initialize a request. // Initialize a request.
test_msgs__srv__Primitives_Request client_request; test_msgs__srv__Primitives_Request client_request;
// TODO(dirk-thomas) zero initialization necessary until
// https://github.com/ros2/ros2/issues/397 is implemented
memset(&client_request, 0, sizeof(test_msgs__srv__Primitives_Request));
test_msgs__srv__Primitives_Request__init(&client_request); test_msgs__srv__Primitives_Request__init(&client_request);
client_request.uint8_value = 1; client_request.uint8_value = 1;
client_request.uint32_value = 2; client_request.uint32_value = 2;
@ -178,6 +181,9 @@ int main(int argc, char ** argv)
// Initialize the response owned by the client and take the response. // Initialize the response owned by the client and take the response.
test_msgs__srv__Primitives_Response client_response; test_msgs__srv__Primitives_Response client_response;
// TODO(dirk-thomas) zero initialization necessary until
// https://github.com/ros2/ros2/issues/397 is implemented
memset(&client_response, 0, sizeof(test_msgs__srv__Primitives_Response));
test_msgs__srv__Primitives_Response__init(&client_response); test_msgs__srv__Primitives_Response__init(&client_response);
if (!wait_for_client_to_be_ready(&client, 1000, 100)) { if (!wait_for_client_to_be_ready(&client, 1000, 100)) {

View file

@ -125,6 +125,9 @@ int main(int argc, char ** argv)
// Initialize a response. // Initialize a response.
test_msgs__srv__Primitives_Response service_response; test_msgs__srv__Primitives_Response service_response;
// TODO(dirk-thomas) zero initialization necessary until
// https://github.com/ros2/ros2/issues/397 is implemented
memset(&service_response, 0, sizeof(test_msgs__srv__Primitives_Response));
test_msgs__srv__Primitives_Response__init(&service_response); test_msgs__srv__Primitives_Response__init(&service_response);
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({ OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({
test_msgs__srv__Primitives_Response__fini(&service_response); test_msgs__srv__Primitives_Response__fini(&service_response);
@ -139,6 +142,9 @@ int main(int argc, char ** argv)
// Take the pending request. // Take the pending request.
test_msgs__srv__Primitives_Request service_request; test_msgs__srv__Primitives_Request service_request;
// TODO(dirk-thomas) zero initialization necessary until
// https://github.com/ros2/ros2/issues/397 is implemented
memset(&service_request, 0, sizeof(test_msgs__srv__Primitives_Request));
test_msgs__srv__Primitives_Request__init(&service_request); test_msgs__srv__Primitives_Request__init(&service_request);
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({ OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({
test_msgs__srv__Primitives_Request__fini(&service_request); test_msgs__srv__Primitives_Request__fini(&service_request);