summaryrefslogtreecommitdiff
path: root/redfish-core
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2024-03-28 02:31:46 +0300
committerEd Tanous <ed@tanous.net>2024-04-07 21:09:42 +0300
commit8cb2c024c4625e2fe2f0b107a865faffcd4bb770 (patch)
tree252d85214747ab3b9ae784b08b0f07ec31ea0c13 /redfish-core
parentdce4d230c52978fc258ee3bc31117389d9c25388 (diff)
downloadbmcweb-8cb2c024c4625e2fe2f0b107a865faffcd4bb770.tar.xz
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>(callback)} in a capture confuses it, so change usages to callback = std::forward<Callback>(callback) to be consistent. Tested: Redfish service validator passes. Change-Id: I7a111ec00cf78ecb7d5f5b102c786c1c14d74384 Signed-off-by: Ed Tanous <ed@tanous.net>
Diffstat (limited to 'redfish-core')
-rw-r--r--redfish-core/include/utils/chassis_utils.hpp2
-rw-r--r--redfish-core/lib/account_service.hpp2
-rw-r--r--redfish-core/lib/ethernet.hpp4
-rw-r--r--redfish-core/lib/hypervisor_system.hpp2
-rw-r--r--redfish-core/lib/log_services.hpp2
-rw-r--r--redfish-core/lib/network_protocol.hpp2
-rw-r--r--redfish-core/lib/pcie.hpp2
-rw-r--r--redfish-core/lib/redfish_util.hpp6
-rw-r--r--redfish-core/lib/sensors.hpp33
-rw-r--r--redfish-core/lib/virtual_media.hpp6
10 files changed, 31 insertions, 30 deletions
diff --git a/redfish-core/include/utils/chassis_utils.hpp b/redfish-core/include/utils/chassis_utils.hpp
index 6d1f8d1572..410a28990d 100644
--- a/redfish-core/include/utils/chassis_utils.hpp
+++ b/redfish-core/include/utils/chassis_utils.hpp
@@ -29,7 +29,7 @@ void getValidChassisPath(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
// Get the Chassis Collection
dbus::utility::getSubTreePaths(
"/xyz/openbmc_project/inventory", 0, interfaces,
- [callback{std::forward<Callback>(callback)}, asyncResp,
+ [callback = std::forward<Callback>(callback), asyncResp,
chassisId](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse&
chassisPaths) mutable {
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index 3a1869f095..47fb58d902 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -513,7 +513,7 @@ inline void getLDAPConfigData(const std::string& ldapType,
dbus::utility::getDbusObject(
ldapConfigObjectName, interfaces,
- [callback,
+ [callback = std::forward<CallbackFunc>(callback),
ldapType](const boost::system::error_code& ec,
const dbus::utility::MapperGetObject& resp) mutable {
if (ec || resp.empty())
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 2d538d7f1f..876bc2edb4 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -1111,7 +1111,7 @@ void getEthernetIfaceData(const std::string& ethifaceId,
dbus::utility::getManagedObjects(
"xyz.openbmc_project.Network", path,
[ethifaceId{std::string{ethifaceId}},
- callback{std::forward<CallbackFunc>(callback)}](
+ callback = std::forward<CallbackFunc>(callback)](
const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& resp) mutable {
EthernetInterfaceData ethData{};
@@ -1166,7 +1166,7 @@ void getEthernetIfaceList(CallbackFunc&& callback)
sdbusplus::message::object_path path("/xyz/openbmc_project/network");
dbus::utility::getManagedObjects(
"xyz.openbmc_project.Network", path,
- [callback{std::forward<CallbackFunc>(callback)}](
+ [callback = std::forward<CallbackFunc>(callback)](
const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& resp) {
// Callback requires vector<string> to retrieve all available
diff --git a/redfish-core/lib/hypervisor_system.hpp b/redfish-core/lib/hypervisor_system.hpp
index 1a3d6cbb54..2b3714bae4 100644
--- a/redfish-core/lib/hypervisor_system.hpp
+++ b/redfish-core/lib/hypervisor_system.hpp
@@ -315,7 +315,7 @@ void getHypervisorIfaceData(const std::string& ethIfaceId,
dbus::utility::getManagedObjects(
"xyz.openbmc_project.Settings", path,
[ethIfaceId{std::string{ethIfaceId}},
- callback{std::forward<CallbackFunc>(callback)}](
+ callback = std::forward<CallbackFunc>(callback)](
const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& resp) mutable {
EthernetInterfaceData ethData{};
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 6ea165d799..f27785d78f 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -960,7 +960,7 @@ inline void createDumpTaskCallback(
}
crow::connections::systemBus->async_method_call(
- [asyncResp, payload, createdObjPath,
+ [asyncResp, payload = std::move(payload), createdObjPath,
dumpEntryPath{std::move(dumpEntryPath)},
dumpId](const boost::system::error_code& ec,
const std::string& introspectXml) {
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index 31fc5afc04..d864e222d6 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -101,7 +101,7 @@ void getEthernetIfaceData(CallbackFunc&& callback)
sdbusplus::message::object_path path("/xyz/openbmc_project/network");
dbus::utility::getManagedObjects(
"xyz.openbmc_project.Network", path,
- [callback{std::forward<CallbackFunc>(callback)}](
+ [callback = std::forward<CallbackFunc>(callback)](
const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& dbusData) {
std::vector<std::string> ntpServers;
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index e8da2195a8..9392916c47 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -221,7 +221,7 @@ inline void getPCIeDeviceSlotPath(
dbus::utility::getAssociatedSubTreePaths(
associationPath, sdbusplus::message::object_path(inventoryPath), 0,
pcieSlotInterface,
- [callback, asyncResp, pcieDevicePath](
+ [callback = std::move(callback), asyncResp, pcieDevicePath](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse& endpoints) {
if (ec)
diff --git a/redfish-core/lib/redfish_util.hpp b/redfish-core/lib/redfish_util.hpp
index 7a96481782..5d8c0e6670 100644
--- a/redfish-core/lib/redfish_util.hpp
+++ b/redfish-core/lib/redfish_util.hpp
@@ -69,7 +69,7 @@ void getMainChassisId(std::shared_ptr<bmcweb::AsyncResp> asyncResp,
"xyz.openbmc_project.Inventory.Item.Chassis"};
dbus::utility::getSubTree(
"/xyz/openbmc_project/inventory", 0, interfaces,
- [callback,
+ [callback = std::forward<CallbackFunc>(callback),
asyncResp](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
@@ -104,7 +104,7 @@ void getPortStatusAndPath(
CallbackFunc&& callback)
{
crow::connections::systemBus->async_method_call(
- [protocolToDBus, callback{std::forward<CallbackFunc>(callback)}](
+ [protocolToDBus, callback = std::forward<CallbackFunc>(callback)](
const boost::system::error_code& ec,
const std::vector<UnitStruct>& r) {
std::vector<std::tuple<std::string, std::string, bool>> socketData;
@@ -211,7 +211,7 @@ void getPortNumber(const std::string& socketPath, CallbackFunc&& callback)
std::vector<std::tuple<std::string, std::string>>>(
*crow::connections::systemBus, "org.freedesktop.systemd1", socketPath,
"org.freedesktop.systemd1.Socket", "Listen",
- [callback{std::forward<CallbackFunc>(callback)}](
+ [callback = std::forward<CallbackFunc>(callback)](
const boost::system::error_code& ec,
const std::vector<std::tuple<std::string, std::string>>& resp) {
if (ec)
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 8506185e8d..75eaa7cde1 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -361,7 +361,7 @@ void getObjectsWithConnection(
// Make call to ObjectMapper to find all sensors objects
dbus::utility::getSubTree(
path, 2, interfaces,
- [callback{std::forward<Callback>(callback)}, sensorsAsyncResp,
+ [callback = std::forward<Callback>(callback), sensorsAsyncResp,
sensorNames](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
// Response handler for parsing objects subtree
@@ -423,9 +423,10 @@ void getConnections(std::shared_ptr<SensorsAsyncResp> sensorsAsyncResp,
Callback&& callback)
{
auto objectsWithConnectionCb =
- [callback](const std::set<std::string>& connections,
- const std::set<std::pair<std::string, std::string>>&
- /*objectsWithConnection*/) { callback(connections); };
+ [callback = std::forward<Callback>(callback)](
+ const std::set<std::string>& connections,
+ const std::set<std::pair<std::string, std::string>>&
+ /*objectsWithConnection*/) { callback(connections); };
getObjectsWithConnection(sensorsAsyncResp, sensorNames,
std::move(objectsWithConnectionCb));
}
@@ -524,7 +525,7 @@ void getChassis(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
// Get the Chassis Collection
dbus::utility::getSubTreePaths(
"/xyz/openbmc_project/inventory", 0, interfaces,
- [callback{std::forward<Callback>(callback)}, asyncResp,
+ [callback = std::forward<Callback>(callback), asyncResp,
chassisIdStr{std::string(chassisId)},
chassisSubNode{std::string(chassisSubNode)}, sensorTypes](
const boost::system::error_code& ec,
@@ -567,7 +568,7 @@ void getChassis(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
dbus::utility::getAssociationEndPoints(
sensorPath,
[asyncResp, chassisSubNode, sensorTypes,
- callback{std::forward<const Callback>(callback)}](
+ callback = std::forward<const Callback>(callback)](
const boost::system::error_code& ec2,
const dbus::utility::MapperEndPoints& nodeSensorList) {
if (ec2)
@@ -1474,7 +1475,7 @@ static void getInventoryItemsData(
dbus::utility::getManagedObjects(
invConnection, path,
[sensorsAsyncResp, inventoryItems, invConnections,
- callback{std::forward<Callback>(callback)}, invConnectionsIndex](
+ callback = std::forward<Callback>(callback), invConnectionsIndex](
const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& resp) {
BMCWEB_LOG_DEBUG("getInventoryItemsData respHandler enter");
@@ -1550,7 +1551,7 @@ static void getInventoryItemsConnections(
// Make call to ObjectMapper to find all inventory items
dbus::utility::getSubTree(
path, 0, interfaces,
- [callback{std::forward<Callback>(callback)}, sensorsAsyncResp,
+ [callback = std::forward<Callback>(callback), sensorsAsyncResp,
inventoryItems](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
@@ -1626,7 +1627,7 @@ static void getInventoryItemAssociations(
sdbusplus::message::object_path path("/");
dbus::utility::getManagedObjects(
"xyz.openbmc_project.ObjectMapper", path,
- [callback{std::forward<Callback>(callback)}, sensorsAsyncResp,
+ [callback = std::forward<Callback>(callback), sensorsAsyncResp,
sensorNames](const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& resp) {
BMCWEB_LOG_DEBUG("getInventoryItemAssociations respHandler enter");
@@ -1795,7 +1796,7 @@ void getInventoryLedData(
// Response handler for Get State property
auto respHandler =
[sensorsAsyncResp, inventoryItems, ledConnections, ledPath,
- callback{std::forward<Callback>(callback)}, ledConnectionsIndex](
+ callback = std::forward<Callback>(callback), ledConnectionsIndex](
const boost::system::error_code& ec, const std::string& state) {
BMCWEB_LOG_DEBUG("getInventoryLedData respHandler enter");
if (ec)
@@ -1886,7 +1887,7 @@ void getInventoryLeds(
// Make call to ObjectMapper to find all inventory items
dbus::utility::getSubTree(
path, 0, interfaces,
- [callback{std::forward<Callback>(callback)}, sensorsAsyncResp,
+ [callback = std::forward<Callback>(callback), sensorsAsyncResp,
inventoryItems](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
@@ -1976,7 +1977,7 @@ void getPowerSupplyAttributesData(
// Response handler for Get DeratingFactor property
auto respHandler = [sensorsAsyncResp, inventoryItems,
- callback{std::forward<Callback>(callback)}](
+ callback = std::forward<Callback>(callback)](
const boost::system::error_code& ec,
const uint32_t value) {
BMCWEB_LOG_DEBUG("getPowerSupplyAttributesData respHandler enter");
@@ -2058,7 +2059,7 @@ void getPowerSupplyAttributes(
// Make call to ObjectMapper to find the PowerSupplyAttributes service
dbus::utility::getSubTree(
"/xyz/openbmc_project", 0, interfaces,
- [callback{std::forward<Callback>(callback)}, sensorsAsyncResp,
+ [callback = std::forward<Callback>(callback), sensorsAsyncResp,
inventoryItems](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
@@ -2142,12 +2143,12 @@ static void
{
BMCWEB_LOG_DEBUG("getInventoryItems enter");
auto getInventoryItemAssociationsCb =
- [sensorsAsyncResp, callback{std::forward<Callback>(callback)}](
+ [sensorsAsyncResp, callback = std::forward<Callback>(callback)](
std::shared_ptr<std::vector<InventoryItem>> inventoryItems) {
BMCWEB_LOG_DEBUG("getInventoryItemAssociationsCb enter");
auto getInventoryItemsConnectionsCb =
[sensorsAsyncResp, inventoryItems,
- callback{std::forward<const Callback>(callback)}](
+ callback = std::forward<const Callback>(callback)](
std::shared_ptr<std::set<std::string>> invConnections) {
BMCWEB_LOG_DEBUG("getInventoryItemsConnectionsCb enter");
auto getInventoryItemsDataCb = [sensorsAsyncResp, inventoryItems,
@@ -2778,7 +2779,7 @@ inline void retrieveUriToDbusMap(const std::string& chassis,
auto asyncResp = std::make_shared<bmcweb::AsyncResp>();
auto callback = [asyncResp,
- mapCompleteCb{std::forward<Callback>(mapComplete)}](
+ mapCompleteCb = std::forward<Callback>(mapComplete)](
const boost::beast::http::status status,
const std::map<std::string, std::string>& uriToDbus) {
mapCompleteCb(status, uriToDbus);
diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
index 9784d37724..b03f323620 100644
--- a/redfish-core/lib/virtual_media.hpp
+++ b/redfish-core/lib/virtual_media.hpp
@@ -98,9 +98,9 @@ inline void
sdbusplus::message::object_path path("/xyz/openbmc_project/VirtualMedia");
dbus::utility::getManagedObjects(
service, path,
- [service, resName, asyncResp,
- handler](const boost::system::error_code& ec,
- const dbus::utility::ManagedObjectType& subtree) {
+ [service, resName, asyncResp, handler = std::move(handler)](
+ const boost::system::error_code& ec,
+ const dbus::utility::ManagedObjectType& subtree) {
if (ec)
{
BMCWEB_LOG_DEBUG("DBUS response error");