phosphor-power-supply: Fix code security vulnerabilities

Using the invpath variable after calling std::move(invpath) may
result in unexpected or undefined behavior.

Signed-off-by: George Liu <liuxiwei@ieisystem.com>
Change-Id: Iad80d8844d99a0f1760d7f0f7ea354f001c3d2be
diff --git a/phosphor-power-supply/util.hpp b/phosphor-power-supply/util.hpp
index 3302d8d..22e192e 100644
--- a/phosphor-power-supply/util.hpp
+++ b/phosphor-power-supply/util.hpp
@@ -42,6 +42,12 @@
     void setPresence(sdbusplus::bus_t& bus, const std::string& invpath,
                      bool present, const std::string& name) const override
     {
+        using namespace phosphor::logging;
+        log<level::INFO>(fmt::format("Updating inventory present property. "
+                                     "present:{} invpath:{} name:{}",
+                                     present, invpath, name)
+                             .c_str());
+
         using InternalFailure =
             sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
         PropertyMap invProp;
@@ -60,12 +66,6 @@
         ObjectMap invObj;
         invObj.emplace(std::move(invpath), std::move(invIntf));
 
-        using namespace phosphor::logging;
-        log<level::INFO>(fmt::format("Updating inventory present property. "
-                                     "present:{} invpath:{} name:{}",
-                                     present, invpath, name)
-                             .c_str());
-
         try
         {
             auto invService = phosphor::power::util::getService(