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/elog_serialize.cpp b/elog_serialize.cpp
index 087ef40..b8e2cd6 100644
--- a/elog_serialize.cpp
+++ b/elog_serialize.cpp
@@ -130,13 +130,13 @@
}
return false;
}
- catch (const cereal::Exception& e)
+ catch (const cereal::Exception& ex)
{
- log<level::ERR>(e.what());
+ log<level::ERR>(ex.what());
fs::remove(path);
return false;
}
- catch (const std::length_error& e)
+ catch (const std::length_error& ex)
{
// Running into: USCiLab/cereal#192
// This may be indicating some other issue in the
@@ -144,7 +144,7 @@
// possibly associations ??. But handling it here for
// now since we are anyway tossing the log
// TODO: openbmc/phosphor-logging#8
- log<level::ERR>(e.what());
+ log<level::ERR>(ex.what());
fs::remove(path);
return false;
}
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);
diff --git a/test/elog_errorwrap_test.hpp b/test/elog_errorwrap_test.hpp
index 553e2e8..239ba05 100644
--- a/test/elog_errorwrap_test.hpp
+++ b/test/elog_errorwrap_test.hpp
@@ -37,11 +37,11 @@
class journalImpl : public journalInterface
{
public:
- void journalSync();
- int sd_journal_open(sd_journal** j, int k);
+ void journalSync() override;
+ int sd_journal_open(sd_journal** j, int k) override;
int sd_journal_get_data(sd_journal* j, const char* transactionIdVar,
- const void** data, size_t length);
- void sd_journal_close(sd_journal* j);
+ const void** data, size_t length) override;
+ void sd_journal_close(sd_journal* j) override;
};
int journalImpl::sd_journal_open(sd_journal**, int)