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
diff --git a/.clang-tidy b/.clang-tidy
index ffb6b06..0a7f665 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -274,6 +274,7 @@
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 41c09a9..5f352d3 100644
--- a/http/http_client.hpp
+++ b/http/http_client.hpp
@@ -309,7 +309,6 @@
// Lets close connection and start from resolve.
self->doClose();
});
- return;
}
void handleConnState()
@@ -407,8 +406,6 @@
{
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 0ea4887..0ed0bbc 100644
--- a/include/dbus_utility.hpp
+++ b/include/dbus_utility.hpp
@@ -104,12 +104,7 @@
}
}
}
- 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 4434e1f..10f0a9a 100644
--- a/include/ibm/locks.hpp
+++ b/include/ibm/locks.hpp
@@ -544,12 +544,7 @@
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 57c9d83..876ceb3 100644
--- a/include/ibm/management_console_rest.hpp
+++ b/include/ibm/management_console_rest.hpp
@@ -257,7 +257,6 @@
asyncResp->res.jsonValue["Actions"]["#IBMConfigFiles.DeleteAll"] = {
{"target",
"/ibm/v1/Host/ConfigFiles/Actions/IBMConfigFiles.DeleteAll"}};
- return;
}
inline void
@@ -280,7 +279,6 @@
<< ec;
}
}
- return;
}
inline void
@@ -297,7 +295,6 @@
{"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 @@
fileData = {std::istreambuf_iterator<char>(readfile),
std::istreambuf_iterator<char>()};
asyncResp->res.jsonValue["Data"] = fileData;
- return;
}
inline void
@@ -362,7 +358,6 @@
asyncResp->res.result(boost::beast::http::status::not_found);
asyncResp->res.jsonValue["Description"] = resourceNotFoundMsg;
}
- return;
}
inline void
@@ -385,7 +380,6 @@
return;
}
redfish::EventServiceManager::getInstance().sendBroadcastMsg(broadcastMsg);
- return;
}
inline void handleFileUrl(const crow::Request& req,
@@ -545,7 +539,6 @@
{
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 @@
returnJson["SegmentFlags"] = myArray;
asyncResp->res.jsonValue["Record"] = returnJson;
- return;
}
inline void
diff --git a/include/login_routes.hpp b/include/login_routes.hpp
index 858968b..c918cdd 100644
--- a/include/login_routes.hpp
+++ b/include/login_routes.hpp
@@ -253,7 +253,6 @@
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 b8a916c..556a635 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -660,7 +660,6 @@
subValue->updateRetryConfig(retryAttempts, retryTimeoutInterval);
subValue->updateRetryPolicy();
}
- return;
}
void loadOldBehavior()
@@ -1064,8 +1063,6 @@
// 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 dd3cd36..79703f0 100644
--- a/redfish-core/include/server_sent_events.hpp
+++ b/redfish-core/include/server_sent_events.hpp
@@ -248,8 +248,6 @@
break;
}
}
-
- return;
}
public:
diff --git a/redfish-core/include/utils/fw_utils.hpp b/redfish-core/include/utils/fw_utils.hpp
index 027c851..a0758d9 100644
--- a/redfish-core/include/utils/fw_utils.hpp
+++ b/redfish-core/include/utils/fw_utils.hpp
@@ -253,8 +253,6 @@
std::array<const char*, 1>{
"xyz.openbmc_project.Software.Version"});
});
-
- return;
}
/**
@@ -405,8 +403,6 @@
return;
}
});
-
- return;
}
} // namespace fw_util
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index 0bf03cc..d89710b 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -158,8 +158,6 @@
{
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 7c2da78..e4e5eb9 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -1853,11 +1853,7 @@
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 f35db24..9f40725 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -3364,12 +3364,8 @@
// 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 af0fd12..8e07881 100644
--- a/redfish-core/lib/processor.hpp
+++ b/redfish-core/lib/processor.hpp
@@ -201,8 +201,6 @@
}
}
}
-
- return;
}
inline void getCpuDataByService(std::shared_ptr<bmcweb::AsyncResp> aResp,