phosphor-ipmi-blobs: Code Health Cleanup
Removed the following errors.
- the 'empty' method should be used to check for emptiness instead of
comparing to an empty object
- using decl '*' is unused
- redundant return statement at the end of a function with a void return
type
- variable 'managerReturned' defined in a header file; variable
definitions in header files can lead to ODR violations
- function 'getBlobManager' defined in a header file; function
definitions in header files can lead to ODR violations
Change-Id: I70c3db92c81b1f1b2468814605e0b2dfd358b401
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/ipmi.cpp b/ipmi.cpp
index f1f034c..07f6cd8 100644
--- a/ipmi.cpp
+++ b/ipmi.cpp
@@ -104,7 +104,7 @@
std::memcpy(&request, reqBuf, sizeof(request));
std::string blobId = mgr->getBlobId(request.blobIdx);
- if (blobId == "")
+ if (blobId.empty())
{
return IPMI_CC_INVALID_FIELD_REQUEST;
}
@@ -204,7 +204,7 @@
std::memcpy(replyCmdBuf, &reply, sizeof(reply));
/* If there is metadata, copy it over. */
- if (meta->metadata.size())
+ if (!meta->metadata.empty())
{
uint8_t* metadata = &replyCmdBuf[sizeof(reply)];
std::memcpy(metadata, meta->metadata.data(), reply.metadataLen);
@@ -299,7 +299,7 @@
*/
(*dataLen) = sizeof(struct BmcBlobReadRx);
- if (result.size())
+ if (!result.empty())
{
uint8_t* output = &replyCmdBuf[sizeof(struct BmcBlobReadRx)];
std::memcpy(output, result.data(), result.size());
diff --git a/test/ipmi_close_unittest.cpp b/test/ipmi_close_unittest.cpp
index 74a8efb..af2e03e 100644
--- a/test/ipmi_close_unittest.cpp
+++ b/test/ipmi_close_unittest.cpp
@@ -9,10 +9,7 @@
namespace blobs
{
-using ::testing::Invoke;
-using ::testing::NotNull;
using ::testing::Return;
-using ::testing::StrEq;
// ipmid.hpp isn't installed where we can grab it and this value is per BMC
// SoC.
diff --git a/test/ipmi_delete_unittest.cpp b/test/ipmi_delete_unittest.cpp
index 777e417..3336b2d 100644
--- a/test/ipmi_delete_unittest.cpp
+++ b/test/ipmi_delete_unittest.cpp
@@ -9,7 +9,6 @@
namespace blobs
{
-using ::testing::_;
using ::testing::Return;
using ::testing::StrEq;
diff --git a/test/manager_mock.hpp b/test/manager_mock.hpp
index 9ffd3a2..5a94cf4 100644
--- a/test/manager_mock.hpp
+++ b/test/manager_mock.hpp
@@ -36,15 +36,4 @@
(uint16_t, uint32_t, const std::vector<uint8_t>&), (override));
};
-/*
- * Provide a one-off implementation for now.
- * To test this, set managerReturned as you need.
- */
-ManagerInterface* managerReturned;
-
-ManagerInterface* getBlobManager()
-{
- return managerReturned;
-}
-
} // namespace blobs
diff --git a/test/process_unittest.cpp b/test/process_unittest.cpp
index 47359cc..b72fe9a 100644
--- a/test/process_unittest.cpp
+++ b/test/process_unittest.cpp
@@ -13,7 +13,6 @@
using ::testing::_;
using ::testing::Eq;
-using ::testing::Invoke;
using ::testing::Return;
using ::testing::StrictMock;
@@ -50,7 +49,6 @@
EXPECT_TRUE(lPtr);
EXPECT_TRUE(rPtr);
EXPECT_EQ(*lPtr, *rPtr);
- return;
}
} // namespace