Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated error returns on rmw_take #432

Merged
merged 6 commits into from
Sep 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 45 additions & 31 deletions rmw_fastrtps_shared_cpp/src/rmw_take.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ _take(
(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,
Lobotuerk marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -102,10 +102,10 @@ _take_sequence(
bool taken_flag = false;
rmw_ret_t ret = RMW_RET_OK;

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 @@ -175,11 +175,14 @@ __rmw_take(
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(
ros_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(
ros_message, RMW_RET_INVALID_ARGUMENT);

RMW_CHECK_ARGUMENT_FOR_NULL(
taken, RMW_RET_INVALID_ARGUMENT);
Lobotuerk marked this conversation as resolved.
Show resolved Hide resolved

return _take(identifier, subscription, ros_message, taken, nullptr, allocation);
}
Expand All @@ -194,24 +197,31 @@ __rmw_take_sequence(
size_t * taken,
rmw_subscription_allocation_t * allocation)
{
RCUTILS_CHECK_FOR_NULL_WITH_MSG(
subscription, "subscription pointer is null", return RMW_RET_INVALID_ARGUMENT);
RCUTILS_CHECK_FOR_NULL_WITH_MSG(
message_sequence, "message_sequence pointer is null", return RMW_RET_INVALID_ARGUMENT);
RCUTILS_CHECK_FOR_NULL_WITH_MSG(
message_info_sequence, "message_info_sequence pointer is null",
return RMW_RET_INVALID_ARGUMENT);
RCUTILS_CHECK_FOR_NULL_WITH_MSG(
taken, "size_t flag for count is null", return RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_ARGUMENT_FOR_NULL(
subscription, RMW_RET_INVALID_ARGUMENT);

RMW_CHECK_ARGUMENT_FOR_NULL(
message_sequence, RMW_RET_INVALID_ARGUMENT);

RMW_CHECK_ARGUMENT_FOR_NULL(
message_info_sequence, RMW_RET_INVALID_ARGUMENT);

RMW_CHECK_ARGUMENT_FOR_NULL(
taken, RMW_RET_INVALID_ARGUMENT);

if (0u == count) {
RMW_SET_ERROR_MSG("count cannot be 0");
return RMW_RET_INVALID_ARGUMENT;
}

if (count > message_sequence->capacity) {
RMW_SET_ERROR_MSG("Insufficient capacity in message_sequence");
return RMW_RET_ERROR;
return RMW_RET_INVALID_ARGUMENT;
}

if (count > message_info_sequence->capacity) {
RMW_SET_ERROR_MSG("Insufficient capacity in message_info_sequence");
return RMW_RET_ERROR;
return RMW_RET_INVALID_ARGUMENT;
}
Lobotuerk marked this conversation as resolved.
Show resolved Hide resolved

return _take_sequence(
Expand All @@ -228,13 +238,17 @@ __rmw_take_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(
ros_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(
message_info, RMW_RET_INVALID_ARGUMENT);

RMW_CHECK_ARGUMENT_FOR_NULL(
taken, RMW_RET_INVALID_ARGUMENT);

RMW_CHECK_ARGUMENT_FOR_NULL(
ros_message, RMW_RET_INVALID_ARGUMENT);

RMW_CHECK_ARGUMENT_FOR_NULL(
subscription, RMW_RET_INVALID_ARGUMENT);

return _take(identifier, subscription, ros_message, taken, message_info, allocation);
}
Expand Down