Fix .clang-tidy
camelLower is not a type, camelBack is.
Changes were made automatically with clang-tidy --fix-errors
To be able to apply changes automatically, the only way I've found that
works was to build the version of clang/clang-tidy that yocto has, and
run the fix script within bitbake -c devshell bmcweb. Unfortunately,
yocto has clang-tidy 11, which can apparently find a couple extra errors
in tests we already had enabled. As such, a couple of those are also
included.
Tested:
Ran clang-tidy-11 and got a clean result.
Signed-off-by: Ed Tanous <ed@tanous.net>
Change-Id: I9d1080b67f0342229c2f267160849445c065ca51
diff --git a/include/authorization.hpp b/include/authorization.hpp
index c0a84b6..e32d9ad 100644
--- a/include/authorization.hpp
+++ b/include/authorization.hpp
@@ -37,12 +37,12 @@
#ifdef BMCWEB_ENABLE_BASIC_AUTHENTICATION
static std::shared_ptr<persistent_data::UserSession>
performBasicAuth(const boost::asio::ip::address& clientIp,
- std::string_view auth_header)
+ std::string_view authHeader)
{
BMCWEB_LOG_DEBUG << "[AuthMiddleware] Basic authentication";
std::string authData;
- std::string_view param = auth_header.substr(strlen("Basic "));
+ std::string_view param = authHeader.substr(strlen("Basic "));
if (!crow::utility::base64Decode(param, authData))
{
return nullptr;
@@ -86,11 +86,11 @@
#ifdef BMCWEB_ENABLE_SESSION_AUTHENTICATION
static std::shared_ptr<persistent_data::UserSession>
- performTokenAuth(std::string_view auth_header)
+ performTokenAuth(std::string_view authHeader)
{
BMCWEB_LOG_DEBUG << "[AuthMiddleware] Token authentication";
- std::string_view token = auth_header.substr(strlen("Token "));
+ std::string_view token = authHeader.substr(strlen("Token "));
auto session =
persistent_data::SessionStore::getInstance().loginSessionByToken(token);
return session;
@@ -132,7 +132,7 @@
return nullptr;
}
startIndex += sizeof("SESSION=") - 1;
- auto endIndex = cookieValue.find(";", startIndex);
+ auto endIndex = cookieValue.find(';', startIndex);
if (endIndex == std::string::npos)
{
endIndex = cookieValue.size();
diff --git a/include/dbus_monitor.hpp b/include/dbus_monitor.hpp
index 74d38f6..18085a9 100644
--- a/include/dbus_monitor.hpp
+++ b/include/dbus_monitor.hpp
@@ -27,9 +27,9 @@
sessions;
inline int onPropertyUpdate(sd_bus_message* m, void* userdata,
- sd_bus_error* ret_error)
+ sd_bus_error* retError)
{
- if (ret_error == nullptr || sd_bus_error_is_set(ret_error))
+ if (retError == nullptr || sd_bus_error_is_set(retError))
{
BMCWEB_LOG_ERROR << "Got sdbus error on match";
return 0;
diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp
index 8ba9a57..9927024 100644
--- a/include/dbus_utility.hpp
+++ b/include/dbus_utility.hpp
@@ -90,8 +90,8 @@
crow::connections::systemBus->async_method_call(
[callback{std::move(callback)}](const boost::system::error_code ec,
- const GetObjectType& object_names) {
- callback(!ec && object_names.size() != 0);
+ const GetObjectType& objectNames) {
+ callback(!ec && objectNames.size() != 0);
},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
diff --git a/include/hostname_monitor.hpp b/include/hostname_monitor.hpp
index 7b8283e..1b04af5 100644
--- a/include/hostname_monitor.hpp
+++ b/include/hostname_monitor.hpp
@@ -32,9 +32,9 @@
}
inline int onPropertyUpdate(sd_bus_message* m, void* /* userdata */,
- sd_bus_error* ret_error)
+ sd_bus_error* retError)
{
- if (ret_error == nullptr || sd_bus_error_is_set(ret_error))
+ if (retError == nullptr || sd_bus_error_is_set(retError))
{
BMCWEB_LOG_ERROR << "Got sdbus error on match";
return 0;
diff --git a/include/nbd_proxy.hpp b/include/nbd_proxy.hpp
index 7ad80a6..7b90e90 100644
--- a/include/nbd_proxy.hpp
+++ b/include/nbd_proxy.hpp
@@ -248,12 +248,12 @@
std::shared_ptr<NbdProxyServer>>
sessions;
-void requestRoutes(App& app)
+inline void requestRoutes(App& app)
{
BMCWEB_ROUTE(app, "/nbd/<str>")
.websocket()
.onopen([](crow::websocket::Connection& conn,
- std::shared_ptr<bmcweb::AsyncResp> asyncResp) {
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
BMCWEB_LOG_DEBUG << "nbd-proxy.onopen(" << &conn << ")";
auto getUserInfoHandler =
@@ -399,9 +399,8 @@
std::remove((*socketValue).c_str());
sessions[&conn] = std::make_shared<NbdProxyServer>(
- conn, std::move(*socketValue),
- std::move(*endpointValue),
- std::move(*endpointObjectPath));
+ conn, *socketValue, *endpointValue,
+ *endpointObjectPath);
sessions[&conn]->run();
};
diff --git a/include/obmc_console.hpp b/include/obmc_console.hpp
index 17c106f..cdb1990 100644
--- a/include/obmc_console.hpp
+++ b/include/obmc_console.hpp
@@ -45,9 +45,9 @@
doingWrite = true;
hostSocket->async_write_some(
boost::asio::buffer(inputBuffer.data(), inputBuffer.size()),
- [](boost::beast::error_code ec, std::size_t bytes_written) {
+ [](boost::beast::error_code ec, std::size_t bytesWritten) {
doingWrite = false;
- inputBuffer.erase(0, bytes_written);
+ inputBuffer.erase(0, bytesWritten);
if (ec == boost::asio::error::eof)
{
@@ -148,8 +148,7 @@
}
})
.onmessage([]([[maybe_unused]] crow::websocket::Connection& conn,
- const std::string& data,
- [[maybe_unused]] bool is_binary) {
+ const std::string& data, [[maybe_unused]] bool isBinary) {
inputBuffer += data;
doWrite();
});
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index e970de5..466ddc1 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -83,7 +83,7 @@
[transaction, processName{std::string(processName)},
objectPath{std::string(objectPath)}](
const boost::system::error_code ec,
- const std::string& introspect_xml) {
+ const std::string& introspectXml) {
if (ec)
{
BMCWEB_LOG_ERROR
@@ -97,7 +97,7 @@
tinyxml2::XMLDocument doc;
- doc.Parse(introspect_xml.c_str());
+ doc.Parse(introspectXml.c_str());
tinyxml2::XMLNode* pRoot = doc.FirstChildElement("node");
if (pRoot == nullptr)
{
@@ -222,21 +222,21 @@
};
inline void getManagedObjectsForEnumerate(
- const std::string& object_name, const std::string& object_manager_path,
- const std::string& connection_name,
+ const std::string& objectName, const std::string& objectManagerPath,
+ const std::string& connectionName,
const std::shared_ptr<InProgressEnumerateData>& transaction)
{
- BMCWEB_LOG_DEBUG << "getManagedObjectsForEnumerate " << object_name
- << " object_manager_path " << object_manager_path
- << " connection_name " << connection_name;
+ BMCWEB_LOG_DEBUG << "getManagedObjectsForEnumerate " << objectName
+ << " object_manager_path " << objectManagerPath
+ << " connection_name " << connectionName;
crow::connections::systemBus->async_method_call(
- [transaction, object_name,
- connection_name](const boost::system::error_code ec,
- const dbus::utility::ManagedObjectType& objects) {
+ [transaction, objectName,
+ connectionName](const boost::system::error_code ec,
+ const dbus::utility::ManagedObjectType& objects) {
if (ec)
{
- BMCWEB_LOG_ERROR << "GetManagedObjects on path " << object_name
- << " on connection " << connection_name
+ BMCWEB_LOG_ERROR << "GetManagedObjects on path " << objectName
+ << " on connection " << connectionName
<< " failed with code " << ec;
return;
}
@@ -246,7 +246,7 @@
for (const auto& objectPath : objects)
{
- if (boost::starts_with(objectPath.first.str, object_name))
+ if (boost::starts_with(objectPath.first.str, objectName))
{
BMCWEB_LOG_DEBUG << "Reading object "
<< objectPath.first.str;
@@ -273,23 +273,23 @@
{
getManagedObjectsForEnumerate(
objectPath.first.str, objectPath.first.str,
- connection_name, transaction);
+ connectionName, transaction);
}
}
}
},
- connection_name, object_manager_path,
- "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
+ connectionName, objectManagerPath, "org.freedesktop.DBus.ObjectManager",
+ "GetManagedObjects");
}
inline void findObjectManagerPathForEnumerate(
- const std::string& object_name, const std::string& connection_name,
+ const std::string& objectName, const std::string& connectionName,
const std::shared_ptr<InProgressEnumerateData>& transaction)
{
- BMCWEB_LOG_DEBUG << "Finding objectmanager for path " << object_name
- << " on connection:" << connection_name;
+ BMCWEB_LOG_DEBUG << "Finding objectmanager for path " << objectName
+ << " on connection:" << connectionName;
crow::connections::systemBus->async_method_call(
- [transaction, object_name, connection_name](
+ [transaction, objectName, connectionName](
const boost::system::error_code ec,
const boost::container::flat_map<
std::string, boost::container::flat_map<
@@ -297,7 +297,7 @@
objects) {
if (ec)
{
- BMCWEB_LOG_ERROR << "GetAncestors on path " << object_name
+ BMCWEB_LOG_ERROR << "GetAncestors on path " << objectName
<< " failed with code " << ec;
return;
}
@@ -306,11 +306,11 @@
{
for (const auto& connectionGroup : pathGroup.second)
{
- if (connectionGroup.first == connection_name)
+ if (connectionGroup.first == connectionName)
{
// Found the object manager path for this resource.
getManagedObjectsForEnumerate(
- object_name, pathGroup.first, connection_name,
+ objectName, pathGroup.first, connectionName,
transaction);
return;
}
@@ -319,7 +319,7 @@
},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetAncestors", object_name,
+ "xyz.openbmc_project.ObjectMapper", "GetAncestors", objectName,
std::array<const char*, 1>{"org.freedesktop.DBus.ObjectManager"});
}
@@ -515,17 +515,17 @@
return ret;
}
-inline int convertJsonToDbus(sd_bus_message* m, const std::string& arg_type,
- const nlohmann::json& input_json)
+inline int convertJsonToDbus(sd_bus_message* m, const std::string& argType,
+ const nlohmann::json& inputJson)
{
int r = 0;
- BMCWEB_LOG_DEBUG << "Converting " << input_json.dump()
- << " to type: " << arg_type;
- const std::vector<std::string> argTypes = dbusArgSplit(arg_type);
+ BMCWEB_LOG_DEBUG << "Converting " << inputJson.dump()
+ << " to type: " << argType;
+ const std::vector<std::string> argTypes = dbusArgSplit(argType);
// Assume a single object for now.
- const nlohmann::json* j = &input_json;
- nlohmann::json::const_iterator jIt = input_json.begin();
+ const nlohmann::json* j = &inputJson;
+ nlohmann::json::const_iterator jIt = inputJson.begin();
for (const std::string& argCode : argTypes)
{
@@ -533,7 +533,7 @@
// iterator, and increment it for the next loop
if (argTypes.size() > 1)
{
- if (jIt == input_json.end())
+ if (jIt == inputJson.end())
{
return -2;
}
@@ -770,7 +770,7 @@
return r;
}
- r = convertJsonToDbus(m, containedType, input_json);
+ r = convertJsonToDbus(m, containedType, inputJson);
if (r < 0)
{
return r;
@@ -794,7 +794,7 @@
}
nlohmann::json::const_iterator it = j->begin();
- for (const std::string& argCode2 : dbusArgSplit(arg_type))
+ for (const std::string& argCode2 : dbusArgSplit(argType))
{
if (it == j->end())
{
@@ -1314,8 +1314,8 @@
crow::connections::systemBus->async_method_call(
[transaction, connectionName{std::string(connectionName)}](
const boost::system::error_code ec,
- const std::string& introspect_xml) {
- BMCWEB_LOG_DEBUG << "got xml:\n " << introspect_xml;
+ const std::string& introspectXml) {
+ BMCWEB_LOG_DEBUG << "got xml:\n " << introspectXml;
if (ec)
{
BMCWEB_LOG_ERROR
@@ -1325,7 +1325,7 @@
}
tinyxml2::XMLDocument doc;
- doc.Parse(introspect_xml.data(), introspect_xml.size());
+ doc.Parse(introspectXml.data(), introspectXml.size());
tinyxml2::XMLNode* pRoot = doc.FirstChildElement("node");
if (pRoot == nullptr)
{
@@ -1611,12 +1611,12 @@
crow::connections::systemBus->async_method_call(
[objectPath, asyncResp](const boost::system::error_code ec,
- GetSubTreeType& object_names) {
+ GetSubTreeType& objectNames) {
auto transaction = std::make_shared<InProgressEnumerateData>(
objectPath, asyncResp);
transaction->subtree =
- std::make_shared<GetSubTreeType>(std::move(object_names));
+ std::make_shared<GetSubTreeType>(std::move(objectNames));
if (ec)
{
@@ -1652,8 +1652,8 @@
std::vector<std::pair<std::string, std::vector<std::string>>>;
crow::connections::systemBus->async_method_call(
[&res, path, propertyName](const boost::system::error_code ec,
- const GetObjectType& object_names) {
- if (ec || object_names.size() <= 0)
+ const GetObjectType& objectNames) {
+ if (ec || objectNames.size() <= 0)
{
setErrorResponse(res, boost::beast::http::status::not_found,
notFoundDesc, notFoundMsg);
@@ -1665,7 +1665,7 @@
// The mapper should never give us an empty interface names
// list, but check anyway
for (const std::pair<std::string, std::vector<std::string>>&
- connection : object_names)
+ connection : objectNames)
{
const std::vector<std::string>& interfaceNames =
connection.second;
@@ -1820,8 +1820,8 @@
crow::connections::systemBus->async_method_call(
[transaction](const boost::system::error_code ec2,
- const GetObjectType& object_names) {
- if (!ec2 && object_names.size() <= 0)
+ const GetObjectType& objectNames) {
+ if (!ec2 && objectNames.size() <= 0)
{
setErrorResponse(transaction->res,
boost::beast::http::status::not_found,
@@ -1830,7 +1830,7 @@
}
for (const std::pair<std::string, std::vector<std::string>>&
- connection : object_names)
+ connection : objectNames)
{
const std::string& connectionName = connection.first;
@@ -2214,8 +2214,8 @@
.methods(boost::beast::http::verb::get)(
[](const crow::Request&, crow::Response& res,
- const std::string& Connection) {
- introspectObjects(Connection, "/",
+ const std::string& connection) {
+ introspectObjects(connection, "/",
std::make_shared<bmcweb::AsyncResp>(res));
});
@@ -2284,7 +2284,7 @@
crow::connections::systemBus->async_method_call(
[asyncResp, processName,
objectPath](const boost::system::error_code ec,
- const std::string& introspect_xml) {
+ const std::string& introspectXml) {
if (ec)
{
BMCWEB_LOG_ERROR
@@ -2296,7 +2296,7 @@
}
tinyxml2::XMLDocument doc;
- doc.Parse(introspect_xml.c_str());
+ doc.Parse(introspectXml.c_str());
tinyxml2::XMLNode* pRoot =
doc.FirstChildElement("node");
if (pRoot == nullptr)
@@ -2311,7 +2311,7 @@
return;
}
- BMCWEB_LOG_DEBUG << introspect_xml;
+ BMCWEB_LOG_DEBUG << introspectXml;
asyncResp->res.jsonValue = {
{"status", "ok"},
{"bus_name", processName},
@@ -2347,7 +2347,7 @@
crow::connections::systemBus->async_method_call(
[asyncResp, processName, objectPath,
interfaceName](const boost::system::error_code ec,
- const std::string& introspect_xml) {
+ const std::string& introspectXml) {
if (ec)
{
BMCWEB_LOG_ERROR
@@ -2359,7 +2359,7 @@
}
tinyxml2::XMLDocument doc;
- doc.Parse(introspect_xml.data(), introspect_xml.size());
+ doc.Parse(introspectXml.data(), introspectXml.size());
tinyxml2::XMLNode* pRoot =
doc.FirstChildElement("node");
if (pRoot == nullptr)
diff --git a/include/ssl_key_handler.hpp b/include/ssl_key_handler.hpp
index 93fe5d0..39e83d7 100644
--- a/include/ssl_key_handler.hpp
+++ b/include/ssl_key_handler.hpp
@@ -355,7 +355,7 @@
}
inline std::shared_ptr<boost::asio::ssl::context>
- getSslContext(const std::string& ssl_pem_file)
+ getSslContext(const std::string& sslPemFile)
{
std::shared_ptr<boost::asio::ssl::context> mSslContext =
std::make_shared<boost::asio::ssl::context>(
@@ -376,9 +376,9 @@
BMCWEB_LOG_DEBUG << "Using default TrustStore location: " << trustStorePath;
mSslContext->add_verify_path(trustStorePath);
- mSslContext->use_certificate_file(ssl_pem_file,
+ mSslContext->use_certificate_file(sslPemFile,
boost::asio::ssl::context::pem);
- mSslContext->use_private_key_file(ssl_pem_file,
+ mSslContext->use_private_key_file(sslPemFile,
boost::asio::ssl::context::pem);
// Set up EC curves to auto (boost asio doesn't have a method for this)