util:dbus: Limit the scope of some variables

The scope of some variables were reduced in response to CI compiler
warnings.

Signed-off-by: Ben Tyner <ben.tyner@ibm.com>
Change-Id: Ia3bcccc2f2aeff70dad3d835a4c2e912c2ebeefb
diff --git a/util/dbus.cpp b/util/dbus.cpp
index 5b4de10..7e8a234 100644
--- a/util/dbus.cpp
+++ b/util/dbus.cpp
@@ -21,10 +21,10 @@
 
     auto bus = sdbusplus::bus::new_default();
 
-    constexpr auto function = "GetSubTree";
-
     try
     {
+        constexpr auto function = "GetSubTree";
+
         auto method = bus.new_method_call(objectMapperService, objectMapperPath,
                                           objectMapperInterface, function);
 
@@ -65,10 +65,10 @@
 
     auto bus = sdbusplus::bus::new_default();
 
-    constexpr auto function = "GetObject";
-
     try
     {
+        constexpr auto function = "GetObject";
+
         auto method = bus.new_method_call(objectMapperService, objectMapperPath,
                                           objectMapperInterface, function);
 
@@ -109,11 +109,11 @@
 
     auto bus = sdbusplus::bus::new_default();
 
-    constexpr auto interface = "org.freedesktop.DBus.Properties";
-    constexpr auto function  = "Get";
-
     try
     {
+        constexpr auto interface = "org.freedesktop.DBus.Properties";
+        constexpr auto function  = "Get";
+
         // calling the get property method
         auto method = bus.new_method_call(i_service.c_str(), i_path.c_str(),
                                           interface, function);