Skip to content

Commit

Permalink
Merge branch 'master' into namespace_node_secure_root
Browse files Browse the repository at this point in the history
  • Loading branch information
ruffsl authored Nov 5, 2018
2 parents d15b1c1 + 1120b2f commit 67a6a54
Show file tree
Hide file tree
Showing 68 changed files with 1,959 additions and 1,426 deletions.
3 changes: 0 additions & 3 deletions rcl/include/rcl/arguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,6 @@ rcl_remove_ros_arguments(
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[in] error_alloc an alocator to use if an error occurs.
* This allocator is not used to allocate args_out.
* \param[in] args The structure to be copied.
* Its allocator is used to copy memory into the new structure.
* \param[out] args_out A zero-initialized arguments structure to be copied into.
Expand All @@ -256,7 +254,6 @@ RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_arguments_copy(
rcl_allocator_t error_alloc,
const rcl_arguments_t * args,
rcl_arguments_t * args_out);

Expand Down
6 changes: 2 additions & 4 deletions rcl/include/rcl/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ RCL_WARN_UNUSED
rcl_client_t
rcl_get_zero_initialized_client(void);


/// Initialize a rcl client.
/**
* After calling this function on a rcl_client_t, it can be used to send
Expand Down Expand Up @@ -378,7 +377,7 @@ rcl_client_get_rmw_handle(const rcl_client_t * client);

/// Check that the client is valid.
/**
* The bool returned is `false` if client is invalid
* The bool returned is `false` if client is invalid.
* The bool returned is `true` otherwise.
* In the case where `false` is to be returned, an error message is set.
* This function cannot fail.
Expand All @@ -392,12 +391,11 @@ rcl_client_get_rmw_handle(const rcl_client_t * client);
* Lock-Free | Yes
*
* \param[in] client pointer to the rcl client
* \param[in] error_msg_allocator a valid allocator or `NULL`
* \return `true` if `client` is valid, otherwise `false`
*/
RCL_PUBLIC
bool
rcl_client_is_valid(const rcl_client_t * client, rcl_allocator_t * error_msg_allocator);
rcl_client_is_valid(const rcl_client_t * client);

#ifdef __cplusplus
}
Expand Down
32 changes: 10 additions & 22 deletions rcl/include/rcl/error_handling.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,32 @@
#include "rcutils/error_handling.h"

/// The error handling in RCL is just an alias to the error handling in rcutils.
/**
* Allocators given to functions in rcl are passed along to the error handling
* on a "best effort" basis.
* In some situations, like when NULL is passed for the allocator or something
* else that contains it, the allocator is not available to be passed to the
* RCL_SET_ERROR_MSG macro.
* In these cases, the default allocator rcl_get_default_allocator() is used.
* Since these are considered fatal errors, as opposed to errors that might
* occur during normal runtime, is should be okay to use the default allocator.
*/

typedef rcutils_error_state_t rcl_error_state_t;
typedef rcutils_error_string_t rcl_error_string_t;

#define rcl_error_state_copy rcutils_error_state_copy

#define rcl_error_state_fini rcutils_error_state_fini
#define rcl_initialize_error_handling_thread_local_storage \
rcutils_initialize_error_handling_thread_local_storage

#define rcl_set_error_state rcutils_set_error_state

#define RCL_CHECK_ARGUMENT_FOR_NULL(argument, error_return_type, allocator) \
RCUTILS_CHECK_ARGUMENT_FOR_NULL(argument, error_return_type, allocator)
#define RCL_CHECK_ARGUMENT_FOR_NULL(argument, error_return_type) \
RCUTILS_CHECK_ARGUMENT_FOR_NULL(argument, error_return_type)

#define RCL_CHECK_FOR_NULL_WITH_MSG(value, msg, error_statement, allocator) \
RCUTILS_CHECK_FOR_NULL_WITH_MSG(value, msg, error_statement, allocator)
#define RCL_CHECK_FOR_NULL_WITH_MSG(value, msg, error_statement) \
RCUTILS_CHECK_FOR_NULL_WITH_MSG(value, msg, error_statement)

#define RCL_SET_ERROR_MSG(msg, allocator) RCUTILS_SET_ERROR_MSG(msg, allocator)
#define RCL_SET_ERROR_MSG(msg) RCUTILS_SET_ERROR_MSG(msg)

#define RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(allocator, fmt_str, ...) \
RCUTILS_SET_ERROR_MSG_WITH_FORMAT_STRING(allocator, fmt_str, __VA_ARGS__)
#define RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(fmt_str, ...) \
RCUTILS_SET_ERROR_MSG_WITH_FORMAT_STRING(fmt_str, __VA_ARGS__)

#define rcl_error_is_set rcutils_error_is_set

#define rcl_get_error_state rcutils_get_error_state

#define rcl_get_error_string rcutils_get_error_string

#define rcl_get_error_string_safe rcutils_get_error_string_safe

#define rcl_reset_error rcutils_reset_error

#endif // RCL__ERROR_HANDLING_H_
6 changes: 1 addition & 5 deletions rcl/include/rcl/lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,23 @@ typedef enum rcl_lexeme_t
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes [1]
* Allocates Memory | No
* Thread-Safe | Yes
* Uses Atomics | No
* Lock-Free | Yes
* <i>[1] Only allocates if an argument is invalid or an internal bug is detected.</i>
*
* \param[in] text The string to analyze.
* \param[in] allocator An allocator to use if an error occurs.
* \param[out] lexeme The type of lexeme found in the string.
* \param[out] length The length of text in the string that constitutes the found lexeme.
* \return `RCL_RET_OK` if analysis is successful regardless whether a valid lexeme is found, or
* \return `RCL_RET_INVALID_ARGUMENT` if any function arguments are invalid, or
* \return `RCL_RET_BAD_ALLOC` if allocating memory failed, or
* \return `RCL_RET_ERROR` if an internal bug is detected.
*/
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_lexer_analyze(
const char * text,
rcl_allocator_t allocator,
rcl_lexeme_t * lexeme,
size_t * length);

