diff options
author | Ed Tanous <edtanous@google.com> | 2022-01-25 21:07:45 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-02-07 19:41:37 +0300 |
commit | dcf2ebc020257bc298d948fcb4da761c284e84d7 (patch) | |
tree | 5e1ee6dc29480f7b26cd39bf9a9bd0d6759bfdaa | |
parent | 104f09c95af2b3068e7afd655e4cebcad2bf0617 (diff) | |
download | bmcweb-dcf2ebc020257bc298d948fcb4da761c284e84d7.tar.xz |
Enable readability-redundant-control-flow checks
These checks are a nice addition to our static analysis, as they
simplify code quite a bit, as can be seen by this diff being negative
lines.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I60ede4ad23d7e5337e811d70ddcab24bf8986891
-rw-r--r-- | .clang-tidy | 1 | ||||
-rw-r--r-- | http/http_client.hpp | 3 | ||||
-rw-r--r-- | include/dbus_utility.hpp | 7 | ||||
-rw-r--r-- | include/ibm/locks.hpp | 7 | ||||
-rw-r--r-- | include/ibm/management_console_rest.hpp | 8 | ||||
-rw-r--r-- | include/login_routes.hpp | 1 | ||||
-rw-r--r-- | redfish-core/include/event_service_manager.hpp | 3 | ||||
-rw-r--r-- | redfish-core/include/server_sent_events.hpp | 2 | ||||
-rw-r--r-- | redfish-core/include/utils/fw_utils.hpp | 4 | ||||
-rw-r--r-- | redfish-core/lib/account_service.hpp | 2 | ||||
-rw-r--r-- | redfish-core/lib/ethernet.hpp | 6 | ||||
-rw-r--r-- | redfish-core/lib/log_services.hpp | 6 | ||||
-rw-r--r-- | redfish-core/lib/processor.hpp | 2 |
13 files changed, 5 insertions, 47 deletions
diff --git a/.clang-tidy b/.clang-tidy index ffb6b06fe2..0a7f665751 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -274,6 +274,7 @@ readability-delete-null-pointer, readability-deleted-default, readability-else-after-return, readability-named-parameter, +readability-redundant-control-flow, readability-identifier-naming' WarningsAsErrors: '*' diff --git a/http/http_client.hpp b/http/http_client.hpp index 41c09a942a..5f352d3674 100644 --- a/http/http_client.hpp +++ b/http/http_client.hpp @@ -309,7 +309,6 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> // Lets close connection and start from resolve. self->doClose(); }); - return; } void handleConnState() @@ -407,8 +406,6 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> { BMCWEB_LOG_ERROR << "Request queue is full. So ignoring data."; } - - return; } void setRetryConfig(const uint32_t retryAttempts, diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp index 0ea4887393..0ed0bbc83e 100644 --- a/include/dbus_utility.hpp +++ b/include/dbus_utility.hpp @@ -104,12 +104,7 @@ inline bool getNthStringFromPath(const std::string& path, int index, } } } - if (count < index) - { - return false; - } - - return true; + return count >= index; } template <typename Callback> diff --git a/include/ibm/locks.hpp b/include/ibm/locks.hpp index 4434e1f117..10f0a9a66b 100644 --- a/include/ibm/locks.hpp +++ b/include/ibm/locks.hpp @@ -544,12 +544,7 @@ inline bool Lock::checkByte(uint64_t resourceId1, uint64_t resourceId2, BMCWEB_LOG_DEBUG << "Comparing bytes " << std::to_string(pPosition) << "," << std::to_string(qPosition); - if (pPosition != qPosition) - { - return false; - } - - return true; + return pPosition == qPosition; } inline bool Lock::isConflictRecord(const LockRequest& refLockRecord1, diff --git a/include/ibm/management_console_rest.hpp b/include/ibm/management_console_rest.hpp index 57c9d8328f..876ceb3d18 100644 --- a/include/ibm/management_console_rest.hpp +++ b/include/ibm/management_console_rest.hpp @@ -257,7 +257,6 @@ inline void asyncResp->res.jsonValue["Actions"]["#IBMConfigFiles.DeleteAll"] = { {"target", "/ibm/v1/Host/ConfigFiles/Actions/IBMConfigFiles.DeleteAll"}}; - return; } inline void @@ -280,7 +279,6 @@ inline void << ec; } } - return; } inline void @@ -297,7 +295,6 @@ inline void {"target", "/ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock"}}; asyncResp->res.jsonValue["Actions"]["#LockService.GetLockList"] = { {"target", "/ibm/v1/HMC/LockService/Actions/LockService.GetLockList"}}; - return; } inline void handleFileGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, @@ -330,7 +327,6 @@ inline void handleFileGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, fileData = {std::istreambuf_iterator<char>(readfile), std::istreambuf_iterator<char>()}; asyncResp->res.jsonValue["Data"] = fileData; - return; } inline void @@ -362,7 +358,6 @@ inline void asyncResp->res.result(boost::beast::http::status::not_found); asyncResp->res.jsonValue["Description"] = resourceNotFoundMsg; } - return; } inline void @@ -385,7 +380,6 @@ inline void return; } redfish::EventServiceManager::getInstance().sendBroadcastMsg(broadcastMsg); - return; } inline void handleFileUrl(const crow::Request& req, @@ -545,7 +539,6 @@ inline void { crow::ibm_mc_lock::Lock::getInstance().releaseLock(req.session->uniqueId); asyncResp->res.result(boost::beast::http::status::ok); - return; } inline void @@ -603,7 +596,6 @@ inline void returnJson["SegmentFlags"] = myArray; asyncResp->res.jsonValue["Record"] = returnJson; - return; } inline void diff --git a/include/login_routes.hpp b/include/login_routes.hpp index 858968bfd9..c918cddd1a 100644 --- a/include/login_routes.hpp +++ b/include/login_routes.hpp @@ -253,7 +253,6 @@ inline void requestRoutes(App& app) persistent_data::SessionStore::getInstance().removeSession( session); } - return; }); } } // namespace login_routes diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp index b8a916c10f..556a635917 100644 --- a/redfish-core/include/event_service_manager.hpp +++ b/redfish-core/include/event_service_manager.hpp @@ -660,7 +660,6 @@ class EventServiceManager subValue->updateRetryConfig(retryAttempts, retryTimeoutInterval); subValue->updateRetryPolicy(); } - return; } void loadOldBehavior() @@ -1064,8 +1063,6 @@ class EventServiceManager // Control would be here when Redfish file is created. // Reset File Position as new file is created redfishLogFilePosition = 0; - - return; } void cacheRedfishLogFile() diff --git a/redfish-core/include/server_sent_events.hpp b/redfish-core/include/server_sent_events.hpp index dd3cd36dcc..79703f02eb 100644 --- a/redfish-core/include/server_sent_events.hpp +++ b/redfish-core/include/server_sent_events.hpp @@ -248,8 +248,6 @@ class ServerSentEvents : public std::enable_shared_from_this<ServerSentEvents> break; } } - - return; } public: diff --git a/redfish-core/include/utils/fw_utils.hpp b/redfish-core/include/utils/fw_utils.hpp index 027c85154a..a0758d925c 100644 --- a/redfish-core/include/utils/fw_utils.hpp +++ b/redfish-core/include/utils/fw_utils.hpp @@ -253,8 +253,6 @@ inline void std::array<const char*, 1>{ "xyz.openbmc_project.Software.Version"}); }); - - return; } /** @@ -405,8 +403,6 @@ inline void return; } }); - - return; } } // namespace fw_util diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp index 0bf03cc51c..d89710b1a3 100644 --- a/redfish-core/lib/account_service.hpp +++ b/redfish-core/lib/account_service.hpp @@ -158,8 +158,6 @@ inline void userErrorMessageHandler( { messages::internalError(asyncResp->res); } - - return; } inline void parseLDAPConfigData(nlohmann::json& jsonResponse, diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp index 7c2da78843..e4e5eb9d62 100644 --- a/redfish-core/lib/ethernet.hpp +++ b/redfish-core/lib/ethernet.hpp @@ -1853,11 +1853,7 @@ inline void parseInterfaceData(nlohmann::json& jsonResponse, inline bool verifyNames(const std::string& parent, const std::string& iface) { - if (!boost::starts_with(iface, parent + "_")) - { - return false; - } - return true; + return boost::starts_with(iface, parent + "_"); } inline void requestEthernetInterfacesRoutes(App& app) diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp index f35db24723..9f40725d61 100644 --- a/redfish-core/lib/log_services.hpp +++ b/redfish-core/lib/log_services.hpp @@ -3364,12 +3364,8 @@ inline static bool parsePostCode(const std::string& postCodeID, // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) end = split[1].data() + split[1].size(); auto [ptrValue, ecValue] = std::from_chars(start, end, currentValue); - if (ptrValue != end || ecValue != std::errc()) - { - return false; - } - return true; + return ptrValue == end && ecValue != std::errc(); } inline void requestRoutesPostCodesEntryAdditionalData(App& app) diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp index af0fd123d8..8e078816d9 100644 --- a/redfish-core/lib/processor.hpp +++ b/redfish-core/lib/processor.hpp @@ -201,8 +201,6 @@ inline void getCpuDataByInterface( } } } - - return; } inline void getCpuDataByService(std::shared_ptr<bmcweb::AsyncResp> aResp, |