From 8cb2c024c4625e2fe2f0b107a865faffcd4bb770 Mon Sep 17 00:00:00 2001 From: Ed Tanous Date: Wed, 27 Mar 2024 16:31:46 -0700 Subject: Fix moves/forward Clang has new checks for std::move/std::forward correctness, which catches quite a few "wrong" things where we were making copies of callback handlers. Unfortunately, the lambda syntax of callback{std::forward(callback)} in a capture confuses it, so change usages to callback = std::forward(callback) to be consistent. Tested: Redfish service validator passes. Change-Id: I7a111ec00cf78ecb7d5f5b102c786c1c14d74384 Signed-off-by: Ed Tanous --- include/async_resolve.hpp | 2 +- include/dbus_privileges.hpp | 4 ++-- include/dbus_utility.hpp | 2 +- include/google/google_service_root.hpp | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/async_resolve.hpp b/include/async_resolve.hpp index 805fbad124..798c3e8964 100644 --- a/include/async_resolve.hpp +++ b/include/async_resolve.hpp @@ -83,7 +83,7 @@ class Resolver uint64_t flag = 0; crow::connections::systemBus->async_method_call( [host{std::string(host)}, portNum, - handler{std::forward(handler)}]( + handler = std::forward(handler)]( const boost::system::error_code& ec, const std::vector< std::tuple>>& resp, diff --git a/include/dbus_privileges.hpp b/include/dbus_privileges.hpp index b2bb1e3b70..a58f9bebd0 100644 --- a/include/dbus_privileges.hpp +++ b/include/dbus_privileges.hpp @@ -109,7 +109,7 @@ inline bool template void afterGetUserInfo(Request& req, const std::shared_ptr& asyncResp, - BaseRule& rule, CallbackFn&& callback, + BaseRule& rule, CallbackFn callback, const boost::system::error_code& ec, const dbus::utility::DBusPropertiesMap& userInfoMap) { @@ -151,7 +151,7 @@ void validatePrivilege(Request& req, std::string username = req.session->username; crow::connections::systemBus->async_method_call( [req{std::move(req)}, asyncResp, &rule, - callback(std::forward(callback))]( + callback = std::forward(callback)]( const boost::system::error_code& ec, const dbus::utility::DBusPropertiesMap& userInfoMap) mutable { afterGetUserInfo(req, asyncResp, rule, diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp index 933d733f96..c06ba9eae6 100644 --- a/include/dbus_utility.hpp +++ b/include/dbus_utility.hpp @@ -147,7 +147,7 @@ template inline void checkDbusPathExists(const std::string& path, Callback&& callback) { crow::connections::systemBus->async_method_call( - [callback{std::forward(callback)}]( + [callback = std::forward(callback)]( const boost::system::error_code& ec, const dbus::utility::MapperGetObject& objectNames) { callback(!ec && !objectNames.empty()); diff --git a/include/google/google_service_root.hpp b/include/google/google_service_root.hpp index 9dd2405738..00c5e36736 100644 --- a/include/google/google_service_root.hpp +++ b/include/google/google_service_root.hpp @@ -104,8 +104,7 @@ inline void resolveRoT(const std::string& command, "xyz.openbmc_project.Control.Hoth"}; dbus::utility::getSubTree( "/xyz/openbmc_project", 0, hothIfaces, - [command, asyncResp, rotId, - entityHandler{std::forward(entityHandler)}]( + [command, asyncResp, rotId, entityHandler{std::move(entityHandler)}]( const boost::system::error_code& ec, const dbus::utility::MapperGetSubTreeResponse& subtree) { hothGetSubtreeCallback(command, asyncResp, rotId, entityHandler, ec, -- cgit v1.2.3