change analyzerHardware() to return PEL PLID is created

Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: Icee2909e5060c79cb95ead8fc08a5e359df42829
diff --git a/analyzer/analyzer_main.cpp b/analyzer/analyzer_main.cpp
index 71d47e9..c17a0ee 100644
--- a/analyzer/analyzer_main.cpp
+++ b/analyzer/analyzer_main.cpp
@@ -34,10 +34,10 @@
  * @brief Will create and submit a PEL using the given data.
  * @param i_isoData   The data gathered during isolation (for FFDC).
  * @param i_servData  Data regarding service actions gathered during analysis.
- * @return Tuple of BMC log id, platform log id
+ * @return The platform log ID. Will return zero if no PEL is generated.
  */
-std::tuple<uint32_t, uint32_t> createPel(const libhei::IsolationData& i_isoData,
-                                         const ServiceData& i_servData);
+uint32_t createPel(const libhei::IsolationData& i_isoData,
+                   const ServiceData& i_servData);
 
 //------------------------------------------------------------------------------
 
@@ -70,14 +70,14 @@
 
 //------------------------------------------------------------------------------
 
-bool analyzeHardware(attn::DumpParameters& o_dumpParameters)
+uint32_t analyzeHardware(attn::DumpParameters& o_dumpParameters)
 {
-    bool attnFound = false;
+    uint32_t o_plid = 0; // default, zero indicates PEL was not created
 
     if (!util::pdbg::queryHardwareAnalysisSupported())
     {
         trace::err("Hardware error analysis is not supported on this system");
-        return attnFound;
+        return o_plid;
     }
 
     trace::inf(">>> enter analyzeHardware()");
@@ -102,7 +102,7 @@
 
     // Filter for root cause attention.
     libhei::Signature rootCause{};
-    attnFound = filterRootCause(isoData, rootCause);
+    bool attnFound = filterRootCause(isoData, rootCause);
 
     if (!attnFound)
     {
@@ -124,18 +124,24 @@
         rasData.getResolution(rootCause)->resolve(servData);
 
         // Create and commit a PEL.
-        uint32_t logId = std::get<1>(createPel(isoData, servData));
+        o_plid = createPel(isoData, servData);
 
-        trace::inf("PEL created: PLID=0x%0" PRIx32, logId);
+        if (0 == o_plid)
+        {
+            trace::err("Failed to create PEL");
+        }
+        else
+        {
+            trace::inf("PEL created: PLID=0x%0" PRIx32, o_plid);
 
-        // Gather/return information needed for dump. A hardware dump will
-        // always be used for system checkstop attenions. Software dumps will be
-        // reserved for MP-IPLs during TI analysis.
-        // TODO: Need ID from root cause. At the moment, HUID does not exist in
-        //       devtree. Will need a better ID definition.
-        o_dumpParameters.logId    = logId;
-        o_dumpParameters.unitId   = 0;
-        o_dumpParameters.dumpType = attn::DumpType::Hardware;
+            // Gather/return information needed for dump. A hardware dump will
+            // always be used for system checkstop attenions. Software dumps
+            // will be reserved for MP-IPLs during TI analysis.
+            // TODO: Need ID from root cause. At the moment, HUID does not exist
+            //       in devtree. Will need a better ID definition.
+            o_dumpParameters.unitId   = 0;
+            o_dumpParameters.dumpType = attn::DumpType::Hardware;
+        }
     }
 
     // All done, clean up the isolator.
@@ -144,7 +150,7 @@
 
     trace::inf("<<< exit analyzeHardware()");
 
-    return attnFound;
+    return o_plid;
 }
 
 //------------------------------------------------------------------------------
diff --git a/analyzer/analyzer_main.hpp b/analyzer/analyzer_main.hpp
index 5619ba3..51399b0 100644
--- a/analyzer/analyzer_main.hpp
+++ b/analyzer/analyzer_main.hpp
@@ -11,18 +11,10 @@
  *         attentions.
  *
  * @param[out] o_dumpParameters Dump request parameters
- * @return True if an active attenion was successfully analyzed, false
- *         otherwise.
- *         For system checkstop handling:
- *            If analysis fails, there likely is a defect in the design because
- *            an active attention is required to trigger the interrupt.
- *         For TI handling:
- *            It is possible that a recoverable attention could cause a TI,
- *            however, it is not required. Therefore, it is expected that
- *            analysis could fail to find an attention and it should not be
- *            treated as a defect.
+ * @return The platform log ID (PLID) of the PEL generated during analysis. Will
+ *         return zero if no PEL is generated.
  */
-bool analyzeHardware(attn::DumpParameters& o_dumpParameters);
+uint32_t analyzeHardware(attn::DumpParameters& o_dumpParameters);
 
 /**
  * @brief Get error analyzer build information
diff --git a/analyzer/create_pel.cpp b/analyzer/create_pel.cpp
index adc2264..bef001e 100644
--- a/analyzer/create_pel.cpp
+++ b/analyzer/create_pel.cpp
@@ -308,9 +308,11 @@
 
 //------------------------------------------------------------------------------
 
-std::tuple<uint32_t, uint32_t> createPel(const libhei::IsolationData& i_isoData,
-                                         const ServiceData& i_servData)
+uint32_t createPel(const libhei::IsolationData& i_isoData,
+                   const ServiceData& i_servData)
 {
+    uint32_t o_plid = 0; // default, zero indicates PEL was not created
+
     // The message registry will require additional log data to fill in keywords
     // and additional log data.
     std::map<std::string, std::string> logData;
@@ -348,9 +350,6 @@
     std::vector<util::FFDCTuple> userData;
     util::transformFFDC(userDataFiles, userData);
 
-    // Response will be a tuple containing bmc-log-id, pel-log-id
-    std::tuple<uint32_t, uint32_t> response = {0, 0};
-
     try
     {
         // We want to use the logging interface that returns the event log
@@ -387,8 +386,13 @@
             // Log the event.
             auto reply = bus.call(method);
 
+            // Response will be a tuple containing bmc-log-id, pel-log-id
+            std::tuple<uint32_t, uint32_t> response = {0, 0};
+
             // Parse reply for response
             reply.read(response);
+
+            o_plid = std::get<1>(response);
         }
     }
     catch (const sdbusplus::exception::SdBusError& e)
@@ -398,8 +402,8 @@
         trace::err(exceptionString.c_str());
     }
 
-    // return tuple of {bmc-log-id, pel-log-id} or {0, 0} on error
-    return response;
+    // Return the platorm log ID of the error.
+    return o_plid;
 }
 
 } // namespace analyzer