clang-tidy: Enable readability-convert-member-functions-to-static
This check finds non-static member functions that can be made
static because the functions don’t use this.
This check also triggers readability-static-accessed-through
-instance check as we are trying to access a static member
function through an instance.
Change-Id: Ia0867db019db8e40e710bdd4025e030061f7a992
Signed-off-by: Pavithra Barithaya <pavithrabarithaya07@gmail.com>
diff --git a/.clang-tidy b/.clang-tidy
index a5de905..89403ad 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -232,6 +232,7 @@
readability-braces-around-statements,
readability-const-return-type,
readability-container-size-empty,
+readability-convert-member-functions-to-static,
readability-delete-null-pointer,
readability-deleted-default,
readability-function-size,
diff --git a/activation.hpp b/activation.hpp
index 891e582..22e0445 100644
--- a/activation.hpp
+++ b/activation.hpp
@@ -351,7 +351,8 @@
*
* @return true if verification successful and false otherwise
*/
- bool verifySignature(const fs::path& imageDir, const fs::path& confDir);
+ static bool verifySignature(const fs::path& imageDir,
+ const fs::path& confDir);
/** @brief Called when image verification fails. */
void onVerifyFailed();
diff --git a/image_verify.hpp b/image_verify.hpp
index 0675eaa..14ff93a 100644
--- a/image_verify.hpp
+++ b/image_verify.hpp
@@ -182,15 +182,16 @@
* @param[in] - Hash function name
* @return true if signature verification was successful, false if not
*/
- bool verifyFile(const fs::path& file, const fs::path& signature,
- const fs::path& publicKey, const std::string& hashFunc);
+ static bool verifyFile(const fs::path& file, const fs::path& signature,
+ const fs::path& publicKey,
+ const std::string& hashFunc);
/**
* @brief Create RSA object from the public key
* @param[in] - publickey
* @param[out] - RSA Object.
*/
- inline EVP_PKEY_Ptr createPublicRSA(const fs::path& publicKey);
+ static inline EVP_PKEY_Ptr createPublicRSA(const fs::path& publicKey);
/**
* @brief Memory map the file
@@ -198,7 +199,7 @@
* @param[in] - file size
* @param[out] - Custom Mmap address
*/
- CustomMap mapFile(const fs::path& path, size_t size);
+ static CustomMap mapFile(const fs::path& path, size_t size);
/**
* @brief Verify the full file signature using public key and hash function
diff --git a/item_updater.cpp b/item_updater.cpp
index 2215b71..641a2a5 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -560,7 +560,7 @@
void ItemUpdater::reset()
{
- helper.factoryReset();
+ phosphor::software::updater::Helper::factoryReset();
info("BMC factory reset will take effect upon reboot.");
}
diff --git a/item_updater.hpp b/item_updater.hpp
index a0607fe..ad538e9 100644
--- a/item_updater.hpp
+++ b/item_updater.hpp
@@ -290,8 +290,8 @@
* true if all image files are found in BMC tarball
* false if one of image files is missing
*/
- bool checkImage(const std::string& filePath,
- const std::vector<std::string>& imageList);
+ static bool checkImage(const std::string& filePath,
+ const std::vector<std::string>& imageList);
/** @brief Persistent MinimumVersion D-Bus object */
std::unique_ptr<MinimumVersion> minimumVersionObject;
diff --git a/item_updater_helper.hpp b/item_updater_helper.hpp
index c0584a2..2b10e8f 100644
--- a/item_updater_helper.hpp
+++ b/item_updater_helper.hpp
@@ -47,7 +47,7 @@
void cleanup();
/** @brief Do factory reset */
- void factoryReset();
+ static void factoryReset();
/** @brief Remove the image with the flash id
*
diff --git a/sync_manager.hpp b/sync_manager.hpp
index 98e7b95..82fe266 100644
--- a/sync_manager.hpp
+++ b/sync_manager.hpp
@@ -32,7 +32,7 @@
* @param[in] entryPath - The file or directory to process.
* @param[out] result - 0 if successful.
*/
- int processEntry(int mask, const fs::path& entryPath);
+ static int processEntry(int mask, const fs::path& entryPath);
};
} // namespace manager
diff --git a/sync_manager_main.cpp b/sync_manager_main.cpp
index 758abcf..8f70fe4 100644
--- a/sync_manager_main.cpp
+++ b/sync_manager_main.cpp
@@ -22,12 +22,10 @@
try
{
- phosphor::software::manager::Sync syncManager;
-
using namespace phosphor::software::manager;
- phosphor::software::manager::SyncWatch watch(
- *loop, std::bind(std::mem_fn(&Sync::processEntry), &syncManager,
- std::placeholders::_1, std::placeholders::_2));
+ auto syncCallback = std::bind(
+ &Sync::processEntry, std::placeholders::_1, std::placeholders::_2);
+ phosphor::software::manager::SyncWatch watch(*loop, syncCallback);
bus.attach_event(loop, SD_EVENT_PRIORITY_NORMAL);
sd_event_loop(loop);
}
diff --git a/test/utest.cpp b/test/utest.cpp
index 5d3d10d..778c845 100644
--- a/test/utest.cpp
+++ b/test/utest.cpp
@@ -175,7 +175,7 @@
static constexpr auto testPath = "/tmp/_testSig";
protected:
- void command(const std::string& cmd)
+ static void command(const std::string& cmd)
{
auto val = std::system(cmd.c_str());
if (val)
@@ -354,7 +354,7 @@
class FileTest : public testing::Test
{
protected:
- std::string readFile(const fs::path& path)
+ static std::string readFile(const fs::path& path)
{
std::ifstream f(path, std::ios::in);
if (!f.is_open())
@@ -369,7 +369,7 @@
return result;
}
- void command(const std::string& cmd)
+ static void command(const std::string& cmd)
{
auto val = std::system(cmd.c_str());
if (val)