psu-ng: Move adding _PID to createError

Adding the _PID value to the additional data for an error does not need
to repeat every time we loop through a power supply in the
configuration. Move adding that _PID value down into the createError()
function.

Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Change-Id: Id09b981debb2d9e35c6ddf6865cf0ec60742156f
diff --git a/phosphor-power-supply/psu_manager.cpp b/phosphor-power-supply/psu_manager.cpp
index 1afdfd2..76838dc 100644
--- a/phosphor-power-supply/psu_manager.cpp
+++ b/phosphor-power-supply/psu_manager.cpp
@@ -325,9 +325,8 @@
     }
 }
 
-void PSUManager::createError(
-    const std::string& faultName,
-    const std::map<std::string, std::string>& additionalData)
+void PSUManager::createError(const std::string& faultName,
+                             std::map<std::string, std::string>& additionalData)
 {
     using namespace sdbusplus::xyz::openbmc_project;
     constexpr auto loggingObjectPath = "/xyz/openbmc_project/logging";
@@ -336,6 +335,8 @@
 
     try
     {
+        additionalData["_PID"] = std::to_string(getpid());
+
         auto service =
             util::getService(loggingObjectPath, loggingCreateInterface, bus);
 
@@ -377,7 +378,6 @@
 
         for (auto& psu : psus)
         {
-            additionalData["_PID"] = std::to_string(getpid());
             // TODO: Fault priorities #918
             if (!psu->isFaultLogged() && !psu->isPresent())
             {
diff --git a/phosphor-power-supply/psu_manager.hpp b/phosphor-power-supply/psu_manager.hpp
index edc296f..085f11e 100644
--- a/phosphor-power-supply/psu_manager.hpp
+++ b/phosphor-power-supply/psu_manager.hpp
@@ -169,10 +169,10 @@
      * Create an error
      *
      * @param[in] faultName - 'name' message for the BMC error log entry
-     * @param[in] additionalData - The AdditionalData property for the error
+     * @param[in,out] additionalData - The AdditionalData property for the error
      */
     void createError(const std::string& faultName,
-                     const std::map<std::string, std::string>& additionalData);
+                     std::map<std::string, std::string>& additionalData);
 
     /**
      * Analyze the status of each of the power supplies.