Change variable scopes

cppcheck correctly notes that a lot of our variables can be declared at
more specific scopes, and in every case, it seems to be correct.

Tested: Redfish service validator passes.  Unit test coverage on others.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ia4414410d0e8f74a3bd40fdc0e0232450d1a6416
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index 95503d7..0e3e070 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -432,7 +432,6 @@
         {
             for (const auto& connection : object.second)
             {
-                std::string& objectManagerPath = connections[connection.first];
                 for (const auto& interface : connection.second)
                 {
                     BMCWEB_LOG_DEBUG << connection.first << " has interface "
@@ -441,7 +440,7 @@
                     {
                         BMCWEB_LOG_DEBUG << "found object manager path "
                                          << object.first;
-                        objectManagerPath = object.first;
+                        connections[connection.first] = object.first;
                     }
                 }
             }