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/.clang-tidy b/.clang-tidy
index 67c3f8a..989dd74 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -1,6 +1,84 @@
Checks: '
-*,
-readability-identifier-naming,
+bugprone-argument-comment,
+bugprone-assert-side-effect,
+bugprone-bad-signal-to-kill-thread,
+bugprone-bool-pointer-implicit-conversion,
+bugprone-branch-clone,
+bugprone-copy-constructor-init,
+bugprone-dangling-handle,
+bugprone-dynamic-static-initializers,
+bugprone-fold-init-type,
+bugprone-forward-declaration-namespace,
+bugprone-forwarding-reference-overload,
+bugprone-inaccurate-erase,
+bugprone-incorrect-roundings,
+bugprone-infinite-loop,
+bugprone-integer-division,
+bugprone-lambda-function-name,
+bugprone-macro-parentheses,
+bugprone-macro-repeated-side-effects,
+bugprone-misplaced-operator-in-strlen-in-alloc,
+bugprone-misplaced-pointer-arithmetic-in-alloc,
+bugprone-misplaced-widening-cast,
+bugprone-multiple-statement-macro,
+bugprone-narrowing-conversions,
+bugprone-no-escape,
+bugprone-not-null-terminated-result,
+bugprone-parent-virtual-call,
+bugprone-posix-return,
+bugprone-reserved-identifier,
+bugprone-signed-char-misuse,
+bugprone-sizeof-container,
+bugprone-sizeof-expression,
+bugprone-spuriously-wake-up-functions,
+bugprone-string-constructor,
+bugprone-string-integer-assignment,
+bugprone-string-literal-with-embedded-nul,
+bugprone-suspicious-enum-usage,
+bugprone-suspicious-include,
+bugprone-suspicious-memset-usage,
+bugprone-suspicious-missing-comma,
+bugprone-suspicious-semicolon,
+bugprone-suspicious-string-compare,
+bugprone-swapped-arguments,
+bugprone-terminating-continue,
+bugprone-throw-keyword-missing,
+bugprone-too-small-loop-variable,
+bugprone-undefined-memory-manipulation,
+bugprone-undelegated-constructor,
+bugprone-unhandled-self-assignment,
+bugprone-unused-raii,
+bugprone-unused-return-value,
+bugprone-use-after-move,
+bugprone-virtual-near-miss,
+cert-con36-c,
+cert-con54-cpp,
+cert-dcl03-c,
+cert-dcl16-c,
+cert-dcl21-cpp,
+cert-dcl37-c,
+cert-dcl50-cpp,
+cert-dcl51-cpp,
+cert-dcl54-cpp,
+cert-dcl58-cpp,
+cert-dcl59-cpp,
+cert-env33-c,
+cert-err09-cpp,
+cert-err34-c,
+cert-err52-cpp,
+cert-err60-cpp,
+cert-err61-cpp,
+cert-fio38-c,
+cert-flp30-c,
+cert-mem57-cpp,
+cert-msc30-c,
+cert-msc32-c,
+cert-msc50-cpp,
+cert-msc51-cpp,
+cert-oop11-cpp,
+cert-oop54-cpp,
+cert-oop57-cpp,
clang-analyzer-apiModeling.StdCLibraryFunctions,
clang-analyzer-apiModeling.TrustNonnull,
clang-analyzer-apiModeling.google.GTest,
@@ -111,33 +189,14 @@
clang-analyzer-valist.ValistBase,
clang-analyzer-webkit.NoUncountedMemberChecker,
clang-analyzer-webkit.RefCntblBaseVirtualDtor,
-cert-con36-c,
-cert-con54-cpp,
-cert-dcl03-c,
-cert-dcl16-c,
-cert-dcl21-cpp,
-cert-dcl37-c,
-cert-dcl50-cpp,
-cert-dcl51-cpp,
-cert-dcl54-cpp,
-cert-dcl58-cpp,
-cert-dcl59-cpp,
-cert-env33-c,
-cert-err09-cpp,
-cert-err34-c,
-cert-err52-cpp,
-cert-err60-cpp,
-cert-err61-cpp,
-cert-fio38-c,
-cert-flp30-c,
-cert-mem57-cpp,
-cert-msc30-c,
-cert-msc32-c,
-cert-msc50-cpp,
-cert-msc51-cpp,
-cert-oop11-cpp,
-cert-oop54-cpp,
-cert-oop57-cpp,
+misc-misplaced-const,
+misc-no-recursion,
+misc-redundant-expression,
+misc-static-assert,
+misc-throw-by-value-catch-by-reference,
+misc-unconventional-assign-operator,
+misc-uniqueptr-reset-release,
+misc-unused-using-decls,
modernize-avoid-bind,
modernize-deprecated-headers,
modernize-deprecated-ios-base-aliases,
@@ -161,82 +220,26 @@
modernize-use-transparent-functors,
modernize-use-uncaught-exceptions,
modernize-use-using,
-bugprone-argument-comment,
-bugprone-assert-side-effect,
-bugprone-bad-signal-to-kill-thread,
-bugprone-bool-pointer-implicit-conversion,
-bugprone-branch-clone,
-bugprone-copy-constructor-init,
-bugprone-dangling-handle,
-bugprone-dynamic-static-initializers,
-bugprone-fold-init-type,
-bugprone-forward-declaration-namespace,
-bugprone-forwarding-reference-overload,
-bugprone-inaccurate-erase,
-bugprone-incorrect-roundings,
-bugprone-infinite-loop,
-bugprone-integer-division,
-bugprone-lambda-function-name,
-bugprone-macro-parentheses,
-bugprone-macro-repeated-side-effects,
-bugprone-misplaced-operator-in-strlen-in-alloc,
-bugprone-misplaced-pointer-arithmetic-in-alloc,
-bugprone-misplaced-widening-cast,
-bugprone-multiple-statement-macro,
-bugprone-narrowing-conversions,
-bugprone-no-escape,
-bugprone-not-null-terminated-result,
-bugprone-parent-virtual-call,
-bugprone-posix-return,
-bugprone-reserved-identifier,
-bugprone-signed-char-misuse,
-bugprone-sizeof-container,
-bugprone-sizeof-expression,
-bugprone-spuriously-wake-up-functions,
-bugprone-string-constructor,
-bugprone-string-integer-assignment,
-bugprone-string-literal-with-embedded-nul,
-bugprone-suspicious-enum-usage,
-bugprone-suspicious-include,
-bugprone-suspicious-memset-usage,
-bugprone-suspicious-missing-comma,
-bugprone-suspicious-semicolon,
-bugprone-suspicious-string-compare,
-bugprone-swapped-arguments,
-bugprone-terminating-continue,
-bugprone-throw-keyword-missing,
-bugprone-too-small-loop-variable,
-bugprone-undefined-memory-manipulation,
-bugprone-undelegated-constructor,
-bugprone-unhandled-self-assignment,
-bugprone-unused-raii,
-bugprone-unused-return-value,
-bugprone-use-after-move,
-bugprone-virtual-near-miss,
-misc-misplaced-const,
-misc-no-recursion,
-misc-redundant-expression,
-misc-static-assert,
-misc-throw-by-value-catch-by-reference,
-misc-unconventional-assign-operator,
-misc-uniqueptr-reset-release,
-misc-unused-using-decls,
+performance-faster-string-find,
performance-for-range-copy,
performance-implicit-conversion-in-loop,
performance-inefficient-algorithm,
+performance-inefficient-string-concatenation,
performance-inefficient-vector-operation,
+performance-move-const-arg,
performance-move-constructor-init,
performance-no-automatic-move,
+performance-noexcept-move-constructor,
performance-trivially-destructible,
performance-type-promotion-in-math-fn,
performance-unnecessary-copy-initialization,
-readability-identifier-naming,
+performance-unnecessary-value-param,
readability-braces-around-statements,
readability-const-return-type,
readability-delete-null-pointer,
readability-deleted-default,
-readability-else-after-return'
-
+readability-else-after-return,
+readability-identifier-naming,
WarningsAsErrors: '*'
HeaderFilterRegex: '.*'
diff --git a/http/http_client.hpp b/http/http_client.hpp
index cc30cab..5c7b13f 100644
--- a/http/http_client.hpp
+++ b/http/http_client.hpp
@@ -306,7 +306,7 @@
const std::string& destUri) :
conn(ioc),
timer(ioc), subId(id), host(destIP), port(destPort), uri(destUri),
- retryCount(0), maxRetryAttempts(5),
+ retryCount(0), maxRetryAttempts(5), retryIntervalSecs(0),
retryPolicyAction("TerminateAfterRetries"), runningTimer(false)
{
boost::asio::ip::tcp::resolver resolver(ioc);
diff --git a/http/http_response.hpp b/http/http_response.hpp
index b521b20..7b8b5d9 100644
--- a/http/http_response.hpp
+++ b/http/http_response.hpp
@@ -37,17 +37,6 @@
Response() : stringResponse(response_type{})
{}
- Response(Response&& r)
- {
- BMCWEB_LOG_DEBUG << "Moving response containers";
- *this = std::move(r);
- }
-
- ~Response()
- {
- BMCWEB_LOG_DEBUG << this << " Destroying response";
- }
-
Response& operator=(const Response& r) = delete;
Response& operator=(Response&& r) noexcept
diff --git a/http/routing.hpp b/http/routing.hpp
index 9c6a15b..d547348 100644
--- a/http/routing.hpp
+++ b/http/routing.hpp
@@ -30,7 +30,7 @@
class BaseRule
{
public:
- BaseRule(std::string thisRule) : rule(std::move(thisRule))
+ BaseRule(const std::string& thisRule) : rule(thisRule)
{}
virtual ~BaseRule() = default;
@@ -313,7 +313,7 @@
using self_t = WebSocketRule;
public:
- WebSocketRule(std::string ruleIn) : BaseRule(std::move(ruleIn))
+ WebSocketRule(const std::string& ruleIn) : BaseRule(ruleIn)
{}
void validate() override
@@ -402,10 +402,10 @@
return *p;
}
- self_t& name(const std::string& name) noexcept
+ self_t& name(const std::string_view name) noexcept
{
self_t* self = static_cast<self_t*>(this);
- self->nameStr = std::move(name);
+ self->nameStr = name;
return *self;
}
@@ -448,7 +448,7 @@
class DynamicRule : public BaseRule, public RuleParameterTraits<DynamicRule>
{
public:
- DynamicRule(std::string ruleIn) : BaseRule(std::move(ruleIn))
+ DynamicRule(const std::string& ruleIn) : BaseRule(ruleIn)
{}
void validate() override
@@ -521,7 +521,7 @@
public:
using self_t = TaggedRule<Args...>;
- TaggedRule(const std::string& ruleIn) : BaseRule(std::move(ruleIn))
+ TaggedRule(const std::string& ruleIn) : BaseRule(ruleIn)
{}
void validate() override
@@ -612,9 +612,9 @@
}
template <typename Func>
- void operator()(const std::string& name, Func&& f)
+ void operator()(const std::string_view name, Func&& f)
{
- nameStr = std::move(name);
+ nameStr = name;
(*this).template operator()<Func>(std::forward(f));
}
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 */
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
index 7ece888..54dafb4 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -156,14 +156,14 @@
{
// The redfish log format is "<Timestamp> <MessageId>,<MessageArgs>"
// First get the Timestamp
- size_t space = logEntry.find_first_of(" ");
+ size_t space = logEntry.find_first_of(' ');
if (space == std::string::npos)
{
return -EINVAL;
}
timestamp = logEntry.substr(0, space);
// Then get the log contents
- size_t entryStart = logEntry.find_first_not_of(" ", space);
+ size_t entryStart = logEntry.find_first_not_of(' ', space);
if (entryStart == std::string::npos)
{
return -EINVAL;
@@ -247,8 +247,8 @@
// Get the Created time from the timestamp. The log timestamp is in
// RFC3339 format which matches the Redfish format except for the
// fractional seconds between the '.' and the '+', so just remove them.
- std::size_t dot = timestamp.find_first_of(".");
- std::size_t plus = timestamp.find_first_of("+");
+ std::size_t dot = timestamp.find_first_of('.');
+ std::size_t plus = timestamp.find_first_of('+');
if (dot != std::string::npos && plus != std::string::npos)
{
timestamp.erase(dot, plus - dot);
@@ -259,8 +259,8 @@
{"EventType", "Event"},
{"Severity", std::move(severity)},
{"Message", std::move(msg)},
- {"MessageId", std::move(messageID)},
- {"MessageArgs", std::move(messageArgs)},
+ {"MessageId", messageID},
+ {"MessageArgs", messageArgs},
{"EventTimestamp", std::move(timestamp)},
{"Context", customText}};
return 0;
@@ -1122,7 +1122,7 @@
std::string logEntry;
while (std::getline(logStream, logEntry))
{
- size_t space = logEntry.find_first_of(" ");
+ size_t space = logEntry.find_first_of(' ');
if (space == std::string::npos)
{
// Shouldn't enter here but lets skip it.
@@ -1346,7 +1346,7 @@
void getMetricReading(const std::string& service,
const std::string& objPath, const std::string& intf)
{
- std::size_t found = objPath.find_last_of("/");
+ std::size_t found = objPath.find_last_of('/');
if (found == std::string::npos)
{
BMCWEB_LOG_DEBUG << "Invalid objPath received";
diff --git a/redfish-core/include/server_sent_events.hpp b/redfish-core/include/server_sent_events.hpp
index ee4ad4d..578fa19 100644
--- a/redfish-core/include/server_sent_events.hpp
+++ b/redfish-core/include/server_sent_events.hpp
@@ -261,8 +261,8 @@
ServerSentEvents& operator=(ServerSentEvents&&) = delete;
ServerSentEvents(const std::shared_ptr<boost::beast::tcp_stream>& adaptor) :
- sseConn(std::move(adaptor)), state(SseConnState::startInit),
- retryCount(0), maxRetryAttempts(5)
+ sseConn(adaptor), state(SseConnState::startInit), retryCount(0),
+ maxRetryAttempts(5)
{
startSSE();
}
diff --git a/redfish-core/include/utils/collection.hpp b/redfish-core/include/utils/collection.hpp
index e73fce3..85a462a 100644
--- a/redfish-core/include/utils/collection.hpp
+++ b/redfish-core/include/utils/collection.hpp
@@ -44,7 +44,7 @@
for (const auto& object : subtree)
{
- auto iter = object.first.rfind("/");
+ auto iter = object.first.rfind('/');
if ((iter != std::string::npos) && (iter < object.first.size()))
{
members.push_back(
diff --git a/redfish-core/include/utils/fw_utils.hpp b/redfish-core/include/utils/fw_utils.hpp
index 6a2ca14..43eded6 100644
--- a/redfish-core/include/utils/fw_utils.hpp
+++ b/redfish-core/include/utils/fw_utils.hpp
@@ -69,7 +69,7 @@
for (auto& fw : *functionalFw)
{
- std::string::size_type idPos = fw.rfind("/");
+ std::string::size_type idPos = fw.rfind('/');
if (idPos == std::string::npos)
{
BMCWEB_LOG_DEBUG << "Can't parse firmware ID!";
@@ -110,7 +110,7 @@
subtree)
{
// if can't parse fw id then return
- std::string::size_type idPos = obj.first.rfind("/");
+ std::string::size_type idPos = obj.first.rfind('/');
if (idPos == std::string::npos)
{
messages::internalError(aResp->res);
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index 23c7fb9..06c6bf2 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -208,11 +208,11 @@
inline void handleRoleMapPatch(
const std::shared_ptr<AsyncResp>& asyncResp,
const std::vector<std::pair<std::string, LDAPRoleMapData>>& roleMapObjData,
- const std::string& serverType, std::vector<nlohmann::json>& input)
+ const std::string& serverType, const std::vector<nlohmann::json>& input)
{
for (size_t index = 0; index < input.size(); index++)
{
- nlohmann::json& thisJson = input[index];
+ const nlohmann::json& thisJson = input[index];
if (thisJson.is_null())
{
@@ -255,8 +255,12 @@
std::optional<std::string> remoteGroup;
std::optional<std::string> localRole;
- if (!json_util::readJson(thisJson, asyncResp->res, "RemoteGroup",
- remoteGroup, "LocalRole", localRole))
+ // This is a copy, but it's required in this case because of how
+ // readJson is structured
+ nlohmann::json thisJsonCopy = thisJson;
+ if (!json_util::readJson(thisJsonCopy, asyncResp->res,
+ "RemoteGroup", remoteGroup, "LocalRole",
+ localRole))
{
continue;
}
@@ -1112,11 +1116,8 @@
if (remoteRoleMapData)
{
- std::vector<nlohmann::json> remoteRoleMap =
- std::move(*remoteRoleMapData);
-
handleRoleMapPatch(asyncResp, confData.groupRoleList,
- serverT, remoteRoleMap);
+ serverT, *remoteRoleMapData);
}
});
}
@@ -1367,7 +1368,7 @@
{
const std::string& path =
static_cast<const std::string&>(user.first);
- std::size_t lastIndex = path.rfind("/");
+ std::size_t lastIndex = path.rfind('/');
if (lastIndex == std::string::npos)
{
lastIndex = 0;
@@ -1453,9 +1454,9 @@
}
crow::connections::systemBus->async_method_call(
- [asyncResp, username, password{std::move(password)}](
- const boost::system::error_code ec2,
- sdbusplus::message::message& m) {
+ [asyncResp, username,
+ password](const boost::system::error_code ec2,
+ sdbusplus::message::message& m) {
if (ec2)
{
userErrorMessageHandler(m.get_error(), asyncResp,
@@ -1733,10 +1734,10 @@
}
crow::connections::systemBus->async_method_call(
[this, asyncResp, username, password(std::move(password)),
- roleId(std::move(roleId)), enabled(std::move(enabled)),
+ roleId(std::move(roleId)), enabled,
newUser{std::string(*newUserName)},
- locked(std::move(locked))](const boost::system::error_code ec,
- sdbusplus::message::message& m) {
+ locked](const boost::system::error_code ec,
+ sdbusplus::message::message& m) {
if (ec)
{
userErrorMessageHandler(m.get_error(), asyncResp, newUser,
@@ -1765,9 +1766,8 @@
dbus::utility::checkDbusPathExists(
dbusObjectPath,
[dbusObjectPath(std::move(dbusObjectPath)), username,
- password(std::move(password)), roleId(std::move(roleId)),
- enabled(std::move(enabled)), locked(std::move(locked)),
- asyncResp{std::move(asyncResp)}](int rc) {
+ password(std::move(password)), roleId(std::move(roleId)), enabled,
+ locked, asyncResp{std::move(asyncResp)}](int rc) {
if (!rc)
{
messages::resourceNotFound(
@@ -1901,8 +1901,8 @@
const std::string userPath = "/xyz/openbmc_project/user/" + params[0];
crow::connections::systemBus->async_method_call(
- [asyncResp, username{std::move(params[0])}](
- const boost::system::error_code ec) {
+ [asyncResp,
+ username{params[0]}](const boost::system::error_code ec) {
if (ec)
{
messages::resourceNotFound(
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index 6fc5515..5dc1e1f 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -99,7 +99,7 @@
*/
inline long getIDFromURL(const std::string_view url)
{
- std::size_t found = url.rfind("/");
+ std::size_t found = url.rfind('/');
if (found == std::string::npos)
{
return -1;
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index 92bf1a0..b718698 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -473,8 +473,7 @@
}
if (indicatorChassis)
{
- setIndicatorLedState(asyncResp,
- std::move(*indicatorLed));
+ setIndicatorLedState(asyncResp, *indicatorLed);
}
else
{
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 05f5d55..55f1cf5 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -201,13 +201,13 @@
}
inline bool extractEthernetInterfaceData(const std::string& ethiface_id,
- const GetManagedObjects& dbus_data,
+ GetManagedObjects& dbus_data,
EthernetInterfaceData& ethData)
{
bool idFound = false;
- for (const auto& objpath : dbus_data)
+ for (auto& objpath : dbus_data)
{
- for (const auto& ifacePair : objpath.second)
+ for (auto& ifacePair : objpath.second)
{
if (objpath.first == "/xyz/openbmc_project/network/" + ethiface_id)
{
@@ -290,7 +290,7 @@
&propertyPair.second);
if (nameservers != nullptr)
{
- ethData.nameServers = std::move(*nameservers);
+ ethData.nameServers = *nameservers;
}
}
else if (propertyPair.first == "StaticNameServers")
@@ -300,8 +300,7 @@
&propertyPair.second);
if (staticNameServers != nullptr)
{
- ethData.staticNameServers =
- std::move(*staticNameServers);
+ ethData.staticNameServers = *staticNameServers;
}
}
else if (propertyPair.first == "DHCPEnabled")
@@ -320,7 +319,7 @@
&propertyPair.second);
if (domainNames != nullptr)
{
- ethData.domainnames = std::move(*domainNames);
+ ethData.domainnames = *domainNames;
}
}
}
@@ -895,7 +894,7 @@
crow::connections::systemBus->async_method_call(
[ethifaceId{std::string{ethiface_id}}, callback{std::move(callback)}](
const boost::system::error_code error_code,
- const GetManagedObjects& resp) {
+ GetManagedObjects& resp) {
EthernetInterfaceData ethData{};
boost::container::flat_set<IPv4AddressData> ipv4Data;
boost::container::flat_set<IPv6AddressData> ipv6Data;
@@ -971,7 +970,7 @@
{
// Cut out everything until last "/", ...
const std::string& ifaceId = objpath.first.str;
- std::size_t lastPos = ifaceId.rfind("/");
+ std::size_t lastPos = ifaceId.rfind('/');
if (lastPos != std::string::npos)
{
// and put it into output vector.
@@ -1264,7 +1263,8 @@
void handleDHCPPatch(const std::string& ifaceId,
const EthernetInterfaceData& ethData,
- DHCPParameters v4dhcpParms, DHCPParameters v6dhcpParms,
+ const DHCPParameters& v4dhcpParms,
+ const DHCPParameters& v6dhcpParms,
const std::shared_ptr<AsyncResp>& asyncResp)
{
bool ipv4Active = translateDHCPEnabledToBool(ethData.DHCPEnabled, true);
@@ -1601,7 +1601,7 @@
}
void handleIPv6StaticAddressesPatch(
- const std::string& ifaceId, nlohmann::json& input,
+ const std::string& ifaceId, const nlohmann::json& input,
const boost::container::flat_set<IPv6AddressData>& ipv6Data,
const std::shared_ptr<AsyncResp>& asyncResp)
{
@@ -1614,7 +1614,7 @@
size_t entryIdx = 1;
boost::container::flat_set<IPv6AddressData>::const_iterator niciPentry =
getNextStaticIpEntry(ipv6Data.cbegin(), ipv6Data.cend());
- for (nlohmann::json& thisJson : input)
+ for (const nlohmann::json& thisJson : input)
{
std::string pathString =
"IPv6StaticAddresses/" + std::to_string(entryIdx);
@@ -1623,9 +1623,10 @@
{
std::optional<std::string> address;
std::optional<uint8_t> prefixLength;
-
- if (!json_util::readJson(thisJson, asyncResp->res, "Address",
- address, "PrefixLength", prefixLength))
+ nlohmann::json thisJsonCopy = thisJson;
+ if (!json_util::readJson(thisJsonCopy, asyncResp->res,
+ "Address", address, "PrefixLength",
+ prefixLength))
{
messages::propertyValueFormatError(
asyncResp->res, thisJson.dump(), pathString);
@@ -1781,7 +1782,7 @@
// When domain name is empty then it means, that it is a network
// without domain names, and the host name itself must be treated as
// FQDN
- std::string fqdn = std::move(ethData.hostname);
+ std::string fqdn = ethData.hostname;
if (!ethData.domainnames.empty())
{
fqdn += "." + ethData.domainnames[0];
@@ -1959,8 +1960,7 @@
staticNameServers = std::move(staticNameServers),
dhcpv4 = std::move(dhcpv4), dhcpv6 = std::move(dhcpv6),
v4dhcpParms = std::move(v4dhcpParms),
- v6dhcpParms = std::move(v6dhcpParms),
- interfaceEnabled = std::move(interfaceEnabled)](
+ v6dhcpParms = std::move(v6dhcpParms), interfaceEnabled](
const bool& success, const EthernetInterfaceData& ethData,
const boost::container::flat_set<IPv4AddressData>& ipv4Data,
const boost::container::flat_set<IPv6AddressData>& ipv6Data) {
@@ -1976,8 +1976,8 @@
if (dhcpv4 || dhcpv6)
{
- handleDHCPPatch(ifaceId, ethData, std::move(v4dhcpParms),
- std::move(v6dhcpParms), asyncResp);
+ handleDHCPPatch(ifaceId, ethData, v4dhcpParms, v6dhcpParms,
+ asyncResp);
}
if (hostname)
@@ -2004,7 +2004,7 @@
// nlohmann::json objects. This makes a copy of the
// structure, and operates on that, but could be done
// more efficiently
- nlohmann::json ipv4Static = std::move(*ipv4StaticAddresses);
+ nlohmann::json ipv4Static = *ipv4StaticAddresses;
handleIPv4StaticPatch(ifaceId, ipv4Static, ipv4Data,
asyncResp);
}
@@ -2023,7 +2023,7 @@
if (ipv6StaticAddresses)
{
- nlohmann::json ipv6Static = std::move(*ipv6StaticAddresses);
+ nlohmann::json ipv6Static = *ipv6StaticAddresses;
handleIPv6StaticAddressesPatch(ifaceId, ipv6Static,
ipv6Data, asyncResp);
}
@@ -2346,10 +2346,12 @@
{
if (boost::starts_with(ifaceItem, rootInterfaceName + "_"))
{
- ifaceArray.push_back(
- {{"@odata.id",
- "/redfish/v1/Managers/bmc/EthernetInterfaces/" +
- rootInterfaceName + "/VLANs/" + ifaceItem}});
+ std::string path =
+ "/redfish/v1/Managers/bmc/EthernetInterfaces/";
+ path += rootInterfaceName;
+ path += "/VLANs/";
+ path += ifaceItem;
+ ifaceArray.push_back({{"@odata.id", std::move(path)}});
}
}
diff --git a/redfish-core/lib/hypervisor_ethernet.hpp b/redfish-core/lib/hypervisor_ethernet.hpp
index 559aa5f..eff9c3c 100644
--- a/redfish-core/lib/hypervisor_ethernet.hpp
+++ b/redfish-core/lib/hypervisor_ethernet.hpp
@@ -123,7 +123,7 @@
ifaceArray = nlohmann::json::array();
for (const std::string& iface : ifaceList)
{
- std::size_t lastPos = iface.rfind("/");
+ std::size_t lastPos = iface.rfind('/');
if (lastPos != std::string::npos)
{
ifaceArray.push_back(
@@ -522,7 +522,7 @@
}
void handleHypervisorIPv4StaticPatch(
- const std::string& ifaceId, nlohmann::json&& input,
+ const std::string& ifaceId, const nlohmann::json& input,
const std::shared_ptr<AsyncResp>& asyncResp)
{
if ((!input.is_array()) || input.empty())
@@ -535,7 +535,7 @@
// Hypervisor considers the first IP address in the array list
// as the Hypervisor's virtual management interface supports single IPv4
// address
- nlohmann::json& thisJson = input[0];
+ const nlohmann::json& thisJson = input[0];
// For the error string
std::string pathString = "IPv4StaticAddresses/1";
@@ -545,8 +545,8 @@
std::optional<std::string> address;
std::optional<std::string> subnetMask;
std::optional<std::string> gateway;
-
- if (!json_util::readJson(thisJson, asyncResp->res, "Address",
+ nlohmann::json thisJsonCopy = thisJson;
+ if (!json_util::readJson(thisJsonCopy, asyncResp->res, "Address",
address, "SubnetMask", subnetMask,
"Gateway", gateway))
{
@@ -818,8 +818,7 @@
ifaceId,
[this, asyncResp, ifaceId, hostName = std::move(hostName),
ipv4StaticAddresses = std::move(ipv4StaticAddresses),
- ipv4DHCPEnabled = std::move(ipv4DHCPEnabled),
- dhcpv4 = std::move(dhcpv4)](
+ ipv4DHCPEnabled, dhcpv4 = std::move(dhcpv4)](
const bool& success, const EthernetInterfaceData& ethData,
const boost::container::flat_set<IPv4AddressData>&) {
if (!success)
@@ -831,8 +830,8 @@
if (ipv4StaticAddresses)
{
- nlohmann::json ipv4Static = std::move(*ipv4StaticAddresses);
- nlohmann::json& ipv4Json = ipv4Static[0];
+ const nlohmann::json& ipv4Static = *ipv4StaticAddresses;
+ const nlohmann::json& ipv4Json = ipv4Static[0];
// Check if the param is 'null'. If its null, it means that
// user wants to delete the IP address. Deleting the IP
// address is allowed only if its statically configured.
@@ -846,8 +845,8 @@
}
else
{
- handleHypervisorIPv4StaticPatch(
- ifaceId, std::move(ipv4Static), asyncResp);
+ handleHypervisorIPv4StaticPatch(ifaceId, ipv4Static,
+ asyncResp);
}
}
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index c5b7b9d..04f82f7 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -444,7 +444,7 @@
nlohmann::json& thisEntry = entriesArray.back();
const std::string& path =
static_cast<const std::string&>(object.first);
- std::size_t lastPos = path.rfind("/");
+ std::size_t lastPos = path.rfind('/');
if (lastPos == std::string::npos)
{
continue;
@@ -843,7 +843,7 @@
for (const std::string& path : subTreePaths)
{
- std::size_t pos = path.rfind("/");
+ std::size_t pos = path.rfind('/');
if (pos != std::string::npos)
{
std::string logID = path.substr(pos + 1);
@@ -1072,14 +1072,14 @@
{
// The redfish log format is "<Timestamp> <MessageId>,<MessageArgs>"
// First get the Timestamp
- size_t space = logEntry.find_first_of(" ");
+ size_t space = logEntry.find_first_of(' ');
if (space == std::string::npos)
{
return 1;
}
std::string timestamp = logEntry.substr(0, space);
// Then get the log contents
- size_t entryStart = logEntry.find_first_not_of(" ", space);
+ size_t entryStart = logEntry.find_first_not_of(' ', space);
if (entryStart == std::string::npos)
{
return 1;
@@ -1139,8 +1139,8 @@
// Get the Created time from the timestamp. The log timestamp is in RFC3339
// format which matches the Redfish format except for the fractional seconds
// between the '.' and the '+', so just remove them.
- std::size_t dot = timestamp.find_first_of(".");
- std::size_t plus = timestamp.find_first_of("+");
+ std::size_t dot = timestamp.find_first_of('.');
+ std::size_t plus = timestamp.find_first_of('+');
if (dot != std::string::npos && plus != std::string::npos)
{
timestamp.erase(dot, plus - dot);
@@ -1156,7 +1156,7 @@
{"Id", logEntryID},
{"Message", std::move(msg)},
{"MessageId", std::move(messageID)},
- {"MessageArgs", std::move(messageArgs)},
+ {"MessageArgs", messageArgs},
{"EntryType", "Event"},
{"Severity", std::move(severity)},
{"Created", std::move(timestamp)}};
@@ -2529,7 +2529,7 @@
for (const std::string& objpath : resp)
{
// Get the log ID
- std::size_t lastPos = objpath.rfind("/");
+ std::size_t lastPos = objpath.rfind('/');
if (lastPos == std::string::npos)
{
continue;
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 3992c94..26c2125 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -1900,7 +1900,7 @@
if (odataId)
{
- setActiveFirmwareImage(response, std::move(*odataId));
+ setActiveFirmwareImage(response, *odataId);
}
}
}
@@ -1954,10 +1954,10 @@
* @return void
*/
void setActiveFirmwareImage(const std::shared_ptr<AsyncResp>& aResp,
- const std::string&& runningFirmwareTarget)
+ const std::string& runningFirmwareTarget)
{
// Get the Id from /redfish/v1/UpdateService/FirmwareInventory/<Id>
- std::string::size_type idPos = runningFirmwareTarget.rfind("/");
+ std::string::size_type idPos = runningFirmwareTarget.rfind('/');
if (idPos == std::string::npos)
{
messages::propertyValueNotInList(aResp->res, runningFirmwareTarget,
@@ -1999,7 +1999,7 @@
{
const std::string& path =
static_cast<const std::string&>(object.first);
- std::size_t idPos2 = path.rfind("/");
+ std::size_t idPos2 = path.rfind('/');
if (idPos2 == std::string::npos)
{
diff --git a/redfish-core/lib/memory.hpp b/redfish-core/lib/memory.hpp
index 4fa7c11..e7b1113 100644
--- a/redfish-core/lib/memory.hpp
+++ b/redfish-core/lib/memory.hpp
@@ -543,7 +543,7 @@
std::get_if<std::string>(&property.second);
if (value != nullptr)
{
- size_t idx = value->rfind(".");
+ size_t idx = value->rfind('.');
if (idx == std::string::npos ||
idx + 1 >= value->size())
{
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index 8752cf8..31efc75 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -82,7 +82,7 @@
&propertyPair.second);
if (ntpServers != nullptr)
{
- ntpData = std::move(*ntpServers);
+ ntpData = *ntpServers;
}
}
else if (propertyPair.first == "DomainName")
@@ -92,7 +92,7 @@
&propertyPair.second);
if (domainNames != nullptr)
{
- dnData = std::move(*domainNames);
+ dnData = *domainNames;
}
}
}
@@ -240,10 +240,11 @@
asyncResp->res.jsonValue["NTP"]["NTPServers"] = ntpServers;
if (hostName.empty() == false)
{
- std::string fqdn = std::move(hostName);
+ std::string fqdn = hostName;
if (domainNames.empty() == false)
{
- fqdn += "." + domainNames[0];
+ fqdn += ".";
+ fqdn += domainNames[0];
}
asyncResp->res.jsonValue["FQDN"] = std::move(fqdn);
}
@@ -317,7 +318,7 @@
std::get<NET_PROTO_LISTEN_STREAM>(
(*responsePtr)[0]);
std::size_t lastColonPos =
- listenStream.rfind(":");
+ listenStream.rfind(':');
if (lastColonPos == std::string::npos)
{
// Not a port
diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp
index 5051696..1c7a009 100644
--- a/redfish-core/lib/power.hpp
+++ b/redfish-core/lib/power.hpp
@@ -176,7 +176,7 @@
for (const std::string& chassis : chassisPaths)
{
size_t len = std::string::npos;
- size_t lastPos = chassis.rfind("/");
+ size_t lastPos = chassis.rfind('/');
if (lastPos == std::string::npos)
{
continue;
@@ -185,7 +185,7 @@
if (lastPos == chassis.size() - 1)
{
size_t end = lastPos;
- lastPos = chassis.rfind("/", lastPos - 1);
+ lastPos = chassis.rfind('/', lastPos - 1);
if (lastPos == std::string::npos)
{
continue;
diff --git a/redfish-core/lib/redfish_util.hpp b/redfish-core/lib/redfish_util.hpp
index 5701712..acaea53 100644
--- a/redfish-core/lib/redfish_util.hpp
+++ b/redfish-core/lib/redfish_util.hpp
@@ -41,7 +41,7 @@
return;
}
- std::size_t idPos = subtree[0].first.rfind("/");
+ std::size_t idPos = subtree[0].first.rfind('/');
if (idPos == std::string::npos ||
(idPos + 1) >= subtree[0].first.size())
{
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 6480861..567cb0c 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -388,7 +388,7 @@
std::string chassisName;
for (const std::string& chassis : chassisPaths)
{
- std::size_t lastPos = chassis.rfind("/");
+ std::size_t lastPos = chassis.rfind('/');
if (lastPos == std::string::npos)
{
BMCWEB_LOG_ERROR << "Failed to find '/' in " << chassis;
@@ -441,7 +441,7 @@
std::string chassisName;
for (const std::string& chassis : chassisPaths)
{
- std::size_t lastPos = chassis.rfind("/");
+ std::size_t lastPos = chassis.rfind('/');
if (lastPos == std::string::npos)
{
BMCWEB_LOG_ERROR << "Failed to find '/' in " << chassis;
@@ -1149,7 +1149,7 @@
sensorsAsyncResp->res);
return;
}
- size_t lastSlash = path.rfind("/");
+ size_t lastSlash = path.rfind('/');
if (lastSlash == std::string::npos)
{
// this should be impossible
@@ -1180,7 +1180,7 @@
sensorsAsyncResp->res.jsonValue["Fans"];
for (const std::string& item : *collection)
{
- lastSlash = item.rfind("/");
+ lastSlash = item.rfind('/');
// make a copy as collection is const
std::string itemName =
item.substr(lastSlash + 1);
@@ -2617,13 +2617,13 @@
auto getInventoryItemsCb =
[SensorsAsyncResp, sensorNames, connections,
objectMgrPaths](
- std::shared_ptr<std::vector<InventoryItem>>
+ const std::shared_ptr<std::vector<InventoryItem>>&
inventoryItems) {
BMCWEB_LOG_DEBUG << "getInventoryItemsCb enter";
// Get sensor data and store results in JSON
getSensorData(SensorsAsyncResp, sensorNames,
connections, objectMgrPaths,
- std::move(inventoryItems));
+ inventoryItems);
BMCWEB_LOG_DEBUG << "getInventoryItemsCb exit";
};
@@ -2657,10 +2657,10 @@
BMCWEB_LOG_DEBUG << "getChassisData enter";
auto getChassisCb =
[SensorsAsyncResp](
- std::shared_ptr<boost::container::flat_set<std::string>>
+ const std::shared_ptr<boost::container::flat_set<std::string>>&
sensorNames) {
BMCWEB_LOG_DEBUG << "getChassisCb enter";
- processSensorList(SensorsAsyncResp, std::move(sensorNames));
+ processSensorList(SensorsAsyncResp, sensorNames);
BMCWEB_LOG_DEBUG << "getChassisCb exit";
};
SensorsAsyncResp->res.jsonValue["Redundancy"] = nlohmann::json::array();
@@ -2686,7 +2686,7 @@
{
for (std::string_view chassisSensor : sensorsList)
{
- std::size_t pos = chassisSensor.rfind("/");
+ std::size_t pos = chassisSensor.rfind('/');
if (pos >= (chassisSensor.size() - 1))
{
continue;
@@ -3042,7 +3042,7 @@
{
BMCWEB_LOG_DEBUG << "Adding sensor: " << sensor;
- std::size_t lastPos = sensor.rfind("/");
+ std::size_t lastPos = sensor.rfind('/');
if (lastPos == std::string::npos ||
lastPos + 1 >= sensor.size())
{
@@ -3129,7 +3129,7 @@
std::vector<std::string>>>>&
object) {
std::string_view sensor = object.first;
- std::size_t lastPos = sensor.rfind("/");
+ std::size_t lastPos = sensor.rfind('/');
if (lastPos == std::string::npos ||
lastPos + 1 >= sensor.size())
{
diff --git a/redfish-core/lib/storage.hpp b/redfish-core/lib/storage.hpp
index e89db65..7167503 100644
--- a/redfish-core/lib/storage.hpp
+++ b/redfish-core/lib/storage.hpp
@@ -101,7 +101,7 @@
for (const std::string& objpath : storageList)
{
- std::size_t lastPos = objpath.rfind("/");
+ std::size_t lastPos = objpath.rfind('/');
if (lastPos == std::string::npos ||
(objpath.size() <= lastPos + 1))
{
@@ -139,7 +139,7 @@
root = nlohmann::json::array();
for (const auto& [path, interfaceDict] : subtree)
{
- std::size_t lastPos = path.rfind("/");
+ std::size_t lastPos = path.rfind('/');
if (lastPos == std::string::npos ||
(path.size() <= lastPos + 1))
{
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 9f304b0..80d3e05 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -202,11 +202,10 @@
crow::connections::systemBus->async_method_call(
[aResp, service{connection.first},
- path(std::move(path))](
- const boost::system::error_code ec2,
- const std::vector<
- std::pair<std::string, VariantType>>&
- properties) {
+ path](const boost::system::error_code ec2,
+ const std::vector<
+ std::pair<std::string, VariantType>>&
+ properties) {
if (ec2)
{
BMCWEB_LOG_ERROR
@@ -309,11 +308,10 @@
crow::connections::systemBus->async_method_call(
[aResp, service{connection.first},
- path(std::move(path))](
- const boost::system::error_code ec2,
- const std::vector<
- std::pair<std::string, VariantType>>&
- properties) {
+ path](const boost::system::error_code ec2,
+ const std::vector<
+ std::pair<std::string, VariantType>>&
+ properties) {
if (ec2)
{
BMCWEB_LOG_ERROR
@@ -854,7 +852,8 @@
*
* @return None.
*/
-inline void getBootSource(std::shared_ptr<AsyncResp> aResp, bool oneTimeEnabled)
+inline void getBootSource(const std::shared_ptr<AsyncResp>& aResp,
+ bool oneTimeEnabled)
{
std::string bootDbusObj =
oneTimeEnabled ? "/xyz/openbmc_project/control/host0/boot/one_time"
@@ -894,7 +893,7 @@
"xyz.openbmc_project.Settings", bootDbusObj,
"org.freedesktop.DBus.Properties", "Get",
"xyz.openbmc_project.Control.Boot.Source", "BootSource");
- getBootMode(std::move(aResp), std::move(bootDbusObj));
+ getBootMode(aResp, bootDbusObj);
}
/**
@@ -1141,8 +1140,8 @@
*/
inline void setBootModeOrSource(std::shared_ptr<AsyncResp> aResp,
bool oneTimeEnabled,
- std::optional<std::string> bootSource,
- std::optional<std::string> bootEnable)
+ const std::optional<std::string>& bootSource,
+ const std::optional<std::string>& bootEnable)
{
std::string bootSourceStr =
"xyz.openbmc_project.Control.Boot.Source.Sources.Default";
@@ -1287,8 +1286,7 @@
BMCWEB_LOG_DEBUG << "Got one time: " << *oneTimePtr;
- setBootModeOrSource(aResp, *oneTimePtr, std::move(bootSource),
- std::move(bootEnable));
+ setBootModeOrSource(aResp, *oneTimePtr, bootSource, bootEnable);
},
"xyz.openbmc_project.Settings",
"/xyz/openbmc_project/control/host0/boot/one_time",
@@ -1305,7 +1303,7 @@
* @return None.
*/
inline void setAutomaticRetry(const std::shared_ptr<AsyncResp>& aResp,
- const std::string&& automaticRetryConfig)
+ const std::string& automaticRetryConfig)
{
BMCWEB_LOG_DEBUG << "Set Automatic Retry.";
@@ -2008,8 +2006,7 @@
{
return;
}
- setWDTProperties(asyncResp, std::move(wdtEnable),
- std::move(wdtTimeOutAction));
+ setWDTProperties(asyncResp, wdtEnable, wdtTimeOutAction);
}
if (bootProps)
@@ -2032,13 +2029,13 @@
}
if (automaticRetryConfig)
{
- setAutomaticRetry(asyncResp, std::move(*automaticRetryConfig));
+ setAutomaticRetry(asyncResp, *automaticRetryConfig);
}
}
if (indicatorLed)
{
- setIndicatorLedState(asyncResp, std::move(*indicatorLed));
+ setIndicatorLedState(asyncResp, *indicatorLed);
}
if (powerRestorePolicy)
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index 7e6a0b8..a247ad0 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -415,7 +415,7 @@
{
// Must be option 2
// Verify ImageURI has transfer protocol in it
- size_t separator = imageURI.find(":");
+ size_t separator = imageURI.find(':');
if ((separator == std::string::npos) ||
((separator + 1) > imageURI.size()))
{
@@ -451,7 +451,7 @@
}
// Format should be <IP or Hostname>/<file> for imageURI
- size_t separator = imageURI.find("/");
+ size_t separator = imageURI.find('/');
if ((separator == std::string::npos) ||
((separator + 1) > imageURI.size()))
{
@@ -726,7 +726,7 @@
{
// if can't parse fw id then return
std::size_t idPos;
- if ((idPos = obj.first.rfind("/")) == std::string::npos)
+ if ((idPos = obj.first.rfind('/')) == std::string::npos)
{
messages::internalError(asyncResp->res);
BMCWEB_LOG_DEBUG << "Can't parse firmware ID!!";
@@ -913,7 +913,7 @@
// swInvPurpose is of format:
// xyz.openbmc_project.Software.Version.VersionPurpose.ABC
// Translate this to "ABC image"
- size_t endDesc = swInvPurpose->rfind(".");
+ size_t endDesc = swInvPurpose->rfind('.');
if (endDesc == std::string::npos)
{
messages::internalError(asyncResp->res);
diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
index f6a56f6..a921dcb 100644
--- a/redfish-core/lib/virtual_media.hpp
+++ b/redfish-core/lib/virtual_media.hpp
@@ -160,7 +160,7 @@
nlohmann::json item;
const std::string& path =
static_cast<const std::string&>(object.first);
- std::size_t lastIndex = path.rfind("/");
+ std::size_t lastIndex = path.rfind('/');
if (lastIndex == std::string::npos)
{
continue;
@@ -203,7 +203,7 @@
const std::string& path =
static_cast<const std::string&>(item.first);
- std::size_t lastItem = path.rfind("/");
+ std::size_t lastItem = path.rfind('/');
if (lastItem == std::string::npos)
{
continue;
@@ -521,7 +521,7 @@
const std::string& path =
static_cast<const std::string&>(object.first);
- std::size_t lastIndex = path.rfind("/");
+ std::size_t lastIndex = path.rfind('/');
if (lastIndex == std::string::npos)
{
continue;
@@ -903,7 +903,7 @@
const std::string& path =
static_cast<const std::string&>(object.first);
- std::size_t lastIndex = path.rfind("/");
+ std::size_t lastIndex = path.rfind('/');
if (lastIndex == std::string::npos)
{
continue;