Fix some cppcheck warnings
Fix some of the warnings in the base phosphor-logging code.
It doesn't fix all of them - some are false positives and some are just
suggestions, but it does bring down the number a bit to make it easier
to spot real issues.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I8a131cbc2941ccba79ef3775151007c770207bd5
diff --git a/log_manager.cpp b/log_manager.cpp
index af4524c..1a79b36 100644
--- a/log_manager.cpp
+++ b/log_manager.cpp
@@ -383,9 +383,10 @@
void Manager::quiesceOnError(const uint32_t entryId)
{
// Verify we don't already have this entry blocking
- auto it = find_if(
- this->blockingErrors.begin(), this->blockingErrors.end(),
- [&](std::unique_ptr<Block>& obj) { return obj->entryId == entryId; });
+ auto it = find_if(this->blockingErrors.begin(), this->blockingErrors.end(),
+ [&](const std::unique_ptr<Block>& obj) {
+ return obj->entryId == entryId;
+ });
if (it != this->blockingErrors.end())
{
// Already recorded so just return
@@ -468,9 +469,10 @@
void Manager::checkAndRemoveBlockingError(uint32_t entryId)
{
// First look for blocking object and remove
- auto it = find_if(
- blockingErrors.begin(), blockingErrors.end(),
- [&](std::unique_ptr<Block>& obj) { return obj->entryId == entryId; });
+ auto it = find_if(blockingErrors.begin(), blockingErrors.end(),
+ [&](const std::unique_ptr<Block>& obj) {
+ return obj->entryId == entryId;
+ });
if (it != blockingErrors.end())
{
blockingErrors.erase(it);