Make sure to always check return values. (#840)
* Make sure to always check return values. Pointed out by clang static analysis, we should always check these return values. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
This commit is contained in:
parent
fd2f427563
commit
1f7baf2ee5
2 changed files with 21 additions and 1 deletions
|
@ -122,7 +122,10 @@ _filter_action_names(
|
||||||
// Cleanup if there is an error
|
// Cleanup if there is an error
|
||||||
if (RCL_RET_OK != ret) {
|
if (RCL_RET_OK != ret) {
|
||||||
rcl_ret_t fini_ret = rcl_names_and_types_fini(action_names_and_types);
|
rcl_ret_t fini_ret = rcl_names_and_types_fini(action_names_and_types);
|
||||||
(void)fini_ret; // Error already set
|
if (RCL_RET_OK != fini_ret) {
|
||||||
|
RCUTILS_SAFE_FWRITE_TO_STDERR(
|
||||||
|
"Freeing names and types failed while handling a previous error. Leaking memory!\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -154,6 +157,10 @@ rcl_action_get_client_names_and_types_by_node(
|
||||||
rcl_ret_t nat_fini_ret = rcl_names_and_types_fini(&topic_names_and_types);
|
rcl_ret_t nat_fini_ret = rcl_names_and_types_fini(&topic_names_and_types);
|
||||||
if (RCL_RET_OK != nat_fini_ret) {
|
if (RCL_RET_OK != nat_fini_ret) {
|
||||||
ret = rcl_names_and_types_fini(action_names_and_types);
|
ret = rcl_names_and_types_fini(action_names_and_types);
|
||||||
|
if (RCL_RET_OK != ret) {
|
||||||
|
RCUTILS_SAFE_FWRITE_TO_STDERR(
|
||||||
|
"Freeing names and types failed while handling a previous error. Leaking memory!\n");
|
||||||
|
}
|
||||||
return nat_fini_ret;
|
return nat_fini_ret;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -185,6 +192,11 @@ rcl_action_get_server_names_and_types_by_node(
|
||||||
rcl_ret_t nat_fini_ret = rcl_names_and_types_fini(&topic_names_and_types);
|
rcl_ret_t nat_fini_ret = rcl_names_and_types_fini(&topic_names_and_types);
|
||||||
if (RCL_RET_OK != nat_fini_ret) {
|
if (RCL_RET_OK != nat_fini_ret) {
|
||||||
ret = rcl_names_and_types_fini(action_names_and_types);
|
ret = rcl_names_and_types_fini(action_names_and_types);
|
||||||
|
if (RCL_RET_OK != ret) {
|
||||||
|
RCUTILS_SAFE_FWRITE_TO_STDERR(
|
||||||
|
"Freeing names and types failed while handling a previous error. Leaking memory!\n");
|
||||||
|
}
|
||||||
|
|
||||||
return nat_fini_ret;
|
return nat_fini_ret;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -211,6 +223,10 @@ rcl_action_get_names_and_types(
|
||||||
rcl_ret_t nat_fini_ret = rcl_names_and_types_fini(&topic_names_and_types);
|
rcl_ret_t nat_fini_ret = rcl_names_and_types_fini(&topic_names_and_types);
|
||||||
if (RCL_RET_OK != nat_fini_ret) {
|
if (RCL_RET_OK != nat_fini_ret) {
|
||||||
ret = rcl_names_and_types_fini(action_names_and_types);
|
ret = rcl_names_and_types_fini(action_names_and_types);
|
||||||
|
if (RCL_RET_OK != ret) {
|
||||||
|
RCUTILS_SET_ERROR_MSG(
|
||||||
|
"Freeing names and types failed while handling a previous error. Leaking memory!\n");
|
||||||
|
}
|
||||||
return nat_fini_ret;
|
return nat_fini_ret;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -234,6 +234,10 @@ rcl_lifecycle_state_machine_init(
|
||||||
// init default state machine might have allocated memory,
|
// init default state machine might have allocated memory,
|
||||||
// so we have to call fini
|
// so we have to call fini
|
||||||
ret = rcl_lifecycle_state_machine_fini(state_machine, node_handle, allocator);
|
ret = rcl_lifecycle_state_machine_fini(state_machine, node_handle, allocator);
|
||||||
|
if (ret != RCL_RET_OK) {
|
||||||
|
RCUTILS_SAFE_FWRITE_TO_STDERR(
|
||||||
|
"Freeing state machine failed while handling a previous error. Leaking memory!\n");
|
||||||
|
}
|
||||||
return RCL_RET_ERROR;
|
return RCL_RET_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue