Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Update gid API return codes. (#461)
Browse files Browse the repository at this point in the history
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
  • Loading branch information
hidmic authored Sep 22, 2020
1 parent a53c868 commit 7bcd03e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 37 deletions.
28 changes: 6 additions & 22 deletions rmw_connext_cpp/src/rmw_compare_gid_equals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,22 @@ extern "C"
rmw_ret_t
rmw_compare_gids_equal(const rmw_gid_t * gid1, const rmw_gid_t * gid2, bool * result)
{
if (!gid1) {
RMW_SET_ERROR_MSG("gid1 is null");
return RMW_RET_ERROR;
}
RMW_CHECK_ARGUMENT_FOR_NULL(gid1, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
gid1,
gid1->implementation_identifier,
rti_connext_identifier,
return RMW_RET_ERROR)
if (!gid2) {
RMW_SET_ERROR_MSG("gid2 is null");
return RMW_RET_ERROR;
}
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
RMW_CHECK_ARGUMENT_FOR_NULL(gid2, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
gid2,
gid2->implementation_identifier,
rti_connext_identifier,
return RMW_RET_ERROR)
if (!result) {
RMW_SET_ERROR_MSG("result is null");
return RMW_RET_ERROR;
}
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
RMW_CHECK_ARGUMENT_FOR_NULL(result, RMW_RET_INVALID_ARGUMENT);

auto detail1 = reinterpret_cast<const ConnextPublisherGID *>(gid1->data);
if (!detail1) {
RMW_SET_ERROR_MSG("gid1 is invalid");
return RMW_RET_ERROR;
}
auto detail2 = reinterpret_cast<const ConnextPublisherGID *>(gid2->data);
if (!detail2) {
RMW_SET_ERROR_MSG("gid2 is invalid");
return RMW_RET_ERROR;
}
auto matches =
DDS_InstanceHandle_equals(&detail1->publication_handle, &detail2->publication_handle);
*result = (matches == DDS::BOOLEAN_TRUE);
Expand Down
19 changes: 4 additions & 15 deletions rmw_connext_cpp/src/rmw_get_gid_for_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,16 @@ extern "C"
rmw_ret_t
rmw_get_gid_for_publisher(const rmw_publisher_t * publisher, rmw_gid_t * gid)
{
if (!publisher) {
RMW_SET_ERROR_MSG("publisher is null");
return RMW_RET_ERROR;
}
RMW_CHECK_ARGUMENT_FOR_NULL(publisher, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
publisher handle,
publisher,
publisher->implementation_identifier,
rti_connext_identifier,
return RMW_RET_ERROR)
if (!gid) {
RMW_SET_ERROR_MSG("gid is null");
return RMW_RET_ERROR;
}
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
RMW_CHECK_ARGUMENT_FOR_NULL(gid, RMW_RET_INVALID_ARGUMENT);

const ConnextStaticPublisherInfo * publisher_info =
static_cast<const ConnextStaticPublisherInfo *>(publisher->data);
if (!publisher_info) {
RMW_SET_ERROR_MSG("publisher info handle is null");
return RMW_RET_ERROR;
}

*gid = publisher_info->publisher_gid;
return RMW_RET_OK;
}
Expand Down

0 comments on commit 7bcd03e

Please sign in to comment.