Expand Down
12 changes: 2 additions & 10 deletions rcl/include/rcl/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ rcl_node_get_default_options(void);
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[in] error_alloc an alocator to use if an error occurs.
* This allocator is not used to allocate the output.
* \param[in] options The structure to be copied.
* Its allocator is used to copy memory into the new structure.
* \param[out] options_out An options structure containing default values.
Expand All @@ -234,18 +232,13 @@ RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_node_options_copy(
rcl_allocator_t error_alloc,
const rcl_node_options_t * options,
rcl_node_options_t * options_out);

/// Return `true` if the node is valid, else `false`.
/**
* Also return `false` if the node pointer is `NULL` or the allocator is invalid.
*
* The allocator needs to either be a valid allocator or `NULL`, in which case
* the default allocator will be used.
* The allocator is used when allocation is needed for an error message.
*
* A node is invalid if:
* - the implementation is `NULL` (rcl_node_init not called or failed)
* - rcl_shutdown has been called since the node has been initialized
Expand All @@ -256,7 +249,7 @@ rcl_node_options_copy(
* Consider:
*
* ```c
* assert(rcl_node_is_valid(node, NULL)); // <-- thread 1
* assert(rcl_node_is_valid(node)); // <-- thread 1
* rcl_shutdown(); // <-- thread 2
* // use node as if valid // <-- thread 1
* ```
Expand All @@ -275,12 +268,11 @@ rcl_node_options_copy(
* <i>[1] if `atomic_is_lock_free()` returns true for `atomic_uint_least64_t`</i>
*
* \param[in] node rcl_node_t to be validated
* \param[in] error_msg_allocator a valid allocator or `NULL`
* \return `true` if the node and allocator are valid, otherwise `false`.
*/
RCL_PUBLIC
bool
rcl_node_is_valid(const rcl_node_t * node, rcl_allocator_t * error_msg_allocator);
rcl_node_is_valid(const rcl_node_t * node);

/// Return the name of the node.
/**
Expand Down
8 changes: 2 additions & 6 deletions rcl/include/rcl/publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,7 @@ rcl_publisher_get_rmw_handle(const rcl_publisher_t * publisher);
/**
* The bool returned is `false` if `publisher` is invalid.
* The bool returned is `true` otherwise.
* In the case where `false` is to be returned, an
* error message is set.
* In the case where `false` is to be returned, an error message is set.
* This function cannot fail.
*
* <hr>
Expand All @@ -391,14 +390,11 @@ rcl_publisher_get_rmw_handle(const rcl_publisher_t * publisher);
* Lock-Free | Yes
*
* \param[in] publisher pointer to the rcl publisher
* \param[in] error_msg_allocator a valid allocator or `NULL`
* \return `true` if `publisher` is valid, otherwise `false`
*/
RCL_PUBLIC
bool
rcl_publisher_is_valid(
const rcl_publisher_t * publisher,
rcl_allocator_t * error_msg_allocator);
rcl_publisher_is_valid(const rcl_publisher_t * publisher);

#ifdef __cplusplus
}
Expand Down
6 changes: 2 additions & 4 deletions rcl/include/rcl/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,7 @@ rcl_service_get_rmw_handle(const rcl_service_t * service);
/**
* The bool returned is `false` if `service` is invalid.
* The bool returned is `true` otherwise.
* In the case where `false` is to be returned, an
* error message is set.
* In the case where `false` is to be returned, an error message is set.
* This function cannot fail.
*
* <hr>
Expand All @@ -404,12 +403,11 @@ rcl_service_get_rmw_handle(const rcl_service_t * service);
* Lock-Free | Yes
*
* \param[in] service pointer to the rcl service
* \param[in] error_msg_allocator a valid allocator or `NULL`
* \return `true` if `service` is valid, otherwise `false`
*/
RCL_PUBLIC
bool
rcl_service_is_valid(const rcl_service_t * service, rcl_allocator_t * error_msg_allocator);
rcl_service_is_valid(const rcl_service_t * service);

#ifdef __cplusplus
}
Expand Down
8 changes: 2 additions & 6 deletions rcl/include/rcl/subscription.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,7 @@ rcl_subscription_get_rmw_handle(const rcl_subscription_t * subscription);
/**
* The bool returned is `false` if `subscription` is invalid.
* The bool returned is `true` otherwise.
* In the case where `false` is to be returned, an
* error message is set.
* In the case where `false` is to be returned, an error message is set.
* This function cannot fail.
*
* <hr>
Expand All @@ -401,14 +400,11 @@ rcl_subscription_get_rmw_handle(const rcl_subscription_t * subscription);
* Lock-Free | Yes
*
* \param[in] subscription pointer to the rcl subscription
* \param[in] error_msg_allocator a valid allocator or `NULL`
* \return `true` if `subscription` is valid, otherwise `false`
*/
RCL_PUBLIC
bool
rcl_subscription_is_valid(
const rcl_subscription_t * subscription,
rcl_allocator_t * error_msg_allocator);
rcl_subscription_is_valid(const rcl_subscription_t * subscription);

#ifdef __cplusplus
}
Expand Down
Loading

0 comments on commit 67a6a54

Please sign in to comment.