Skip to content

Commit 6c10f94

Browse files
authored
use maybe_unused attribute for the portability. (#2758)
Signed-off-by: Tomoya Fujita <[email protected]>
1 parent 9c493c4 commit 6c10f94

38 files changed

+138
-227
lines changed

rclcpp/include/rclcpp/allocator/allocator_deleter.hpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,17 @@ class AllocatorDeleter
6969
};
7070

7171
template<typename Alloc, typename T, typename D>
72-
void set_allocator_for_deleter(D * deleter, Alloc * alloc)
72+
void set_allocator_for_deleter([[maybe_unused]] D * deleter, [[maybe_unused]] Alloc * alloc)
7373
{
74-
(void) alloc;
75-
(void) deleter;
7674
throw std::runtime_error("Reached unexpected template specialization");
7775
}
7876

7977
template<typename T, typename U>
80-
void set_allocator_for_deleter(std::default_delete<T> * deleter, std::allocator<U> * alloc)
78+
void set_allocator_for_deleter(
79+
[[maybe_unused]] std::default_delete<T> * deleter,
80+
[[maybe_unused]] std::allocator<U> * alloc)
8181
{
82-
(void) deleter;
83-
(void) alloc;
82+
// This function is intentionally left empty.
8483
}
8584

8685
template<typename Alloc, typename T>

rclcpp/include/rclcpp/event_handler.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,8 @@ class EventHandler : public EventHandlerBase
293293
}
294294

295295
std::shared_ptr<void>
296-
take_data_by_entity_id(size_t id) override
296+
take_data_by_entity_id([[maybe_unused]] size_t id) override
297297
{
298-
(void)id;
299298
return take_data();
300299
}
301300

rclcpp/include/rclcpp/experimental/subscription_intra_process_base.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ class SubscriptionIntraProcessBase : public rclcpp::Waitable
7979
take_data() override = 0;
8080

8181
std::shared_ptr<void>
82-
take_data_by_entity_id(size_t id) override
82+
take_data_by_entity_id([[maybe_unused]] size_t id) override
8383
{
84-
(void)id;
8584
return take_data();
8685
}
8786

rclcpp/include/rclcpp/experimental/subscription_intra_process_buffer.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,8 @@ class SubscriptionIntraProcessBuffer : public SubscriptionROSMsgIntraProcessBuff
110110
}
111111

112112
bool
113-
is_ready(const rcl_wait_set_t & wait_set) override
113+
is_ready([[maybe_unused]] const rcl_wait_set_t & wait_set) override
114114
{
115-
(void) wait_set;
116115
return buffer_->has_data();
117116
}
118117

rclcpp/include/rclcpp/publisher.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,9 @@ class Publisher : public PublisherBase
143143
post_init_setup(
144144
rclcpp::node_interfaces::NodeBaseInterface * node_base,
145145
const std::string & topic,
146-
const rclcpp::QoS & qos,
147-
const rclcpp::PublisherOptionsWithAllocator<AllocatorT> & options)
146+
[[maybe_unused]] const rclcpp::QoS & qos,
147+
[[maybe_unused]] const rclcpp::PublisherOptionsWithAllocator<AllocatorT> & options)
148148
{
149-
(void)qos;
150-
(void)options;
151-
152149
// If needed, setup intra process communication.
153150
if (rclcpp::detail::resolve_use_intra_process(options_, *node_base)) {
154151
auto context = node_base->get_context();

rclcpp/include/rclcpp/strategies/message_pool_memory_strategy.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ class MessagePoolMemoryStrategy
114114
* all references.
115115
* \param[in] msg Shared pointer to the message to return.
116116
*/
117-
void return_message(std::shared_ptr<MessageT> & msg)
117+
void return_message([[maybe_unused]] std::shared_ptr<MessageT> & msg)
118118
{
119-
(void)msg;
119+
// This function is intentionally left empty.
120120
}
121121

122122
protected:

rclcpp/include/rclcpp/subscription.hpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,11 @@ class Subscription : public SubscriptionBase
209209
/// Called after construction to continue setup that requires shared_from_this().
210210
void
211211
post_init_setup(
212-
rclcpp::node_interfaces::NodeBaseInterface * node_base,
213-
const rclcpp::QoS & qos,
214-
const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT> & options)
212+
[[maybe_unused]] rclcpp::node_interfaces::NodeBaseInterface * node_base,
213+
[[maybe_unused]] const rclcpp::QoS & qos,
214+
[[maybe_unused]] const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT> & options)
215215
{
216-
(void)node_base;
217-
(void)qos;
218-
(void)options;
216+
// This function is intentionally left empty.
219217
}
220218

221219
/// Take the next message from the inter-process subscription.
@@ -422,20 +420,17 @@ class Subscription : public SubscriptionBase
422420

423421
void
424422
return_dynamic_message(
425-
rclcpp::dynamic_typesupport::DynamicMessage::SharedPtr & message) override
423+
[[maybe_unused]] rclcpp::dynamic_typesupport::DynamicMessage::SharedPtr & message) override
426424
{
427-
(void) message;
428425
throw rclcpp::exceptions::UnimplementedError(
429426
"return_dynamic_message is not implemented for Subscription");
430427
}
431428

432429
void
433430
handle_dynamic_message(
434-
const rclcpp::dynamic_typesupport::DynamicMessage::SharedPtr & message,
435-
const rclcpp::MessageInfo & message_info) override
431+
[[maybe_unused]] const rclcpp::dynamic_typesupport::DynamicMessage::SharedPtr & message,
432+
[[maybe_unused]] const rclcpp::MessageInfo & message_info) override
436433
{
437-
(void) message;
438-
(void) message_info;
439434
throw rclcpp::exceptions::UnimplementedError(
440435
"handle_dynamic_message is not implemented for Subscription");
441436
}

rclcpp/src/rclcpp/detail/rmw_implementation_specific_publisher_payload.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ namespace detail
2323

2424
void
2525
RMWImplementationSpecificPublisherPayload::modify_rmw_publisher_options(
26-
rmw_publisher_options_t & rmw_publisher_options) const
26+
[[maybe_unused]] rmw_publisher_options_t & rmw_publisher_options) const
2727
{
2828
// By default, do not mutate the rmw publisher options.
29-
(void)rmw_publisher_options;
3029
}
3130

3231
} // namespace detail

rclcpp/src/rclcpp/detail/rmw_implementation_specific_subscription_payload.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ namespace detail
2323

2424
void
2525
RMWImplementationSpecificSubscriptionPayload::modify_rmw_subscription_options(
26-
rmw_subscription_options_t & rmw_subscription_options) const
26+
[[maybe_unused]] rmw_subscription_options_t & rmw_subscription_options) const
2727
{
2828
// By default, do not mutate the rmw subscription options.
29-
(void)rmw_subscription_options;
3029
}
3130

3231
} // namespace detail

rclcpp/src/rclcpp/detail/utilities.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ namespace detail
3131

3232
std::vector<std::string>
3333
get_unparsed_ros_arguments(
34-
int argc, char const * const * argv,
34+
[[maybe_unused]] int argc, char const * const * argv,
3535
rcl_arguments_t * arguments,
3636
rcl_allocator_t allocator)
3737
{
38-
(void)argc;
3938
std::vector<std::string> unparsed_ros_arguments;
4039
int unparsed_ros_args_count = rcl_arguments_get_count_unparsed_ros(arguments);
4140
if (unparsed_ros_args_count > 0) {

0 commit comments

Comments
 (0)