Enable clang-tidy forward reference checks

Clang-13 adds new checks we can turn on, which find quite a few errors.

Tested: Code compiles

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I74b780760014c898cc440b37aea640b33e91c439
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 049f9a6..8735178 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -931,7 +931,8 @@
                           CallbackFunc&& callback)
 {
     crow::connections::systemBus->async_method_call(
-        [ethifaceId{std::string{ethifaceId}}, callback{std::move(callback)}](
+        [ethifaceId{std::string{ethifaceId}},
+         callback{std::forward<CallbackFunc>(callback)}](
             const boost::system::error_code errorCode,
             dbus::utility::ManagedObjectType& resp) {
             EthernetInterfaceData ethData{};
@@ -982,7 +983,7 @@
 void getEthernetIfaceList(CallbackFunc&& callback)
 {
     crow::connections::systemBus->async_method_call(
-        [callback{std::move(callback)}](
+        [callback{std::forward<CallbackFunc>(callback)}](
             const boost::system::error_code errorCode,
             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 8faae3f..db9b5aa 100644
--- a/redfish-core/lib/hypervisor_system.hpp
+++ b/redfish-core/lib/hypervisor_system.hpp
@@ -317,7 +317,8 @@
                             CallbackFunc&& callback)
 {
     crow::connections::systemBus->async_method_call(
-        [ethIfaceId{std::string{ethIfaceId}}, callback{std::move(callback)}](
+        [ethIfaceId{std::string{ethIfaceId}},
+         callback{std::forward<CallbackFunc>(callback)}](
             const boost::system::error_code error,
             const dbus::utility::ManagedObjectType& resp) {
             EthernetInterfaceData ethData{};
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index c19bef5..41b14f8 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -82,7 +82,7 @@
 void getEthernetIfaceData(CallbackFunc&& callback)
 {
     crow::connections::systemBus->async_method_call(
-        [callback{std::move(callback)}](
+        [callback{std::forward<CallbackFunc>(callback)}](
             const boost::system::error_code errorCode,
             const dbus::utility::ManagedObjectType& dbusData) {
             std::vector<std::string> ntpServers;
diff --git a/redfish-core/lib/redfish_util.hpp b/redfish-core/lib/redfish_util.hpp
index b631f91..881bf1a 100644
--- a/redfish-core/lib/redfish_util.hpp
+++ b/redfish-core/lib/redfish_util.hpp
@@ -94,9 +94,9 @@
                           CallbackFunc&& callback)
 {
     crow::connections::systemBus->async_method_call(
-        [serviceName,
-         callback{std::move(callback)}](const boost::system::error_code ec,
-                                        const std::vector<UnitStruct>& r) {
+        [serviceName, callback{std::forward<CallbackFunc>(callback)}](
+            const boost::system::error_code ec,
+            const std::vector<UnitStruct>& r) {
             if (ec)
             {
                 BMCWEB_LOG_ERROR << ec;
@@ -174,7 +174,7 @@
         std::vector<std::tuple<std::string, std::string>>>(
         *crow::connections::systemBus, "org.freedesktop.systemd1", socketPath,
         "org.freedesktop.systemd1.Socket", "Listen",
-        [callback{std::move(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 de0a828..6d10bb7 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -327,7 +327,8 @@
         "xyz.openbmc_project.Sensor.Value"};
 
     // Response handler for parsing objects subtree
-    auto respHandler = [callback{std::move(callback)}, sensorsAsyncResp,
+    auto respHandler = [callback{std::forward<Callback>(callback)},
+                        sensorsAsyncResp,
                         sensorNames](const boost::system::error_code ec,
                                      const GetSubTreeType& subtree) {
         BMCWEB_LOG_DEBUG << "getObjectsWithConnection resp_handler enter";
@@ -466,7 +467,7 @@
         "xyz.openbmc_project.Inventory.Item.Chassis"};
 
     auto respHandler =
-        [callback{std::move(callback)},
+        [callback{std::forward<Callback>(callback)},
          asyncResp](const boost::system::error_code ec,
                     const std::vector<std::string>& chassisPaths) mutable {
             BMCWEB_LOG_DEBUG << "getValidChassisPath respHandler enter";
@@ -520,7 +521,8 @@
     const std::array<const char*, 2> interfaces = {
         "xyz.openbmc_project.Inventory.Item.Board",
         "xyz.openbmc_project.Inventory.Item.Chassis"};
-    auto respHandler = [callback{std::move(callback)}, sensorsAsyncResp](
+    auto respHandler = [callback{std::forward<Callback>(callback)},
+                        sensorsAsyncResp](
                            const boost::system::error_code ec,
                            const std::vector<std::string>& chassisPaths) {
         BMCWEB_LOG_DEBUG << "getChassis respHandler enter";
@@ -596,7 +598,8 @@
         sdbusplus::asio::getProperty<std::vector<std::string>>(
             *crow::connections::systemBus, "xyz.openbmc_project.ObjectMapper",
             sensorPath, "xyz.openbmc_project.Association", "endpoints",
-            [sensorsAsyncResp, callback{std::move(callback)}](
+            [sensorsAsyncResp,
+             callback{std::forward<const Callback>(callback)}](
                 const boost::system::error_code& e,
                 const std::vector<std::string>& nodeSensorList) {
                 if (e)
@@ -653,7 +656,7 @@
         "org.freedesktop.DBus.ObjectManager"};
 
     // Response handler for GetSubTree DBus method
-    auto respHandler = [callback{std::move(callback)},
+    auto respHandler = [callback{std::forward<Callback>(callback)},
                         sensorsAsyncResp](const boost::system::error_code ec,
                                           const GetSubTreeType& subtree) {
         BMCWEB_LOG_DEBUG << "getObjectManagerPaths respHandler enter";
@@ -1602,7 +1605,8 @@
 
         // Response handler for GetManagedObjects
         auto respHandler = [sensorsAsyncResp, inventoryItems, invConnections,
-                            objectMgrPaths, callback{std::move(callback)},
+                            objectMgrPaths,
+                            callback{std::forward<Callback>(callback)},
                             invConnectionsIndex](
                                const boost::system::error_code ec,
                                dbus::utility::ManagedObjectType& resp) {
@@ -1691,7 +1695,8 @@
         "xyz.openbmc_project.State.Decorator.OperationalStatus"};
 
     // Response handler for parsing output from GetSubTree
-    auto respHandler = [callback{std::move(callback)}, sensorsAsyncResp,
+    auto respHandler = [callback{std::forward<Callback>(callback)},
+                        sensorsAsyncResp,
                         inventoryItems](const boost::system::error_code ec,
                                         const GetSubTreeType& subtree) {
         BMCWEB_LOG_DEBUG << "getInventoryItemsConnections respHandler enter";
@@ -1773,7 +1778,8 @@
     BMCWEB_LOG_DEBUG << "getInventoryItemAssociations enter";
 
     // Response handler for GetManagedObjects
-    auto respHandler = [callback{std::move(callback)}, sensorsAsyncResp,
+    auto respHandler = [callback{std::forward<Callback>(callback)},
+                        sensorsAsyncResp,
                         sensorNames](const boost::system::error_code ec,
                                      dbus::utility::ManagedObjectType& resp) {
         BMCWEB_LOG_DEBUG << "getInventoryItemAssociations respHandler enter";
@@ -1955,7 +1961,7 @@
         // Response handler for Get State property
         auto respHandler =
             [sensorsAsyncResp, inventoryItems, ledConnections, ledPath,
-             callback{std::move(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)
@@ -2044,7 +2050,8 @@
         "xyz.openbmc_project.Led.Physical"};
 
     // Response handler for parsing output from GetSubTree
-    auto respHandler = [callback{std::move(callback)}, sensorsAsyncResp,
+    auto respHandler = [callback{std::forward<Callback>(callback)},
+                        sensorsAsyncResp,
                         inventoryItems](const boost::system::error_code ec,
                                         const GetSubTreeType& subtree) {
         BMCWEB_LOG_DEBUG << "getInventoryLeds respHandler enter";
@@ -2141,7 +2148,7 @@
 
     // Response handler for Get DeratingFactor property
     auto respHandler = [sensorsAsyncResp, inventoryItems,
-                        callback{std::move(callback)}](
+                        callback{std::forward<Callback>(callback)}](
                            const boost::system::error_code ec,
                            const uint32_t value) {
         BMCWEB_LOG_DEBUG << "getPowerSupplyAttributesData respHandler enter";
@@ -2221,7 +2228,8 @@
         "xyz.openbmc_project.Control.PowerSupplyAttributes"};
 
     // Response handler for parsing output from GetSubTree
-    auto respHandler = [callback{std::move(callback)}, sensorsAsyncResp,
+    auto respHandler = [callback{std::forward<Callback>(callback)},
+                        sensorsAsyncResp,
                         inventoryItems](const boost::system::error_code ec,
                                         const GetSubTreeType& subtree) {
         BMCWEB_LOG_DEBUG << "getPowerSupplyAttributes respHandler enter";
@@ -2313,12 +2321,13 @@
 {
     BMCWEB_LOG_DEBUG << "getInventoryItems enter";
     auto getInventoryItemAssociationsCb =
-        [sensorsAsyncResp, objectMgrPaths, callback{std::move(callback)}](
+        [sensorsAsyncResp, objectMgrPaths,
+         callback{std::forward<Callback>(callback)}](
             std::shared_ptr<std::vector<InventoryItem>> inventoryItems) {
             BMCWEB_LOG_DEBUG << "getInventoryItemAssociationsCb enter";
             auto getInventoryItemsConnectionsCb =
                 [sensorsAsyncResp, inventoryItems, objectMgrPaths,
-                 callback{std::move(callback)}](
+                 callback{std::forward<const Callback>(callback)}](
                     std::shared_ptr<boost::container::flat_set<std::string>>
                         invConnections) {
                     BMCWEB_LOG_DEBUG << "getInventoryItemsConnectionsCb enter";