Take boost error_code by reference

By convention, we should be following boost here, and passing error_code
by reference, not by value.  This makes our code consistent, and removes
the need for a copy in some cases.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Id42ea4a90b6685a84818b87d1506c11256b3b9ae
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 06729fd..59abd4f 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -181,7 +181,7 @@
                                 const std::string& path)
 {
 
-    auto getCpuPresenceState = [aResp](const boost::system::error_code ec3,
+    auto getCpuPresenceState = [aResp](const boost::system::error_code& ec3,
                                        const bool cpuPresenceCheck) {
         if (ec3)
         {
@@ -191,7 +191,7 @@
         modifyCpuPresenceState(aResp, cpuPresenceCheck);
     };
 
-    auto getCpuFunctionalState = [aResp](const boost::system::error_code ec3,
+    auto getCpuFunctionalState = [aResp](const boost::system::error_code& ec3,
                                          const bool cpuFunctionalCheck) {
         if (ec3)
         {
@@ -217,7 +217,7 @@
         *crow::connections::systemBus, service, path,
         "xyz.openbmc_project.Inventory.Item.Cpu",
         [aResp, service,
-         path](const boost::system::error_code ec2,
+         path](const boost::system::error_code& ec2,
                const dbus::utility::DBusPropertiesMap& properties) {
         if (ec2)
         {
@@ -300,7 +300,7 @@
                             *crow::connections::systemBus, connection.first,
                             path, "xyz.openbmc_project.Inventory.Item.Dimm",
                             [aResp, service{connection.first},
-                             path](const boost::system::error_code ec2,
+                             path](const boost::system::error_code& ec2,
                                    const dbus::utility::DBusPropertiesMap&
                                        properties) {
                             if (ec2)
@@ -321,8 +321,9 @@
                                     "xyz.openbmc_project.State."
                                     "Decorator.OperationalStatus",
                                     "Functional",
-                                    [aResp](const boost::system::error_code ec3,
-                                            bool dimmState) {
+                                    [aResp](
+                                        const boost::system::error_code& ec3,
+                                        bool dimmState) {
                                     if (ec3)
                                     {
                                         BMCWEB_LOG_ERROR
@@ -396,7 +397,7 @@
                         sdbusplus::asio::getAllProperties(
                             *crow::connections::systemBus, connection.first,
                             path, "xyz.openbmc_project.Common.UUID",
-                            [aResp](const boost::system::error_code ec3,
+                            [aResp](const boost::system::error_code& ec3,
                                     const dbus::utility::DBusPropertiesMap&
                                         properties) {
                             if (ec3)
@@ -444,7 +445,7 @@
                             *crow::connections::systemBus, connection.first,
                             path,
                             "xyz.openbmc_project.Inventory.Decorator.Asset",
-                            [aResp](const boost::system::error_code ec2,
+                            [aResp](const boost::system::error_code& ec2,
                                     const dbus::utility::DBusPropertiesMap&
                                         propertiesList) {
                             if (ec2)
@@ -516,7 +517,7 @@
                             "xyz.openbmc_project.Inventory.Decorator."
                             "AssetTag",
                             "AssetTag",
-                            [aResp](const boost::system::error_code ec2,
+                            [aResp](const boost::system::error_code& ec2,
                                     const std::string& value) {
                             if (ec2)
                             {
@@ -549,7 +550,7 @@
         *crow::connections::systemBus, "xyz.openbmc_project.State.Host",
         "/xyz/openbmc_project/state/host0", "xyz.openbmc_project.State.Host",
         "CurrentHostState",
-        [aResp](const boost::system::error_code ec,
+        [aResp](const boost::system::error_code& ec,
                 const std::string& hostState) {
         if (ec)
         {
@@ -838,7 +839,7 @@
         *crow::connections::systemBus, "xyz.openbmc_project.State.Host",
         "/xyz/openbmc_project/state/host0",
         "xyz.openbmc_project.State.Boot.Progress", "BootProgress",
-        [aResp](const boost::system::error_code ec,
+        [aResp](const boost::system::error_code& ec,
                 const std::string& bootProgressStr) {
         if (ec)
         {
@@ -868,7 +869,7 @@
         *crow::connections::systemBus, "xyz.openbmc_project.State.Host",
         "/xyz/openbmc_project/state/host0",
         "xyz.openbmc_project.State.Boot.Progress", "BootProgressLastUpdate",
-        [aResp](const boost::system::error_code ec,
+        [aResp](const boost::system::error_code& ec,
                 const uint64_t lastStateTime) {
         if (ec)
         {
@@ -902,7 +903,7 @@
         *crow::connections::systemBus, "xyz.openbmc_project.Settings",
         "/xyz/openbmc_project/control/host0/boot",
         "xyz.openbmc_project.Control.Boot.Type", "BootType",
-        [aResp](const boost::system::error_code ec,
+        [aResp](const boost::system::error_code& ec,
                 const std::string& bootType) {
         if (ec)
         {
@@ -941,7 +942,7 @@
         *crow::connections::systemBus, "xyz.openbmc_project.Settings",
         "/xyz/openbmc_project/control/host0/boot",
         "xyz.openbmc_project.Control.Boot.Mode", "BootMode",
-        [aResp](const boost::system::error_code ec,
+        [aResp](const boost::system::error_code& ec,
                 const std::string& bootModeStr) {
         if (ec)
         {
@@ -985,7 +986,7 @@
         *crow::connections::systemBus, "xyz.openbmc_project.Settings",
         "/xyz/openbmc_project/control/host0/boot",
         "xyz.openbmc_project.Control.Boot.Source", "BootSource",
-        [aResp](const boost::system::error_code ec,
+        [aResp](const boost::system::error_code& ec,
                 const std::string& bootSourceStr) {
         if (ec)
         {
@@ -1038,7 +1039,7 @@
         *crow::connections::systemBus, "xyz.openbmc_project.Settings",
         "/xyz/openbmc_project/control/host0/boot/one_time",
         "xyz.openbmc_project.Object.Enable", "Enabled",
-        [aResp](const boost::system::error_code ec, bool oneTimeSetting) {
+        [aResp](const boost::system::error_code& ec, bool oneTimeSetting) {
         if (ec)
         {
             BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
@@ -1073,7 +1074,7 @@
         *crow::connections::systemBus, "xyz.openbmc_project.Settings",
         "/xyz/openbmc_project/control/host0/boot",
         "xyz.openbmc_project.Object.Enable", "Enabled",
-        [aResp](const boost::system::error_code ec,
+        [aResp](const boost::system::error_code& ec,
                 const bool bootOverrideEnable) {
         if (ec)
         {
@@ -1126,7 +1127,7 @@
         *crow::connections::systemBus, "xyz.openbmc_project.State.Chassis",
         "/xyz/openbmc_project/state/chassis0",
         "xyz.openbmc_project.State.Chassis", "LastStateChangeTime",
-        [aResp](const boost::system::error_code ec, uint64_t lastResetTime) {
+        [aResp](const boost::system::error_code& ec, uint64_t lastResetTime) {
         if (ec)
         {
             BMCWEB_LOG_DEBUG << "D-BUS response error " << ec;
@@ -1158,7 +1159,7 @@
         *crow::connections::systemBus, "xyz.openbmc_project.Settings",
         "/xyz/openbmc_project/control/host0/auto_reboot",
         "xyz.openbmc_project.Control.Boot.RebootPolicy", "AutoReboot",
-        [aResp](const boost::system::error_code ec, bool autoRebootEnabled) {
+        [aResp](const boost::system::error_code& ec, bool autoRebootEnabled) {
         if (ec)
         {
             BMCWEB_LOG_DEBUG << "D-BUS response error " << ec;
@@ -1177,7 +1178,7 @@
                 "/xyz/openbmc_project/state/host0",
                 "xyz.openbmc_project.Control.Boot.RebootAttempts",
                 "AttemptsLeft",
-                [aResp](const boost::system::error_code ec2,
+                [aResp](const boost::system::error_code& ec2,
                         const uint32_t autoRebootAttemptsLeft) {
                 if (ec2)
                 {
@@ -1227,7 +1228,8 @@
         *crow::connections::systemBus, "xyz.openbmc_project.Settings",
         "/xyz/openbmc_project/control/host0/power_restore_policy",
         "xyz.openbmc_project.Control.Power.RestorePolicy", "PowerRestorePolicy",
-        [aResp](const boost::system::error_code ec, const std::string& policy) {
+        [aResp](const boost::system::error_code& ec,
+                const std::string& policy) {
         if (ec)
         {
             BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
@@ -1316,7 +1318,7 @@
         sdbusplus::asio::getProperty<bool>(
             *crow::connections::systemBus, serv, path,
             "xyz.openbmc_project.Control.TPM.Policy", "TPMEnable",
-            [aResp](const boost::system::error_code ec2, bool tpmRequired) {
+            [aResp](const boost::system::error_code& ec2, bool tpmRequired) {
             if (ec2)
             {
                 BMCWEB_LOG_DEBUG << "D-BUS response error on TPM.Policy Get"
@@ -1405,7 +1407,7 @@
 
         // Valid TPM Enable object found, now setting the value
         crow::connections::systemBus->async_method_call(
-            [aResp](const boost::system::error_code ec2) {
+            [aResp](const boost::system::error_code& ec2) {
             if (ec2)
             {
                 BMCWEB_LOG_DEBUG
@@ -1464,7 +1466,7 @@
     BMCWEB_LOG_DEBUG << "DBUS boot type: " << bootTypeStr;
 
     crow::connections::systemBus->async_method_call(
-        [aResp](const boost::system::error_code ec) {
+        [aResp](const boost::system::error_code& ec) {
         if (ec)
         {
             BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
@@ -1533,7 +1535,7 @@
     BMCWEB_LOG_DEBUG << "DBUS boot override enable: " << bootOverrideEnable;
 
     crow::connections::systemBus->async_method_call(
-        [aResp](const boost::system::error_code ec2) {
+        [aResp](const boost::system::error_code& ec2) {
         if (ec2)
         {
             BMCWEB_LOG_DEBUG << "DBUS response error " << ec2;
@@ -1559,7 +1561,7 @@
                      << bootOverridePersistent;
 
     crow::connections::systemBus->async_method_call(
-        [aResp](const boost::system::error_code ec) {
+        [aResp](const boost::system::error_code& ec) {
         if (ec)
         {
             BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
@@ -1613,7 +1615,7 @@
     BMCWEB_LOG_DEBUG << "DBUS boot mode: " << bootModeStr;
 
     crow::connections::systemBus->async_method_call(
-        [aResp](const boost::system::error_code ec) {
+        [aResp](const boost::system::error_code& ec) {
         if (ec)
         {
             BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
@@ -1629,7 +1631,7 @@
         dbus::utility::DbusVariantType(bootSourceStr));
 
     crow::connections::systemBus->async_method_call(
-        [aResp](const boost::system::error_code ec) {
+        [aResp](const boost::system::error_code& ec) {
         if (ec)
         {
             BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
@@ -1724,7 +1726,7 @@
         }
 
         crow::connections::systemBus->async_method_call(
-            [aResp](const boost::system::error_code ec2) {
+            [aResp](const boost::system::error_code& ec2) {
             if (ec2)
             {
                 BMCWEB_LOG_DEBUG << "D-Bus response error on AssetTag Set "
@@ -1773,7 +1775,7 @@
     }
 
     crow::connections::systemBus->async_method_call(
-        [aResp](const boost::system::error_code ec) {
+        [aResp](const boost::system::error_code& ec) {
         if (ec)
         {
             messages::internalError(aResp->res);
@@ -1822,7 +1824,7 @@
     powerRestorPolicy = policyMapsIt->second;
 
     crow::connections::systemBus->async_method_call(
-        [aResp](const boost::system::error_code ec) {
+        [aResp](const boost::system::error_code& ec) {
         if (ec)
         {
             messages::internalError(aResp->res);
@@ -1850,7 +1852,7 @@
     sdbusplus::asio::getAllProperties(
         *crow::connections::systemBus, "xyz.openbmc_project.PFR.Manager",
         "/xyz/openbmc_project/pfr", "xyz.openbmc_project.PFR.Attributes",
-        [aResp](const boost::system::error_code ec,
+        [aResp](const boost::system::error_code& ec,
                 const dbus::utility::DBusPropertiesMap& propertiesList) {
         nlohmann::json& oemPFR =
             aResp->res.jsonValue["Oem"]["OpenBmc"]["FirmwareProvisioning"];
@@ -2004,7 +2006,7 @@
         sdbusplus::asio::getProperty<std::string>(
             *crow::connections::systemBus, service, path,
             "xyz.openbmc_project.Control.Power.Mode", "PowerMode",
-            [aResp](const boost::system::error_code ec2,
+            [aResp](const boost::system::error_code& ec2,
                     const std::string& pmode) {
             if (ec2)
             {
@@ -2130,7 +2132,7 @@
 
         // Set the Power Mode property
         crow::connections::systemBus->async_method_call(
-            [aResp](const boost::system::error_code ec2) {
+            [aResp](const boost::system::error_code& ec2) {
             if (ec2)
             {
                 messages::internalError(aResp->res);
@@ -2219,7 +2221,7 @@
         *crow::connections::systemBus, "xyz.openbmc_project.Watchdog",
         "/xyz/openbmc_project/watchdog/host0",
         "xyz.openbmc_project.State.Watchdog",
-        [aResp](const boost::system::error_code ec,
+        [aResp](const boost::system::error_code& ec,
                 const dbus::utility::DBusPropertiesMap& properties) {
         if (ec)
         {
@@ -2297,7 +2299,7 @@
         }
 
         crow::connections::systemBus->async_method_call(
-            [aResp](const boost::system::error_code ec) {
+            [aResp](const boost::system::error_code& ec) {
             if (ec)
             {
                 BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
@@ -2315,7 +2317,7 @@
     if (wdtEnable)
     {
         crow::connections::systemBus->async_method_call(
-            [aResp](const boost::system::error_code ec) {
+            [aResp](const boost::system::error_code& ec) {
             if (ec)
             {
                 BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
@@ -2458,7 +2460,7 @@
         sdbusplus::asio::getAllProperties(
             *crow::connections::systemBus, service, path,
             "xyz.openbmc_project.Control.Power.IdlePowerSaver",
-            [aResp](const boost::system::error_code ec2,
+            [aResp](const boost::system::error_code& ec2,
                     const dbus::utility::DBusPropertiesMap& properties) {
             if (ec2)
             {
@@ -2557,7 +2559,7 @@
         if (ipsEnable)
         {
             crow::connections::systemBus->async_method_call(
-                [aResp](const boost::system::error_code ec2) {
+                [aResp](const boost::system::error_code& ec2) {
                 if (ec2)
                 {
                     BMCWEB_LOG_DEBUG << "DBUS response error " << ec2;
@@ -2572,7 +2574,7 @@
         if (ipsEnterUtil)
         {
             crow::connections::systemBus->async_method_call(
-                [aResp](const boost::system::error_code ec2) {
+                [aResp](const boost::system::error_code& ec2) {
                 if (ec2)
                 {
                     BMCWEB_LOG_DEBUG << "DBUS response error " << ec2;
@@ -2590,7 +2592,7 @@
             // Convert from seconds into milliseconds for DBus
             const uint64_t timeMilliseconds = *ipsEnterTime * 1000;
             crow::connections::systemBus->async_method_call(
-                [aResp](const boost::system::error_code ec2) {
+                [aResp](const boost::system::error_code& ec2) {
                 if (ec2)
                 {
                     BMCWEB_LOG_DEBUG << "DBUS response error " << ec2;
@@ -2606,7 +2608,7 @@
         if (ipsExitUtil)
         {
             crow::connections::systemBus->async_method_call(
-                [aResp](const boost::system::error_code ec2) {
+                [aResp](const boost::system::error_code& ec2) {
                 if (ec2)
                 {
                     BMCWEB_LOG_DEBUG << "DBUS response error " << ec2;
@@ -2624,7 +2626,7 @@
             // Convert from seconds into milliseconds for DBus
             const uint64_t timeMilliseconds = *ipsExitTime * 1000;
             crow::connections::systemBus->async_method_call(
-                [aResp](const boost::system::error_code ec2) {
+                [aResp](const boost::system::error_code& ec2) {
                 if (ec2)
                 {
                     BMCWEB_LOG_DEBUG << "DBUS response error " << ec2;
@@ -2688,7 +2690,7 @@
             *crow::connections::systemBus, "xyz.openbmc_project.Settings",
             "/xyz/openbmc_project/network/hypervisor",
             "xyz.openbmc_project.Network.SystemConfiguration", "HostName",
-            [asyncResp](const boost::system::error_code ec2,
+            [asyncResp](const boost::system::error_code& ec2,
                         const std::string& /*hostName*/) {
             nlohmann::json& ifaceArray = asyncResp->res.jsonValue["Members"];
             ifaceArray = nlohmann::json::array();
@@ -2722,7 +2724,7 @@
     constexpr char const* method = "NMI";
 
     crow::connections::systemBus->async_method_call(
-        [asyncResp](const boost::system::error_code ec) {
+        [asyncResp](const boost::system::error_code& ec) {
         if (ec)
         {
             BMCWEB_LOG_ERROR << " Bad D-Bus request error: " << ec;
@@ -2811,7 +2813,7 @@
         if (hostCommand)
         {
             crow::connections::systemBus->async_method_call(
-                [asyncResp, resetType](const boost::system::error_code ec) {
+                [asyncResp, resetType](const boost::system::error_code& ec) {
                 if (ec)
                 {
                     BMCWEB_LOG_ERROR << "D-Bus responses error: " << ec;
@@ -2837,7 +2839,7 @@
         else
         {
             crow::connections::systemBus->async_method_call(
-                [asyncResp, resetType](const boost::system::error_code ec) {
+                [asyncResp, resetType](const boost::system::error_code& ec) {
                 if (ec)
                 {
                     BMCWEB_LOG_ERROR << "D-Bus responses error: " << ec;