Warn about unused result of add_on_set_parameters_callback (#1238) (#1244)

If the user doesn't retain a reference to the returned shared pointer there will be zero references and their callback will be unregistered.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
This commit is contained in:
Jacob Perron 2020-08-03 12:10:27 -07:00 committed by GitHub
parent 6ea67a4e9f
commit ce5de8757d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 0 deletions

View file

@ -26,6 +26,8 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "rcutils/macros.h"
#include "rcl/error_handling.h" #include "rcl/error_handling.h"
#include "rcl/node.h" #include "rcl/node.h"
@ -812,6 +814,7 @@ public:
* \throws std::bad_alloc if the allocation of the OnSetParametersCallbackHandle fails. * \throws std::bad_alloc if the allocation of the OnSetParametersCallbackHandle fails.
*/ */
RCLCPP_PUBLIC RCLCPP_PUBLIC
RCUTILS_WARN_UNUSED
OnSetParametersCallbackHandle::SharedPtr OnSetParametersCallbackHandle::SharedPtr
add_on_set_parameters_callback(OnParametersSetCallbackType callback); add_on_set_parameters_callback(OnParametersSetCallbackType callback);

View file

@ -21,6 +21,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "rcutils/macros.h"
#include "rcl_interfaces/msg/list_parameters_result.hpp" #include "rcl_interfaces/msg/list_parameters_result.hpp"
#include "rcl_interfaces/msg/parameter_descriptor.hpp" #include "rcl_interfaces/msg/parameter_descriptor.hpp"
#include "rcl_interfaces/msg/parameter_event.hpp" #include "rcl_interfaces/msg/parameter_event.hpp"
@ -160,6 +162,7 @@ public:
list_parameters(const std::vector<std::string> & prefixes, uint64_t depth) const override; list_parameters(const std::vector<std::string> & prefixes, uint64_t depth) const override;
RCLCPP_PUBLIC RCLCPP_PUBLIC
RCUTILS_WARN_UNUSED
OnSetParametersCallbackHandle::SharedPtr OnSetParametersCallbackHandle::SharedPtr
add_on_set_parameters_callback(OnParametersSetCallbackType callback) override; add_on_set_parameters_callback(OnParametersSetCallbackType callback) override;

View file

@ -42,6 +42,8 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "rcutils/macros.h"
#include "rcl/error_handling.h" #include "rcl/error_handling.h"
#include "rcl/node.h" #include "rcl/node.h"
@ -456,6 +458,7 @@ public:
* \sa rclcpp::Node::add_on_set_parameters_callback * \sa rclcpp::Node::add_on_set_parameters_callback
*/ */
RCLCPP_LIFECYCLE_PUBLIC RCLCPP_LIFECYCLE_PUBLIC
RCUTILS_WARN_UNUSED
rclcpp_lifecycle::LifecycleNode::OnSetParametersCallbackHandle::SharedPtr rclcpp_lifecycle::LifecycleNode::OnSetParametersCallbackHandle::SharedPtr
add_on_set_parameters_callback( add_on_set_parameters_callback(
rclcpp_lifecycle::LifecycleNode::OnParametersSetCallbackType callback); rclcpp_lifecycle::LifecycleNode::OnParametersSetCallbackType callback);