Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ros2/rmw_fastrtps into sr…
Browse files Browse the repository at this point in the history
…iram_beta3
  • Loading branch information
Sriram Raghunathan committed Oct 30, 2017
2 parents db2d734 + 4e22c3e commit 5030f85
Show file tree
Hide file tree
Showing 29 changed files with 241 additions and 240 deletions.
38 changes: 17 additions & 21 deletions rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ rosidl_generator_c__void__Array__init(
if (!array) {
return false;
}
void * data = NULL;
void * data = nullptr;
if (size) {
data = static_cast<void *>(calloc(size, member_size));
if (!data) {
Expand All @@ -94,7 +94,7 @@ rosidl_generator_c__void__Array__fini(rosidl_generator_c__void__Array * array)
assert(array->capacity > 0);
// finalize all array elements
free(array->data);
array->data = NULL;
array->data = nullptr;
array->size = 0;
array->capacity = 0;
} else {
Expand Down Expand Up @@ -186,7 +186,7 @@ static size_t calculateMaxAlign(const MembersType * members)
break;
case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE:
{
const MembersType * sub_members = (const MembersType *)member.members_->data;
auto sub_members = (const MembersType *)member.members_->data;
alignment = calculateMaxAlign(sub_members);
}
break;
Expand Down Expand Up @@ -269,7 +269,7 @@ size_t get_array_size_and_assign_field(
size_t sub_members_size,
size_t max_align)
{
std::vector<unsigned char> * vector = reinterpret_cast<std::vector<unsigned char> *>(field);
auto vector = reinterpret_cast<std::vector<unsigned char> *>(field);
void * ptr = reinterpret_cast<void *>(sub_members_size);
size_t vsize = vector->size() / reinterpret_cast<size_t>(align_(max_align, ptr));
if (member->is_upper_bound_ && vsize > member->array_size_) {
Expand All @@ -286,8 +286,7 @@ size_t get_array_size_and_assign_field(
void * & subros_message,
size_t, size_t)
{
rosidl_generator_c__void__Array * tmparray =
static_cast<rosidl_generator_c__void__Array *>(field);
auto tmparray = static_cast<rosidl_generator_c__void__Array *>(field);
if (member->is_upper_bound_ && tmparray->size > member->array_size_) {
throw std::runtime_error("vector overcomes the maximum length");
}
Expand Down Expand Up @@ -362,7 +361,7 @@ bool TypeSupport<MembersType>::serializeROSmessage(
break;
case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE:
{
const MembersType * sub_members = (const MembersType *)member->members_->data;
auto sub_members = (const MembersType *)member->members_->data;
serializeROSmessage(ser, sub_members, field);
}
break;
Expand Down Expand Up @@ -411,7 +410,7 @@ bool TypeSupport<MembersType>::serializeROSmessage(
break;
case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE:
{
const MembersType * sub_members =
auto sub_members =
static_cast<const MembersType *>(member->members_->data);
void * subros_message = nullptr;
size_t array_size = 0;
Expand Down Expand Up @@ -455,7 +454,7 @@ void deserialize_array(
if (member->array_size_ && !member->is_upper_bound_) {
deser.deserializeArray(static_cast<T *>(field), member->array_size_);
} else {
std::vector<T> & vector = *reinterpret_cast<std::vector<T> *>(field);
auto & vector = *reinterpret_cast<std::vector<T> *>(field);
if (call_new) {
new(&vector) std::vector<T>;
}
Expand Down Expand Up @@ -533,7 +532,7 @@ inline size_t get_submessage_array_deserialize(
uint32_t vsize = 0;
// Deserialize length
deser >> vsize;
std::vector<unsigned char> * vector = reinterpret_cast<std::vector<unsigned char> *>(field);
auto vector = reinterpret_cast<std::vector<unsigned char> *>(field);
if (call_new) {
new(vector) std::vector<unsigned char>;
}
Expand All @@ -556,8 +555,7 @@ inline size_t get_submessage_array_deserialize(
// Deserialize length
uint32_t vsize = 0;
deser >> vsize;
rosidl_generator_c__void__Array * tmparray =
static_cast<rosidl_generator_c__void__Array *>(field);
auto tmparray = static_cast<rosidl_generator_c__void__Array *>(field);
rosidl_generator_c__void__Array__init(tmparray, vsize, sub_members_size);
subros_message = reinterpret_cast<void *>(tmparray->data);
return vsize;
Expand Down Expand Up @@ -618,7 +616,7 @@ bool TypeSupport<MembersType>::deserializeROSmessage(
break;
case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE:
{
const MembersType * sub_members = (const MembersType *)member->members_->data;
auto sub_members = (const MembersType *)member->members_->data;
deserializeROSmessage(deser, sub_members, field, call_new);
}
break;
Expand Down Expand Up @@ -667,7 +665,7 @@ bool TypeSupport<MembersType>::deserializeROSmessage(
break;
case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE:
{
const MembersType * sub_members = (const MembersType *)member->members_->data;
auto sub_members = (const MembersType *)member->members_->data;
void * subros_message = nullptr;
size_t array_size = 0;
size_t sub_members_size = sub_members->size_of_;
Expand Down Expand Up @@ -748,8 +746,7 @@ size_t TypeSupport<MembersType>::calculateMaxSerializedSize(
break;
case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE:
{
const MembersType * sub_members =
static_cast<const MembersType *>(member->members_->data);
auto sub_members = static_cast<const MembersType *>(member->members_->data);
current_alignment += calculateMaxSerializedSize(sub_members, current_alignment);
}
break;
Expand Down Expand Up @@ -800,8 +797,7 @@ size_t TypeSupport<MembersType>::calculateMaxSerializedSize(
break;
case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE:
{
const MembersType * sub_members =
static_cast<const MembersType *>(member->members_->data);
auto sub_members = static_cast<const MembersType *>(member->members_->data);
for (size_t index = 0; index < array_size; ++index) {
current_alignment += calculateMaxSerializedSize(sub_members, current_alignment);
}
Expand Down Expand Up @@ -871,7 +867,7 @@ bool TypeSupport<MembersType>::serialize(
assert(data);
assert(payload);

eprosima::fastcdr::Cdr * ser = static_cast<eprosima::fastcdr::Cdr *>(data);
auto ser = static_cast<eprosima::fastcdr::Cdr *>(data);
if (payload->max_size >= ser->getSerializedDataLength()) {
payload->length = static_cast<uint32_t>(ser->getSerializedDataLength());
payload->encapsulation = ser->endianness() ==
Expand All @@ -889,7 +885,7 @@ bool TypeSupport<MembersType>::deserialize(SerializedPayload_t * payload, void *
assert(data);
assert(payload);

eprosima::fastcdr::FastBuffer * buffer = static_cast<eprosima::fastcdr::FastBuffer *>(data);
auto buffer = static_cast<eprosima::fastcdr::FastBuffer *>(data);
buffer->resize(payload->length);
memcpy(buffer->getBuffer(), payload->data, payload->length);
return true;
Expand All @@ -900,7 +896,7 @@ std::function<uint32_t()> TypeSupport<MembersType>::getSerializedSizeProvider(vo
{
assert(data);

eprosima::fastcdr::Cdr * ser = static_cast<eprosima::fastcdr::Cdr *>(data);
auto ser = static_cast<eprosima::fastcdr::Cdr *>(data);
return [ser]() -> uint32_t {return static_cast<uint32_t>(ser->getSerializedDataLength());};
}

Expand Down
10 changes: 5 additions & 5 deletions rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/custom_client_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ClientListener : public eprosima::fastrtps::SubscriberListener
public:
explicit ClientListener(CustomClientInfo * info)
: info_(info), list_has_data_(false),
conditionMutex_(NULL), conditionVariable_(NULL) {}
conditionMutex_(nullptr), conditionVariable_(nullptr) {}


void
Expand All @@ -73,7 +73,7 @@ class ClientListener : public eprosima::fastrtps::SubscriberListener
if (info_->writer_guid_ == response.sample_identity_.writer_guid()) {
std::lock_guard<std::mutex> lock(internalMutex_);

if (conditionMutex_ != NULL) {
if (conditionMutex_ != nullptr) {
std::unique_lock<std::mutex> clock(*conditionMutex_);
list.push_back(response);
// the change to list_has_data_ needs to be mutually exclusive with
Expand All @@ -97,7 +97,7 @@ class ClientListener : public eprosima::fastrtps::SubscriberListener
std::lock_guard<std::mutex> lock(internalMutex_);
CustomClientResponse response;

if (conditionMutex_ != NULL) {
if (conditionMutex_ != nullptr) {
std::unique_lock<std::mutex> clock(*conditionMutex_);
if (!list.empty()) {
response = list.front();
Expand Down Expand Up @@ -127,8 +127,8 @@ class ClientListener : public eprosima::fastrtps::SubscriberListener
detachCondition()
{
std::lock_guard<std::mutex> lock(internalMutex_);
conditionMutex_ = NULL;
conditionVariable_ = NULL;
conditionMutex_ = nullptr;
conditionVariable_ = nullptr;
}

bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ServiceListener : public eprosima::fastrtps::SubscriberListener
public:
explicit ServiceListener(CustomServiceInfo * info)
: info_(info), list_has_data_(false),
conditionMutex_(NULL), conditionVariable_(NULL)
conditionMutex_(nullptr), conditionVariable_(nullptr)
{
(void)info_;
}
Expand All @@ -75,7 +75,7 @@ class ServiceListener : public eprosima::fastrtps::SubscriberListener

std::lock_guard<std::mutex> lock(internalMutex_);

if (conditionMutex_ != NULL) {
if (conditionMutex_ != nullptr) {
std::unique_lock<std::mutex> clock(*conditionMutex_);
list.push_back(request);
// the change to list_has_data_ needs to be mutually exclusive with
Expand All @@ -98,7 +98,7 @@ class ServiceListener : public eprosima::fastrtps::SubscriberListener
std::lock_guard<std::mutex> lock(internalMutex_);
CustomServiceRequest request;

if (conditionMutex_ != NULL) {
if (conditionMutex_ != nullptr) {
std::unique_lock<std::mutex> clock(*conditionMutex_);
if (!list.empty()) {
request = list.front();
Expand Down Expand Up @@ -128,8 +128,8 @@ class ServiceListener : public eprosima::fastrtps::SubscriberListener
detachCondition()
{
std::lock_guard<std::mutex> lock(internalMutex_);
conditionMutex_ = NULL;
conditionVariable_ = NULL;
conditionMutex_ = nullptr;
conditionVariable_ = nullptr;
}

bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SubListener : public eprosima::fastrtps::SubscriberListener
public:
explicit SubListener(CustomSubscriberInfo * info)
: data_(0),
conditionMutex_(NULL), conditionVariable_(NULL)
conditionMutex_(nullptr), conditionVariable_(nullptr)
{
// Field is not used right now
(void)info;
Expand All @@ -58,7 +58,7 @@ class SubListener : public eprosima::fastrtps::SubscriberListener
(void)sub;
std::lock_guard<std::mutex> lock(internalMutex_);

if (conditionMutex_ != NULL) {
if (conditionMutex_ != nullptr) {
std::unique_lock<std::mutex> clock(*conditionMutex_);
// the change to data_ needs to be mutually exclusive with rmw_wait()
// which checks hasData() and decides if wait() needs to be called
Expand All @@ -82,8 +82,8 @@ class SubListener : public eprosima::fastrtps::SubscriberListener
detachCondition()
{
std::lock_guard<std::mutex> lock(internalMutex_);
conditionMutex_ = NULL;
conditionVariable_ = NULL;
conditionMutex_ = nullptr;
conditionVariable_ = nullptr;
}

bool
Expand All @@ -97,7 +97,7 @@ class SubListener : public eprosima::fastrtps::SubscriberListener
{
std::lock_guard<std::mutex> lock(internalMutex_);

if (conditionMutex_ != NULL) {
if (conditionMutex_ != nullptr) {
std::unique_lock<std::mutex> clock(*conditionMutex_);
--data_;
} else {
Expand Down
4 changes: 2 additions & 2 deletions rmw_fastrtps_cpp/src/client_service_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ get_request_ptr(const void * untyped_service_members, const char * typesupport)
untyped_service_members);
}
RMW_SET_ERROR_MSG("Unknown typesupport identifier");
return NULL;
return nullptr;
}

const void *
Expand All @@ -41,5 +41,5 @@ get_response_ptr(const void * untyped_service_members, const char * typesupport)
untyped_service_members);
}
RMW_SET_ERROR_MSG("Unknown typesupport identifier");
return NULL;
return nullptr;
}
4 changes: 2 additions & 2 deletions rmw_fastrtps_cpp/src/client_service_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const void * get_request_ptr(const void * untyped_service_members)
auto service_members = static_cast<const ServiceType *>(untyped_service_members);
if (!service_members) {
RMW_SET_ERROR_MSG("service members handle is null");
return NULL;
return nullptr;
}
return service_members->request_members_;
}
Expand All @@ -36,7 +36,7 @@ const void * get_response_ptr(const void * untyped_service_members)
auto service_members = static_cast<const ServiceType *>(untyped_service_members);
if (!service_members) {
RMW_SET_ERROR_MSG("service members handle is null");
return NULL;
return nullptr;
}
return service_members->response_members_;
}
Expand Down
12 changes: 6 additions & 6 deletions rmw_fastrtps_cpp/src/get_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ eprosima::fastrtps::Publisher *
get_request_publisher(rmw_client_t * client)
{
if (!client) {
return NULL;
return nullptr;
}
if (client->implementation_identifier != eprosima_fastrtps_identifier) {
return NULL;
return nullptr;
}
CustomClientInfo * impl = static_cast<CustomClientInfo *>(client->data);
auto impl = static_cast<CustomClientInfo *>(client->data);
return impl->request_publisher_;
}

eprosima::fastrtps::Subscriber *
get_response_subscriber(rmw_client_t * client)
{
if (!client) {
return NULL;
return nullptr;
}
if (client->implementation_identifier != eprosima_fastrtps_identifier) {
return NULL;
return nullptr;
}
CustomClientInfo * impl = static_cast<CustomClientInfo *>(client->data);
auto impl = static_cast<CustomClientInfo *>(client->data);
return impl->response_subscriber_;
}

Expand Down
6 changes: 3 additions & 3 deletions rmw_fastrtps_cpp/src/get_participant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ eprosima::fastrtps::Participant *
get_participant(rmw_node_t * node)
{
if (!node) {
return NULL;
return nullptr;
}
if (node->implementation_identifier != eprosima_fastrtps_identifier) {
return NULL;
return nullptr;
}
CustomParticipantInfo * impl = static_cast<CustomParticipantInfo *>(node->data);
auto impl = static_cast<CustomParticipantInfo *>(node->data);
return impl->participant;
}

Expand Down
6 changes: 3 additions & 3 deletions rmw_fastrtps_cpp/src/get_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ eprosima::fastrtps::Publisher *
get_publisher(rmw_publisher_t * publisher)
{
if (!publisher) {
return NULL;
return nullptr;
}
if (publisher->implementation_identifier != eprosima_fastrtps_identifier) {
return NULL;
return nullptr;
}
CustomPublisherInfo * impl = static_cast<CustomPublisherInfo *>(publisher->data);
auto impl = static_cast<CustomPublisherInfo *>(publisher->data);
return impl->publisher_;
}

Expand Down
Loading

0 comments on commit 5030f85

Please sign in to comment.