ffdc: Only proceed with PEL creation if there is an error

Sometimes the listening application is woken up to read the FFDC file
even if there is no error. Catch this case before trying to create a
PEL. Also, make sure the app doesn't crash trying to get the PEL
service.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Change-Id: I84f3f6d56054c08507473ecf8908ecc3901aaeaa
diff --git a/occ_ffdc.cpp b/occ_ffdc.cpp
index bb55ce8..0dc8d3c 100644
--- a/occ_ffdc.cpp
+++ b/occ_ffdc.cpp
@@ -55,12 +55,12 @@
     additionalData.emplace("_PID", std::to_string(getpid()));
     additionalData.emplace("SBE_ERR_MSG", msg);
 
-    std::string service =
-        utils::getService(loggingObjectPath, loggingInterface);
     auto& bus = utils::getBus();
 
     try
     {
+        std::string service =
+            utils::getService(loggingObjectPath, loggingInterface);
         auto method =
             bus.new_method_call(service.c_str(), loggingObjectPath,
                                 loggingInterface, "CreatePELWithFFDCFiles");
@@ -110,6 +110,12 @@
 
     lseek(fd, 0, SEEK_SET);
 
+    if (!total)
+    {
+        // no error
+        return;
+    }
+
     uint32_t src6 = instance << 16;
     src6 |= *(data.get() + 2) << 8;
     src6 |= *(data.get() + 3);