]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
forwarding reference passed to std::move() 59490/head
authorSuyash Dongre <suyashd999@gmail.com>
Wed, 28 Aug 2024 19:28:57 +0000 (00:58 +0530)
committerSuyash Dongre <suyashd999@gmail.com>
Wed, 28 Aug 2024 19:28:57 +0000 (00:58 +0530)
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<Op>

Signed-off-by: Suyash Dongre <suyashd999@gmail.com>
src/rgw/rgw_aio.cc

index a239171f104d77ff4963c1539fab5ff1d529d4fb..7fba58ad63ff7372e38f078b74c7171a8cc200ab 100644 (file)
@@ -52,7 +52,7 @@ void cb(librados::completion_t, void* arg) {
 
 template <typename Op>
 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>(op), trace_ctx] (Aio* aio, AioResult& r) mutable {
       constexpr bool read = std::is_same_v<std::decay_t<Op>, 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 <typename Op>
 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>(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();