Skip to content
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
5 changes: 5 additions & 0 deletions rmw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ add_library(${PROJECT_NAME} ${rmw_sources})
target_include_directories(${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")

if(BUILD_TESTING AND NOT RCUTILS_DISABLE_FAULT_INJECTION)
target_compile_definitions(${PROJECT_NAME} PUBLIC RCUTILS_ENABLE_FAULT_INJECTION)
endif()

ament_target_dependencies(${PROJECT_NAME}
"rcutils"
"rosidl_runtime_c"
Expand Down
6 changes: 6 additions & 0 deletions rmw/src/names_and_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "rmw/names_and_types.h"

#include "rcutils/logging_macros.h"
#include "rcutils/macros.h"
#include "rcutils/types/string_array.h"
#include "rmw/error_handling.h"
#include "rmw/convert_rcutils_ret_to_rmw_ret.h"
Expand All @@ -34,6 +35,8 @@ rmw_get_zero_initialized_names_and_types(void)
rmw_ret_t
rmw_names_and_types_check_zero(rmw_names_and_types_t * names_and_types)
{
RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_INVALID_ARGUMENT);

if (!names_and_types) {
RMW_SET_ERROR_MSG("names_and_types is null");
return RMW_RET_INVALID_ARGUMENT;
Expand All @@ -55,6 +58,9 @@ rmw_names_and_types_init(
size_t size,
rcutils_allocator_t * allocator)
{
RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_INVALID_ARGUMENT);
RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_BAD_ALLOC);

if (!allocator) {
RMW_SET_ERROR_MSG("allocator is null");
return RMW_RET_INVALID_ARGUMENT;
Expand Down
18 changes: 18 additions & 0 deletions rmw/src/topic_endpoint_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "rmw/topic_endpoint_info.h"

#include "rcutils/macros.h"
#include "rcutils/strdup.h"
#include "rmw/error_handling.h"
#include "rmw/types.h"
Expand Down Expand Up @@ -71,6 +72,8 @@ rmw_topic_endpoint_info_fini(
rmw_topic_endpoint_info_t * topic_endpoint_info,
rcutils_allocator_t * allocator)
{
RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_INVALID_ARGUMENT);

if (!topic_endpoint_info) {
RMW_SET_ERROR_MSG("topic_endpoint_info is null");
return RMW_RET_INVALID_ARGUMENT;
Expand Down Expand Up @@ -105,6 +108,9 @@ _rmw_topic_endpoint_info_copy_str(
const char * str,
rcutils_allocator_t * allocator)
{
RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_INVALID_ARGUMENT);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be able of returning BAD_ALLOC as well? I don't know why the output of rcutils_strdup is not checked there

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with the remaining part of the API receiving an allocator

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #269 to add the new API and added a second RCUTILS_CAN_RETURN_WITH_ERROR_OF here.

RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_BAD_ALLOC);

if (!str) {
RMW_SET_ERROR_MSG("str is null");
return RMW_RET_INVALID_ARGUMENT;
Expand Down Expand Up @@ -134,6 +140,8 @@ rmw_topic_endpoint_info_set_topic_type(
const char * topic_type,
rcutils_allocator_t * allocator)
{
RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_INVALID_ARGUMENT);

if (!topic_endpoint_info) {
RMW_SET_ERROR_MSG("topic_endpoint_info is null");
return RMW_RET_INVALID_ARGUMENT;
Expand All @@ -147,6 +155,8 @@ rmw_topic_endpoint_info_set_node_name(
const char * node_name,
rcutils_allocator_t * allocator)
{
RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_INVALID_ARGUMENT);

if (!topic_endpoint_info) {
RMW_SET_ERROR_MSG("topic_endpoint_info is null");
return RMW_RET_INVALID_ARGUMENT;
Expand All @@ -160,6 +170,8 @@ rmw_topic_endpoint_info_set_node_namespace(
const char * node_namespace,
rcutils_allocator_t * allocator)
{
RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_INVALID_ARGUMENT);

if (!topic_endpoint_info) {
RMW_SET_ERROR_MSG("topic_endpoint_info is null");
return RMW_RET_INVALID_ARGUMENT;
Expand All @@ -175,6 +187,8 @@ rmw_topic_endpoint_info_set_endpoint_type(
rmw_topic_endpoint_info_t * topic_endpoint_info,
rmw_endpoint_type_t type)
{
RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_INVALID_ARGUMENT);

if (!topic_endpoint_info) {
RMW_SET_ERROR_MSG("topic_endpoint_info is null");
return RMW_RET_INVALID_ARGUMENT;
Expand All @@ -191,6 +205,8 @@ rmw_topic_endpoint_info_set_gid(
const uint8_t gid[],
size_t size)
{
RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_INVALID_ARGUMENT);

if (!topic_endpoint_info) {
RMW_SET_ERROR_MSG("topic_endpoint_info is null");
return RMW_RET_INVALID_ARGUMENT;
Expand All @@ -209,6 +225,8 @@ rmw_topic_endpoint_info_set_qos_profile(
rmw_topic_endpoint_info_t * topic_endpoint_info,
const rmw_qos_profile_t * qos_profile)
{
RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_INVALID_ARGUMENT);

if (!topic_endpoint_info) {
RMW_SET_ERROR_MSG("topic_endpoint_info is null");
return RMW_RET_INVALID_ARGUMENT;
Expand Down