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

Update gid API return codes. #440

Merged
merged 1 commit into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
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
40 changes: 15 additions & 25 deletions rmw_fastrtps_shared_cpp/src/rmw_compare_gids_equal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

#include "fastrtps/rtps/common/Guid.h"

#include "rmw/rmw.h"
#include "rmw/error_handling.h"
#include "rmw/impl/cpp/macros.hpp"
#include "rmw/rmw.h"
#include "rmw/types.h"

#include "rmw_fastrtps_shared_cpp/rmw_common.hpp"
Expand All @@ -29,30 +30,19 @@ __rmw_compare_gids_equal(
const rmw_gid_t * gid2,
bool * result)
{
if (!gid1) {
RMW_SET_ERROR_MSG("gid1 is null");
return RMW_RET_ERROR;
}

if (gid1->implementation_identifier != identifier) {
RMW_SET_ERROR_MSG("guid1 handle not from this implementation");
return RMW_RET_ERROR;
}

if (!gid2) {
RMW_SET_ERROR_MSG("gid2 is null");
return RMW_RET_ERROR;
}

if (gid2->implementation_identifier != identifier) {
RMW_SET_ERROR_MSG("gid2 handle not from this implementation");
return RMW_RET_ERROR;
}

if (!result) {
RMW_SET_ERROR_MSG("result 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,
identifier,
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,
identifier,
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
RMW_CHECK_ARGUMENT_FOR_NULL(result, RMW_RET_INVALID_ARGUMENT);

*result =
memcmp(gid1->data, gid2->data, sizeof(eprosima::fastrtps::rtps::GUID_t)) == 0;
Expand Down
28 changes: 8 additions & 20 deletions rmw_fastrtps_shared_cpp/src/rmw_get_gid_for_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

#include "rmw/error_handling.h"
#include "rmw/impl/cpp/macros.hpp"
#include "rmw/rmw.h"
#include "rmw/types.h"

Expand All @@ -27,28 +28,15 @@ __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;
}

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

if (!gid) {
RMW_SET_ERROR_MSG("gid is null");
return RMW_RET_ERROR;
}
RMW_CHECK_ARGUMENT_FOR_NULL(publisher, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
publisher,
publisher->implementation_identifier,
identifier,
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
RMW_CHECK_ARGUMENT_FOR_NULL(gid, RMW_RET_INVALID_ARGUMENT);

auto info = static_cast<const CustomPublisherInfo *>(publisher->data);

if (!info) {
Lobotuerk marked this conversation as resolved.
Show resolved Hide resolved
RMW_SET_ERROR_MSG("publisher info handle is null");
return RMW_RET_ERROR;
}

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