PEL: Fix some cppcheck warnings

This is the first of two commits to fix most of the cppcheck warnings in
the PEL code.  It doesn't fix all of them because some are false
positives and some are just suggestions.

It's broken up into two commits to make them smaller.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I75937797a6920611b136d600e9efd6c694e4209c
diff --git a/extensions/openpower-pels/data_interface.cpp b/extensions/openpower-pels/data_interface.cpp
index 4fa802f..1c33579 100644
--- a/extensions/openpower-pels/data_interface.cpp
+++ b/extensions/openpower-pels/data_interface.cpp
@@ -723,7 +723,7 @@
                     break;
                 }
             }
-            itDumpStatus++;
+            ++itDumpStatus;
         }
         itDumpStatus = result.begin();
     }
@@ -814,17 +814,18 @@
                 // If the entry isn't resolved
                 if (!status)
                 {
-                    auto service = getService(path, interface::association);
-                    if (!service.empty())
+                    auto assocService =
+                        getService(path, interface::association);
+                    if (!assocService.empty())
                     {
-                        DBusValue value;
+                        DBusValue endpoints;
 
                         // Read Endpoints property
-                        getProperty(service, path, interface::association,
-                                    "endpoints", value);
+                        getProperty(assocService, path, interface::association,
+                                    "endpoints", endpoints);
 
                         auto logPath =
-                            std::get<std::vector<std::string>>(value);
+                            std::get<std::vector<std::string>>(endpoints);
                         if (!logPath.empty())
                         {
                             // Get OpenBMC event log Id
diff --git a/extensions/openpower-pels/event_logger.hpp b/extensions/openpower-pels/event_logger.hpp
index eed2b81..1af8e2e 100644
--- a/extensions/openpower-pels/event_logger.hpp
+++ b/extensions/openpower-pels/event_logger.hpp
@@ -55,7 +55,7 @@
      *
      * @param[in] creator - The function to use to create the event log
      */
-    EventLogger(LogFunction creator) :
+    explicit EventLogger(LogFunction creator) :
         _event(sdeventplus::Event::get_default()), _creator(creator)
     {
     }
diff --git a/extensions/openpower-pels/extended_user_data.hpp b/extensions/openpower-pels/extended_user_data.hpp
index be3db5b..07f9969 100644
--- a/extensions/openpower-pels/extended_user_data.hpp
+++ b/extensions/openpower-pels/extended_user_data.hpp
@@ -105,10 +105,10 @@
     void updateDataSection(const uint8_t subType, const uint16_t componentId,
                            const std::vector<uint8_t>& newData)
     {
-        auto origDataSize = 0;
-
         if (newData.size() >= 4)
         {
+            size_t origDataSize{};
+
             // Update component Id & subtype in section header of ED
             _header.componentID = static_cast<uint16_t>(componentId);
             _header.subType = static_cast<uint8_t>(subType);
diff --git a/extensions/openpower-pels/fru_identity.hpp b/extensions/openpower-pels/fru_identity.hpp
index bcb2956..993b32b 100644
--- a/extensions/openpower-pels/fru_identity.hpp
+++ b/extensions/openpower-pels/fru_identity.hpp
@@ -103,7 +103,7 @@
      * @param[in] procedureFromRegistry - The maintenance procedure name
      *                                    as defined in the message registry.
      */
-    FRUIdentity(const std::string& procedureFromRegistry) :
+    explicit FRUIdentity(const std::string& procedureFromRegistry) :
         FRUIdentity(procedureFromRegistry, CalloutValueType::registryName)
     {
     }
diff --git a/extensions/openpower-pels/json_utils.cpp b/extensions/openpower-pels/json_utils.cpp
index e6007ed..679ef4e 100644
--- a/extensions/openpower-pels/json_utils.cpp
+++ b/extensions/openpower-pels/json_utils.cpp
@@ -167,7 +167,7 @@
 }
 
 void jsonInsert(std::string& jsonStr, const std::string& fieldName,
-                std::string fieldValue, uint8_t indentCount)
+                const std::string& fieldValue, uint8_t indentCount)
 {
     const int8_t spacesToAppend =
         colAlign - (indentCount * indentLevel) - fieldName.length() - 3;
@@ -185,7 +185,8 @@
 }
 
 void jsonInsertArray(std::string& jsonStr, const std::string& fieldName,
-                     std::vector<std::string>& values, uint8_t indentCount)
+                     const std::vector<std::string>& values,
+                     uint8_t indentCount)
 {
     const std::string jsonIndent(indentCount * indentLevel, 0x20);
     if (!values.empty())
diff --git a/extensions/openpower-pels/json_utils.hpp b/extensions/openpower-pels/json_utils.hpp
index 6415c9e..02b8a83 100644
--- a/extensions/openpower-pels/json_utils.hpp
+++ b/extensions/openpower-pels/json_utils.hpp
@@ -43,7 +43,7 @@
  * @param[in] indentCount - Indent count for the line
  */
 void jsonInsert(std::string& jsonStr, const std::string& fieldName,
-                std::string fieldValue, uint8_t indentCount);
+                const std::string& fieldValue, uint8_t indentCount);
 
 /**
  * @brief Inserts key-value array into a JSON string
@@ -54,7 +54,8 @@
  * @param[in] indentCount - Indent count for the line
  */
 void jsonInsertArray(std::string& jsonStr, const std::string& fieldName,
-                     std::vector<std::string>& values, uint8_t indentCount);
+                     const std::vector<std::string>& values,
+                     uint8_t indentCount);
 
 /**
  * @brief Converts an integer to a formatted string
diff --git a/extensions/openpower-pels/manager.cpp b/extensions/openpower-pels/manager.cpp
index 152e4fb..e0186bc 100644
--- a/extensions/openpower-pels/manager.cpp
+++ b/extensions/openpower-pels/manager.cpp
@@ -387,14 +387,14 @@
     auto src = pel->primarySRC();
     if (src)
     {
-        auto msg =
+        auto m =
             fmt::format("Created PEL {:#x} (BMC ID {}) with SRC {}", pel->id(),
                         pel->obmcLogID(), (*src)->asciiString());
-        while (msg.back() == ' ')
+        while (m.back() == ' ')
         {
-            msg.pop_back();
+            m.pop_back();
         }
-        log<level::INFO>(msg.c_str());
+        log<level::INFO>(m.c_str());
     }
 
     // Check for severity 0x51 and update boot progress SRC
@@ -648,8 +648,6 @@
 
 std::string Manager::getPELJSON(uint32_t obmcLogID)
 {
-    Repository::LogID id{Repository::LogID::Obmc(obmcLogID)};
-
     // Throws InvalidArgument if not found
     auto pelID = getPELIdFromBMCLogId(obmcLogID);
 
diff --git a/extensions/openpower-pels/pel.cpp b/extensions/openpower-pels/pel.cpp
index a84b7f8..3de2fa3 100644
--- a/extensions/openpower-pels/pel.cpp
+++ b/extensions/openpower-pels/pel.cpp
@@ -47,7 +47,6 @@
 {
 namespace pels
 {
-namespace message = openpower::pels::message;
 namespace pv = openpower::pels::pel_values;
 using namespace phosphor::logging;
 
@@ -185,9 +184,9 @@
         addUserDataSection(std::move(ud));
 
         // Also put in the journal for debug
-        for (const auto& [name, data] : debugData)
+        for (const auto& [name, msgs] : debugData)
         {
-            for (const auto& message : data)
+            for (const auto& message : msgs)
             {
                 std::string entry = name + ": " + message;
                 log<level::INFO>(entry.c_str());
diff --git a/extensions/openpower-pels/pel.hpp b/extensions/openpower-pels/pel.hpp
index 631cbdb..460d588 100644
--- a/extensions/openpower-pels/pel.hpp
+++ b/extensions/openpower-pels/pel.hpp
@@ -80,7 +80,7 @@
      *
      * @param[in] data - The PEL data
      */
-    PEL(std::vector<uint8_t>& data);
+    explicit PEL(std::vector<uint8_t>& data);
 
     /**
      * @brief Constructor
diff --git a/extensions/openpower-pels/registry.cpp b/extensions/openpower-pels/registry.cpp
index c8c37f9..a37bb6e 100644
--- a/extensions/openpower-pels/registry.cpp
+++ b/extensions/openpower-pels/registry.cpp
@@ -698,10 +698,10 @@
 
             return entry;
         }
-        catch (const std::exception& e)
+        catch (const std::exception& ex)
         {
             log<level::ERR>("Found invalid message registry field",
-                            entry("ERROR=%s", e.what()));
+                            entry("ERROR=%s", ex.what()));
         }
     }
 
diff --git a/extensions/openpower-pels/repository.cpp b/extensions/openpower-pels/repository.cpp
index b418c39..ee0d232 100644
--- a/extensions/openpower-pels/repository.cpp
+++ b/extensions/openpower-pels/repository.cpp
@@ -668,16 +668,16 @@
 
     if (!obmcLogIDs.empty())
     {
-        std::string msg = "Number of PELs removed to save space: " +
-                          std::to_string(obmcLogIDs.size());
-        log<level::INFO>(msg.c_str());
+        std::string m = "Number of PELs removed to save space: " +
+                        std::to_string(obmcLogIDs.size());
+        log<level::INFO>(m.c_str());
     }
 
     return obmcLogIDs;
 }
 
-void Repository::removePELs(IsOverLimitFunc& isOverLimit,
-                            IsPELTypeFunc& isPELType,
+void Repository::removePELs(const IsOverLimitFunc& isOverLimit,
+                            const IsPELTypeFunc& isPELType,
                             const std::vector<uint32_t>& idsWithHwIsoEntry,
                             std::vector<uint32_t>& removedBMCLogIDs)
 {
diff --git a/extensions/openpower-pels/repository.hpp b/extensions/openpower-pels/repository.hpp
index 2e8d2d6..5845afd 100644
--- a/extensions/openpower-pels/repository.hpp
+++ b/extensions/openpower-pels/repository.hpp
@@ -151,7 +151,7 @@
      *
      * @param[in] basePath - the base filesystem path for the repository
      */
-    Repository(const std::filesystem::path& basePath) :
+    explicit Repository(const std::filesystem::path& basePath) :
         Repository(basePath, getPELRepoSize(), getMaxNumPELs())
     {
     }
@@ -267,10 +267,7 @@
      */
     void subscribeToAdds(const std::string& name, AddCallback func)
     {
-        if (_addSubscriptions.find(name) == _addSubscriptions.end())
-        {
-            _addSubscriptions.emplace(name, func);
-        }
+        _addSubscriptions.emplace(name, func);
     }
 
     /**
@@ -298,10 +295,7 @@
      */
     void subscribeToDeletes(const std::string& name, DeleteCallback func)
     {
-        if (_deleteSubscriptions.find(name) == _deleteSubscriptions.end())
-        {
-            _deleteSubscriptions.emplace(name, func);
-        }
+        _deleteSubscriptions.emplace(name, func);
     }
 
     /**
@@ -566,7 +560,8 @@
      * @param[out] removedBMCLogIDs - The OpenBMC event log IDs of the
      *                                removed PELs.
      */
-    void removePELs(IsOverLimitFunc& isOverLimit, IsPELTypeFunc& isPELType,
+    void removePELs(const IsOverLimitFunc& isOverLimit,
+                    const IsPELTypeFunc& isPELType,
                     const std::vector<uint32_t>& idsWithHwIsoEntry,
                     std::vector<uint32_t>& removedBMCLogIDs);
     /**