Turn on ALL perf checks
1st, alphabetize the tidy-list for good housekeeping.
Next, enable all the clang-tidy performance checks, and resolve all the
issues. most of the issues boil down to:
1. Using std::move on const variables. This does nothing.
2. Passing big variables (like std::string) by value.
3. Using double quotes on a find call, which constructs an intermediate
string, rather than using the character overload.
Tested
Loaded on system, logged in successfully and pulled down webui-vue. No
new errors.
Walked the Redfish tree a bit, and observed no new problems.
Ran redfish service validator. Got no new failures (although there are
a lot of log service deprecation warnings that we should look at).
Signed-off-by: Ed Tanous <ed@tanous.net>
Change-Id: I2238958c4b22c1e554e09a0a1787c744bdbca43e
diff --git a/include/authorization.hpp b/include/authorization.hpp
index 0ccd1e5..e965508 100644
--- a/include/authorization.hpp
+++ b/include/authorization.hpp
@@ -231,7 +231,7 @@
static void authenticate(
crow::Request& req, Response& res,
- [[maybe_unused]] std::weak_ptr<persistent_data::UserSession> session)
+ [[maybe_unused]] const std::weak_ptr<persistent_data::UserSession>& session)
{
if (isOnWhitelist(req))
{
@@ -244,7 +244,7 @@
#ifdef BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION
if (req.session == nullptr && authMethodsConfig.tls)
{
- req.session = performTLSAuth(req, res, std::move(session));
+ req.session = performTLSAuth(req, res, session);
}
#endif
if (req.session == nullptr && authMethodsConfig.xtoken)
diff --git a/include/dbus_monitor.hpp b/include/dbus_monitor.hpp
index aeab103..74d38f6 100644
--- a/include/dbus_monitor.hpp
+++ b/include/dbus_monitor.hpp
@@ -212,8 +212,10 @@
conn.close();
return;
}
- std::string ifaceMatchString =
- propertiesMatchString + ",arg0='" + interface + "'";
+ std::string ifaceMatchString = propertiesMatchString;
+ ifaceMatchString += ",arg0='";
+ ifaceMatchString += interface;
+ ifaceMatchString += "'";
BMCWEB_LOG_DEBUG << "Creating match "
<< ifaceMatchString;
thisSession.matches.emplace_back(
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index a369ef2..e970de5 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -2444,12 +2444,21 @@
const char* name = methods->Attribute("name");
if (name != nullptr)
{
- methodsArray.push_back(
- {{"name", name},
- {"uri", "/bus/system/" + processName +
- objectPath + "/" +
- interfaceName + "/" + name},
- {"args", argsArray}});
+ std::string uri;
+ uri.reserve(14 + processName.size() +
+ objectPath.size() +
+ interfaceName.size() +
+ strlen(name));
+ uri += "/bus/system/";
+ uri += processName;
+ uri += objectPath;
+ uri += "/";
+ uri += interfaceName;
+ uri += "/";
+ uri += name;
+ methodsArray.push_back({{"name", name},
+ {"uri", std::move(uri)},
+ {"args", argsArray}});
}
methods = methods->NextSiblingElement("method");
}
diff --git a/include/pam_authenticate.hpp b/include/pam_authenticate.hpp
index 3e5c691..12f19c0 100644
--- a/include/pam_authenticate.hpp
+++ b/include/pam_authenticate.hpp
@@ -25,15 +25,16 @@
std::strncpy(pass, appPass, appPassSize + 1);
- *resp = reinterpret_cast<pam_response*>(
- calloc(static_cast<size_t>(numMsg), sizeof(struct pam_response)));
-
- if (resp == nullptr)
+ void* ptr =
+ calloc(static_cast<size_t>(numMsg), sizeof(struct pam_response));
+ if (ptr == nullptr)
{
free(pass);
return PAM_AUTH_ERR;
}
+ *resp = reinterpret_cast<pam_response*>(ptr);
+
for (int i = 0; i < numMsg; ++i)
{
/* Ignore all PAM messages except prompting for hidden input */