Skip to content

Commit

Permalink
Updated error returns on rmw_take_serialized and with_message_info (#435
Browse files Browse the repository at this point in the history
)

Signed-off-by: lobotuerk <jtlorente@ekumenlabs.com>
  • Loading branch information
Lobotuerk authored Sep 18, 2020
1 parent 94b1784 commit 0d75ee1
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions rmw_fastrtps_shared_cpp/src/rmw_take.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ _take_serialized_message(
(void) allocation;
*taken = false;

if (subscription->implementation_identifier != identifier) {
RMW_SET_ERROR_MSG("publisher handle not from this implementation");
return RMW_RET_ERROR;
}
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
subscription handle,
subscription->implementation_identifier, identifier,
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION)

CustomSubscriberInfo * info = static_cast<CustomSubscriberInfo *>(subscription->data);
RCUTILS_CHECK_FOR_NULL_WITH_MSG(info, "custom subscriber info is null", return RMW_RET_ERROR);
Expand Down Expand Up @@ -312,11 +312,14 @@ __rmw_take_serialized_message(
bool * taken,
rmw_subscription_allocation_t * allocation)
{
RCUTILS_CHECK_FOR_NULL_WITH_MSG(
subscription, "subscription pointer is null", return RMW_RET_ERROR);
RCUTILS_CHECK_FOR_NULL_WITH_MSG(
serialized_message, "ros_message pointer is null", return RMW_RET_ERROR);
RCUTILS_CHECK_FOR_NULL_WITH_MSG(taken, "boolean flag for taken is null", return RMW_RET_ERROR);
RMW_CHECK_ARGUMENT_FOR_NULL(
subscription, RMW_RET_INVALID_ARGUMENT);

RMW_CHECK_ARGUMENT_FOR_NULL(
serialized_message, RMW_RET_INVALID_ARGUMENT);

RMW_CHECK_ARGUMENT_FOR_NULL(
taken, RMW_RET_INVALID_ARGUMENT);

return _take_serialized_message(
identifier, subscription, serialized_message, taken, nullptr, allocation);
Expand All @@ -331,13 +334,17 @@ __rmw_take_serialized_message_with_info(
rmw_message_info_t * message_info,
rmw_subscription_allocation_t * allocation)
{
RCUTILS_CHECK_FOR_NULL_WITH_MSG(
subscription, "subscription pointer is null", return RMW_RET_ERROR);
RCUTILS_CHECK_FOR_NULL_WITH_MSG(
serialized_message, "ros_message pointer is null", return RMW_RET_ERROR);
RCUTILS_CHECK_FOR_NULL_WITH_MSG(taken, "boolean flag for taken is null", return RMW_RET_ERROR);
RCUTILS_CHECK_FOR_NULL_WITH_MSG(
message_info, "message info pointer is null", return RMW_RET_ERROR);
RMW_CHECK_ARGUMENT_FOR_NULL(
subscription, RMW_RET_INVALID_ARGUMENT);

RMW_CHECK_ARGUMENT_FOR_NULL(
serialized_message, RMW_RET_INVALID_ARGUMENT);

RMW_CHECK_ARGUMENT_FOR_NULL(
taken, RMW_RET_INVALID_ARGUMENT);

RMW_CHECK_ARGUMENT_FOR_NULL(
message_info, RMW_RET_INVALID_ARGUMENT);

return _take_serialized_message(
identifier, subscription, serialized_message, taken, message_info, allocation);
Expand Down

0 comments on commit 0d75ee1

Please sign in to comment.