openpower-pels: clean up various compile warnings
Compile warnings observed when compiling parts of the
openpower-pels (or corresponding tests) under stricter
compiler warning flags of Meson.
Issues fixed:
- many unused parameters
- invalid case fall-through
- excess semi-colons
- incorrect 'const' on return-by-value type
- removal of variable length array in test case
- uncaught return from 'system' call in test case
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I8af69184042cf8661d1307a02ecf3afcab4724a1
diff --git a/test/openpower-pels/host_notifier_test.cpp b/test/openpower-pels/host_notifier_test.cpp
index d3018dc..9a49a82 100644
--- a/test/openpower-pels/host_notifier_test.cpp
+++ b/test/openpower-pels/host_notifier_test.cpp
@@ -52,7 +52,7 @@
mockHostIface = reinterpret_cast<MockHostInterface*>(hostIface.get());
- auto send = [this](uint32_t id, uint32_t size) {
+ auto send = [this](uint32_t /*id*/, uint32_t /*size*/) {
return this->mockHostIface->send(0);
};
@@ -368,10 +368,10 @@
HostNotifier notifier{repo, dataIface, std::move(hostIface)};
- auto sendFailure = [this](uint32_t id, uint32_t size) {
+ auto sendFailure = [this](uint32_t /*id*/, uint32_t /*size*/) {
return this->mockHostIface->send(1);
};
- auto sendSuccess = [this](uint32_t id, uint32_t size) {
+ auto sendSuccess = [this](uint32_t /*id*/, uint32_t /*size*/) {
return this->mockHostIface->send(0);
};
@@ -418,7 +418,7 @@
HostNotifier notifier{repo, dataIface, std::move(hostIface)};
// Every call will fail
- auto sendFailure = [this](uint32_t id, uint32_t size) {
+ auto sendFailure = [this](uint32_t /*id*/, uint32_t /*size*/) {
return this->mockHostIface->send(1);
};
diff --git a/test/openpower-pels/mocks.hpp b/test/openpower-pels/mocks.hpp
index a2c3b5a..a6a2665 100644
--- a/test/openpower-pels/mocks.hpp
+++ b/test/openpower-pels/mocks.hpp
@@ -202,7 +202,7 @@
* @param[in] fd - The file descriptor used
* @param[in] events - The event bits
*/
- void receive(sdeventplus::source::IO& source, int fd,
+ void receive(sdeventplus::source::IO& /*source*/, int /*fd*/,
uint32_t events) override
{
if (!(events & EPOLLIN))
diff --git a/test/openpower-pels/pel_manager_test.cpp b/test/openpower-pels/pel_manager_test.cpp
index a2cb5fd..4ddf81b 100644
--- a/test/openpower-pels/pel_manager_test.cpp
+++ b/test/openpower-pels/pel_manager_test.cpp
@@ -813,7 +813,11 @@
// Delete them all at once
auto logPath = getPELRepoPath() / "logs";
std::string cmd = "rm " + logPath.string() + "/*";
- system(cmd.c_str());
+
+ {
+ auto rc = system(cmd.c_str());
+ EXPECT_EQ(rc, 0);
+ }
EXPECT_EQ(countPELsInRepo(), 0);
diff --git a/test/openpower-pels/pel_utils.cpp b/test/openpower-pels/pel_utils.cpp
index b596d34..b9b46a6 100644
--- a/test/openpower-pels/pel_utils.cpp
+++ b/test/openpower-pels/pel_utils.cpp
@@ -230,9 +230,11 @@
case TestPELType::failingMTMSSection:
data.insert(data.end(), failingMTMSSection.begin(),
failingMTMSSection.end());
+ break;
case TestPELType::extendedUserDataSection:
data.insert(data.end(), extendedUserDataSection.begin(),
extendedUserDataSection.end());
+ break;
}
return data;
}
diff --git a/test/openpower-pels/stream_test.cpp b/test/openpower-pels/stream_test.cpp
index 361cfc5..d0582d7 100644
--- a/test/openpower-pels/stream_test.cpp
+++ b/test/openpower-pels/stream_test.cpp
@@ -129,9 +129,11 @@
std::vector<uint8_t> data{0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc};
Stream stream{data};
- uint8_t buf[data.size()];
- stream.read(buf, data.size());
+ auto buf = decltype(data)(data.size());
+ ASSERT_EQ(data.size(), buf.size());
+
+ stream.read(buf.data(), buf.size());
for (size_t i = 0; i < data.size(); i++)
{
@@ -142,7 +144,7 @@
}
stream.offset(6);
- stream.write(buf, 6);
+ stream.write(buf.data(), 6);
for (size_t i = 0; i < 6; i++)
{
EXPECT_EQ(buf[i], data[i + 6]);