From: Kefu Chai Date: Wed, 28 Apr 2021 12:13:48 +0000 (+0800) Subject: rgw/rgw_rest_sts: return local variable w/o std::move() X-Git-Tag: v17.1.0~2128^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F41063%2Fhead;p=ceph.git rgw/rgw_rest_sts: return local variable w/o std::move() in C++17, the C++ standard ensures that the return value in this case can be optimized with copy elision, adding std::move() is not necessary, and prevents copy elision from happening. this change also silences the warning of: ../src/rgw/rgw_rest_sts.cc: In member function 'std::unique_ptr rgw::auth::sts::WebTokenEngine::get_provider(const DoutPrefixProvider*, const string&, const string&) const': ../src/rgw/rgw_rest_sts.cc:92:19: warning: moving a local object in a return statement prevents copy elision [-Wpessimizing-move] 92 | return std::move(provider); | ~~~~~~~~~^~~~~~~~~~ ../src/rgw/rgw_rest_sts.cc:92:19: note: remove 'std::move' call Signed-off-by: Kefu Chai --- diff --git a/src/rgw/rgw_rest_sts.cc b/src/rgw/rgw_rest_sts.cc index 986afefdc70e..790d59c360c0 100644 --- a/src/rgw/rgw_rest_sts.cc +++ b/src/rgw/rgw_rest_sts.cc @@ -89,7 +89,7 @@ WebTokenEngine::get_provider(const DoutPrefixProvider *dpp, const string& role_a if (ret < 0) { return nullptr; } - return std::move(provider); + return provider; } bool