From 81fb5ae24328e33fbfe49599b8826f43a72d01a0 Mon Sep 17 00:00:00 2001 From: Suyash Dongre Date: Thu, 29 Aug 2024 00:58:57 +0530 Subject: [PATCH] forwarding reference passed to std::move() Fixes: https://tracker.ceph.com/issues/67781 clang-tidy original warning: warning: forwarding reference passed to std::move(), which may unexpectedly cause lvalues to be moved; use std::forward() instead [bugprone-move-forwarding-reference] return [ctx = std::move(ctx), op = std::move(op), trace_ctx] (Aio* aio, AioResult& r) mutable { ^~~~~~~~~ std::forward Signed-off-by: Suyash Dongre --- src/rgw/rgw_aio.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_aio.cc b/src/rgw/rgw_aio.cc index a239171f104..7fba58ad63f 100644 --- a/src/rgw/rgw_aio.cc +++ b/src/rgw/rgw_aio.cc @@ -52,7 +52,7 @@ void cb(librados::completion_t, void* arg) { template Aio::OpFunc aio_abstract(librados::IoCtx ctx, Op&& op, jspan_context* trace_ctx = nullptr) { - return [ctx = std::move(ctx), op = std::move(op), trace_ctx] (Aio* aio, AioResult& r) mutable { + return [ctx = std::move(ctx), op = std::forward(op), trace_ctx] (Aio* aio, AioResult& r) mutable { constexpr bool read = std::is_same_v, librados::ObjectReadOperation>; // use placement new to construct the rados state inside of user_data auto s = new (&r.user_data) state(aio, ctx, r); @@ -92,7 +92,7 @@ template Aio::OpFunc aio_abstract(librados::IoCtx ctx, Op&& op, boost::asio::yield_context yield, jspan_context* trace_ctx) { - return [ctx = std::move(ctx), op = std::move(op), yield, trace_ctx] (Aio* aio, AioResult& r) mutable { + return [ctx = std::move(ctx), op = std::forward(op), yield, trace_ctx] (Aio* aio, AioResult& r) mutable { // arrange for the completion Handler to run on the yield_context's strand // executor so it can safely call back into Aio without locking auto ex = yield.get_executor(); -- 2.39.5