From: Suyash Dongre Date: Wed, 28 Aug 2024 19:28:57 +0000 (+0530) Subject: forwarding reference passed to std::move() X-Git-Tag: v20.0.0~1131^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F59490%2Fhead;p=ceph.git 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 --- diff --git a/src/rgw/rgw_aio.cc b/src/rgw/rgw_aio.cc index a239171f104d7..7fba58ad63ff7 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();