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/include/async_resolve.hpp b/include/async_resolve.hpp
index 0027a05..f44be4b 100644
--- a/include/async_resolve.hpp
+++ b/include/async_resolve.hpp
@@ -37,7 +37,7 @@
         uint64_t flag = 0;
         crow::connections::systemBus->async_method_call(
             [host, port, handler{std::forward<ResolveHandler>(handler)}](
-                const boost::system::error_code ec,
+                const boost::system::error_code& ec,
                 const std::vector<
                     std::tuple<int32_t, int32_t, std::vector<uint8_t>>>& resp,
                 const std::string& hostName, const uint64_t flagNum) {
diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp
index e953a9f..f41c422 100644
--- a/include/dbus_utility.hpp
+++ b/include/dbus_utility.hpp
@@ -133,7 +133,7 @@
 {
     crow::connections::systemBus->async_method_call(
         [callback{std::forward<Callback>(callback)}](
-            const boost::system::error_code ec,
+            const boost::system::error_code& ec,
             const dbus::utility::MapperGetObject& objectNames) {
         callback(!ec && !objectNames.empty());
         },
@@ -151,7 +151,7 @@
 {
     crow::connections::systemBus->async_method_call(
         [callback{std::move(callback)}](
-            const boost::system::error_code ec,
+            const boost::system::error_code& ec,
             const MapperGetSubTreeResponse& subtree) { callback(ec, subtree); },
         "xyz.openbmc_project.ObjectMapper",
         "/xyz/openbmc_project/object_mapper",
@@ -167,7 +167,7 @@
 {
     crow::connections::systemBus->async_method_call(
         [callback{std::move(callback)}](
-            const boost::system::error_code ec,
+            const boost::system::error_code& ec,
             const MapperGetSubTreePathsResponse& subtreePaths) {
         callback(ec, subtreePaths);
         },
diff --git a/include/google/google_service_root.hpp b/include/google/google_service_root.hpp
index d5d340a..cbcf15d 100644
--- a/include/google/google_service_root.hpp
+++ b/include/google/google_service_root.hpp
@@ -65,7 +65,7 @@
     const std::string& command,
     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
     const std::string& rotId, const ResolvedEntityHandler& entityHandler,
-    const boost::system::error_code ec,
+    const boost::system::error_code& ec,
     const dbus::utility::MapperGetSubTreeResponse& subtree)
 {
     if (ec)
@@ -147,7 +147,7 @@
 
 inline void
     invocationCallback(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
-                       const boost::system::error_code ec,
+                       const boost::system::error_code& ec,
                        const std::vector<uint8_t>& responseBytes)
 {
     if (ec)
@@ -177,7 +177,7 @@
     }
 
     crow::connections::systemBus->async_method_call(
-        [asyncResp{asyncResp}](const boost::system::error_code ec,
+        [asyncResp{asyncResp}](const boost::system::error_code& ec,
                                const std::vector<uint8_t>& responseBytes) {
         invocationCallback(asyncResp, ec, responseBytes);
         },
diff --git a/include/hostname_monitor.hpp b/include/hostname_monitor.hpp
index f0d8bdf..ed719d5 100644
--- a/include/hostname_monitor.hpp
+++ b/include/hostname_monitor.hpp
@@ -19,7 +19,7 @@
 inline void installCertificate(const std::filesystem::path& certPath)
 {
     crow::connections::systemBus->async_method_call(
-        [certPath](const boost::system::error_code ec) {
+        [certPath](const boost::system::error_code& ec) {
         if (ec)
         {
             BMCWEB_LOG_ERROR << "Replace Certificate Fail..";
diff --git a/include/nbd_proxy.hpp b/include/nbd_proxy.hpp
index 500ea76..7ffa9aa 100644
--- a/include/nbd_proxy.hpp
+++ b/include/nbd_proxy.hpp
@@ -65,9 +65,9 @@
 
     void run()
     {
-        acceptor.async_accept(
-            [this, self(shared_from_this())](boost::system::error_code ec,
-                                             stream_protocol::socket socket) {
+        acceptor.async_accept([this, self(shared_from_this())](
+                                  const boost::system::error_code& ec,
+                                  stream_protocol::socket socket) {
             if (ec)
             {
                 BMCWEB_LOG_ERROR << "UNIX socket: async_accept error = "
@@ -93,8 +93,8 @@
         });
 
         auto mountHandler =
-            [this, self(shared_from_this())](const boost::system::error_code ec,
-                                             const bool) {
+            [this, self(shared_from_this())](
+                const boost::system::error_code& ec, const bool) {
             if (ec)
             {
                 BMCWEB_LOG_ERROR << "DBus error: cannot call mount method = "
@@ -130,7 +130,7 @@
         }
         // The reference to session should exists until unmount is
         // called
-        auto unmountHandler = [](const boost::system::error_code ec) {
+        auto unmountHandler = [](const boost::system::error_code& ec) {
             if (ec)
             {
                 BMCWEB_LOG_ERROR << "DBus error: " << ec
@@ -157,8 +157,8 @@
         // Trigger async read
         peerSocket->async_read_some(
             ux2wsBuf.prepare(nbdBufferSize),
-            [this, self(shared_from_this())](boost::system::error_code ec,
-                                             std::size_t bytesRead) {
+            [this, self(shared_from_this())](
+                const boost::system::error_code& ec, std::size_t bytesRead) {
             if (ec)
             {
                 BMCWEB_LOG_ERROR << "UNIX socket: async_read_some error = "
@@ -208,8 +208,8 @@
         uxWriteInProgress = true;
         boost::asio::async_write(
             *peerSocket, ws2uxBuf.data(),
-            [this, self(shared_from_this())](boost::system::error_code ec,
-                                             std::size_t bytesWritten) {
+            [this, self(shared_from_this())](
+                const boost::system::error_code& ec, std::size_t bytesWritten) {
             ws2uxBuf.consume(bytesWritten);
             uxWriteInProgress = false;
             if (ec)
@@ -261,7 +261,7 @@
             BMCWEB_LOG_DEBUG << "nbd-proxy.onopen(" << &conn << ")";
 
             auto getUserInfoHandler =
-                [&conn](const boost::system::error_code ec,
+                [&conn](const boost::system::error_code& ec,
                         const dbus::utility::DBusPropertiesMap& userInfo) {
             if (ec)
             {
@@ -304,7 +304,7 @@
             }
 
             auto openHandler =
-                [&conn](const boost::system::error_code ec2,
+                [&conn](const boost::system::error_code& ec2,
                         const dbus::utility::ManagedObjectType& objects) {
                 const std::string* socketValue = nullptr;
                 const std::string* endpointValue = nullptr;
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index 3035105..98dfb84 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -131,7 +131,7 @@
     crow::connections::systemBus->async_method_call(
         [transaction, processName{std::string(processName)},
          objectPath{std::string(objectPath)}](
-            const boost::system::error_code ec,
+            const boost::system::error_code& ec,
             const std::string& introspectXml) {
         if (ec)
         {
@@ -192,7 +192,7 @@
     sdbusplus::asio::getAllProperties(
         *crow::connections::systemBus, service, objectPath, interface,
         [asyncResp, objectPath, service,
-         interface](const boost::system::error_code ec,
+         interface](const boost::system::error_code& ec,
                     const dbus::utility::DBusPropertiesMap& propertiesList) {
         if (ec)
         {
@@ -305,7 +305,7 @@
                      << " connection_name " << connectionName;
     crow::connections::systemBus->async_method_call(
         [transaction, objectName,
-         connectionName](const boost::system::error_code ec,
+         connectionName](const boost::system::error_code& ec,
                          const dbus::utility::ManagedObjectType& objects) {
         if (ec)
         {
@@ -375,7 +375,7 @@
                      << " on connection:" << connectionName;
     crow::connections::systemBus->async_method_call(
         [transaction, objectName, connectionName](
-            const boost::system::error_code ec,
+            const boost::system::error_code& ec,
             const dbus::utility::MapperGetAncestorsResponse& objects) {
         if (ec)
         {
@@ -1383,7 +1383,7 @@
                      << connectionName;
     crow::connections::systemBus->async_method_call(
         [transaction, connectionName{std::string(connectionName)}](
-            const boost::system::error_code ec,
+            const boost::system::error_code& ec,
             const std::string& introspectXml) {
         BMCWEB_LOG_DEBUG << "got xml:\n " << introspectXml;
         if (ec)
@@ -1495,7 +1495,7 @@
                         crow::connections::systemBus->async_send(
                             m,
                             [transaction,
-                             returnType](boost::system::error_code ec2,
+                             returnType](const boost::system::error_code& ec2,
                                          sdbusplus::message_t& m2) {
                             if (ec2)
                             {
@@ -1747,7 +1747,7 @@
                 m.append(interface);
                 crow::connections::systemBus->async_send(
                     m, [asyncResp, response,
-                        propertyName](const boost::system::error_code ec2,
+                        propertyName](const boost::system::error_code& ec2,
                                       sdbusplus::message_t& msg) {
                         if (ec2)
                         {
@@ -1900,7 +1900,7 @@
 
             crow::connections::systemBus->async_method_call(
                 [connectionName{std::string(connectionName)},
-                 transaction](const boost::system::error_code ec3,
+                 transaction](const boost::system::error_code& ec3,
                               const std::string& introspectXml) {
                 if (ec3)
                 {
@@ -1984,8 +1984,9 @@
                                 }
                                 crow::connections::systemBus->async_send(
                                     m,
-                                    [transaction](boost::system::error_code ec,
-                                                  sdbusplus::message_t& m2) {
+                                    [transaction](
+                                        const boost::system::error_code& ec,
+                                        sdbusplus::message_t& m2) {
                                     BMCWEB_LOG_DEBUG << "sent";
                                     if (ec)
                                     {
@@ -2157,7 +2158,7 @@
     {
         crow::connections::systemBus->async_method_call(
             [asyncResp, processName,
-             objectPath](const boost::system::error_code ec,
+             objectPath](const boost::system::error_code& ec,
                          const std::string& introspectXml) {
             if (ec)
             {
@@ -2212,7 +2213,7 @@
     {
         crow::connections::systemBus->async_method_call(
             [asyncResp, processName, objectPath,
-             interfaceName](const boost::system::error_code ec,
+             interfaceName](const boost::system::error_code& ec,
                             const std::string& introspectXml) {
             if (ec)
             {
@@ -2445,7 +2446,7 @@
         .methods(boost::beast::http::verb::get)(
             [](const crow::Request&,
                const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
-        auto myCallback = [asyncResp](const boost::system::error_code ec,
+        auto myCallback = [asyncResp](const boost::system::error_code& ec,
                                       std::vector<std::string>& names) {
             if (ec)
             {