Fix a bunch of warnings
using the list of warnings from here:
https://github.com/lefticus/cppbestpractices/blob/e73393f25a85f83fed7399d8b65cb117d00b2231/02-Use_the_Tools_Available.md#L100
Seems like a good place to start, and would improve things a bit
type-wise. This patchset attempts to correct all the issues in one
shot.
Tested:
It builds. Will test various subsystems that have been touched
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Change-Id: I588c26440e5a97f718a0f0ea74cc84107d53aa1e
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index 9dac7e4..a183f68 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -299,7 +299,7 @@
<< ",LocalRole=" << *localRole;
crow::connections::systemBus->async_method_call(
- [asyncResp, serverType, index, localRole,
+ [asyncResp, serverType, localRole,
remoteGroup](const boost::system::error_code ec) {
if (ec)
{
@@ -422,43 +422,43 @@
for (const auto& property : interface.second)
{
- const std::string* value =
+ const std::string* strValue =
std::get_if<std::string>(
&property.second);
- if (value == nullptr)
+ if (strValue == nullptr)
{
continue;
}
if (property.first == "LDAPServerURI")
{
- confData.uri = *value;
+ confData.uri = *strValue;
}
else if (property.first == "LDAPBindDN")
{
- confData.bindDN = *value;
+ confData.bindDN = *strValue;
}
else if (property.first == "LDAPBaseDN")
{
- confData.baseDN = *value;
+ confData.baseDN = *strValue;
}
else if (property.first ==
"LDAPSearchScope")
{
- confData.searchScope = *value;
+ confData.searchScope = *strValue;
}
else if (property.first ==
"GroupNameAttribute")
{
- confData.groupAttribute = *value;
+ confData.groupAttribute = *strValue;
}
else if (property.first ==
"UserNameAttribute")
{
- confData.userNameAttribute = *value;
+ confData.userNameAttribute = *strValue;
}
else if (property.first == "LDAPType")
{
- confData.serverType = *value;
+ confData.serverType = *strValue;
}
}
}
@@ -469,22 +469,22 @@
LDAPRoleMapData roleMapData{};
for (const auto& property : interface.second)
{
- const std::string* value =
+ const std::string* strValue =
std::get_if<std::string>(
&property.second);
- if (value == nullptr)
+ if (strValue == nullptr)
{
continue;
}
if (property.first == "GroupName")
{
- roleMapData.groupName = *value;
+ roleMapData.groupName = *strValue;
}
else if (property.first == "Privilege")
{
- roleMapData.privilege = *value;
+ roleMapData.privilege = *strValue;
}
}
@@ -1518,7 +1518,7 @@
crow::connections::systemBus->async_method_call(
[this, asyncResp, username, password(std::move(password)),
roleId(std::move(roleId)), enabled(std::move(enabled)),
- newUser{std::string(*newUserName)}, locked(std::move(locked))](
+ newUser{*newUserName}, locked(std::move(locked))](
const boost::system::error_code ec) {
if (ec)
{
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index 111bcec..89d5634 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -458,13 +458,7 @@
*crow::connections::systemBus, match,
[asyncResp, service, objectPath,
certURI](sdbusplus::message::message &m) {
- boost::system::error_code ec;
- timeout.cancel(ec);
- if (ec)
- {
- BMCWEB_LOG_ERROR << "error canceling timer " << ec;
- csrMatcher = nullptr;
- }
+ timeout.cancel();
if (m.is_method_error())
{
BMCWEB_LOG_ERROR << "Dbus method error!!!";
@@ -489,7 +483,7 @@
}
});
crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code ec,
+ [asyncResp](const boost::system::error_code &ec,
const std::string &path) {
if (ec)
{
@@ -531,14 +525,16 @@
{
break;
}
- const std::string_view key(tokenBegin, i - tokenBegin);
+ const std::string_view key(tokenBegin,
+ static_cast<size_t>(i - tokenBegin));
i++;
tokenBegin = i;
while (i != value.end() && *i != ',')
{
i++;
}
- const std::string_view val(tokenBegin, i - tokenBegin);
+ const std::string_view val(tokenBegin,
+ static_cast<size_t>(i - tokenBegin));
if (key == "L")
{
out["City"] = val;
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index 8c13414..b08ab25 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -148,7 +148,7 @@
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/Intrusion", int32_t(1),
+ "/xyz/openbmc_project/Intrusion", 1,
std::array<const char *, 1>{"xyz.openbmc_project.Chassis.Intrusion"});
}
@@ -217,7 +217,7 @@
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
- "/xyz/openbmc_project/inventory", int32_t(0), interfaces);
+ "/xyz/openbmc_project/inventory", 0, interfaces);
}
};
@@ -397,7 +397,7 @@
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", int32_t(0), interfaces);
+ "/xyz/openbmc_project/inventory", 0, interfaces);
getPhysicalSecurityData(asyncResp);
}
diff --git a/redfish-core/lib/cpudimm.hpp b/redfish-core/lib/cpudimm.hpp
index 2e084d4..d8d4191 100644
--- a/redfish-core/lib/cpudimm.hpp
+++ b/redfish-core/lib/cpudimm.hpp
@@ -63,7 +63,7 @@
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", int32_t(0), collectionName);
+ "/xyz/openbmc_project/inventory", 0, collectionName);
}
void getCpuDataByInterface(std::shared_ptr<AsyncResp> aResp,
@@ -360,8 +360,8 @@
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", int32_t(0), inventoryItems);
-};
+ "/xyz/openbmc_project/inventory", 0, inventoryItems);
+}
void getDimmDataByService(std::shared_ptr<AsyncResp> aResp,
const std::string &dimmId, const std::string &service,
@@ -481,9 +481,9 @@
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", int32_t(0),
+ "/xyz/openbmc_project/inventory", 0,
std::array<const char *, 1>{"xyz.openbmc_project.Inventory.Item.Dimm"});
-};
+}
class ProcessorCollection : public Node
{
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index ff37330..b06acf0 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -320,9 +320,10 @@
std::pair<
boost::container::flat_set<IPv6AddressData>::iterator,
bool>
- it = ipv6_config.insert(
- {objpath.first.str.substr(ipv6PathStart.size())});
+ it = ipv6_config.insert(IPv6AddressData{});
IPv6AddressData &ipv6_address = *it.first;
+ ipv6_address.id =
+ objpath.first.str.substr(ipv6PathStart.size());
for (auto &property : interface.second)
{
if (property.first == "Address")
@@ -392,9 +393,10 @@
std::pair<
boost::container::flat_set<IPv4AddressData>::iterator,
bool>
- it = ipv4_config.insert(
- {objpath.first.str.substr(ipv4PathStart.size())});
+ it = ipv4_config.insert(IPv4AddressData{});
IPv4AddressData &ipv4_address = *it.first;
+ ipv4_address.id =
+ objpath.first.str.substr(ipv4PathStart.size());
for (auto &property : interface.second)
{
if (property.first == "Address")
@@ -858,7 +860,7 @@
},
"xyz.openbmc_project.Network", "/xyz/openbmc_project/network",
"org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
-};
+}
/**
* Function that retrieves all Ethernet Interfaces available through Network
@@ -911,7 +913,7 @@
},
"xyz.openbmc_project.Network", "/xyz/openbmc_project/network",
"org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
-};
+}
/**
* EthernetCollection derived class for delivering Ethernet Collection Schema
@@ -1169,7 +1171,7 @@
return;
}
- int entryIdx = 1;
+ unsigned entryIdx = 1;
// Find the first static IP address currently active on the NIC and
// match it to the first JSON element in the IPv4StaticAddresses array.
// Match each subsequent JSON element to the next static IP programmed
@@ -1201,8 +1203,8 @@
// not explicitly provided are assumed to be unmodified from the
// current state of the interface. Merge existing state into the
// current request.
- const std::string *addr;
- const std::string *gw;
+ const std::string *addr = nullptr;
+ const std::string *gw = nullptr;
uint8_t prefixLength = 0;
bool errorInEntry = false;
if (address)
@@ -1288,6 +1290,13 @@
if (NICIPentry != ipv4Data.cend())
{
+ if (gw != nullptr || addr != nullptr)
+ {
+ // Shouldn't be possible based on errorInEntry, but
+ // it flags -wmaybe-uninitialized in the compiler,
+ // so defend against that
+ return;
+ }
deleteAndCreateIPv4(ifaceId, NICIPentry->id, prefixLength,
*gw, *addr, asyncResp);
NICIPentry =
@@ -1365,7 +1374,7 @@
"IPv6StaticAddresses");
return;
}
- int entryIdx = 1;
+ size_t entryIdx = 1;
boost::container::flat_set<IPv6AddressData>::const_iterator NICIPentry =
GetNextStaticIPEntry(ipv6Data.cbegin(), ipv6Data.cend());
for (nlohmann::json &thisJson : input)
@@ -1874,7 +1883,7 @@
// JSON preparation
getEthernetIfaceData(
params[1],
- [this, asyncResp, parentIfaceId{std::string(params[0])},
+ [asyncResp, parentIfaceId{std::string(params[0])},
ifaceId{std::string(params[1])}, &vlanEnable, &vlanId](
const bool &success, const EthernetInterfaceData ðData,
const boost::container::flat_set<IPv4AddressData> &ipv4Data,
@@ -1944,7 +1953,7 @@
// JSON preparation
getEthernetIfaceData(
params[1],
- [this, asyncResp, parentIfaceId{std::string(params[0])},
+ [asyncResp, parentIfaceId{std::string(params[0])},
ifaceId{std::string(params[1])}](
const bool &success, const EthernetInterfaceData ðData,
const boost::container::flat_set<IPv4AddressData> &ipv4Data,
@@ -2090,7 +2099,7 @@
{
messages::propertyMissing(asyncResp->res, "VLANEnable");
}
- if (static_cast<bool>(vlanId) ^ static_cast<bool>(vlanEnable))
+ if (static_cast<bool>(vlanId) ^ vlanEnable)
{
return;
}
diff --git a/redfish-core/lib/health.hpp b/redfish-core/lib/health.hpp
index da4f2d9..930eaee 100644
--- a/redfish-core/lib/health.hpp
+++ b/redfish-core/lib/health.hpp
@@ -153,8 +153,7 @@
},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", "/",
- int32_t(0),
+ "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", "/", 0,
std::array<const char *, 1>{
"xyz.openbmc_project.Inventory.Item.Global"});
}
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 9fd35a9..7a63162 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -145,8 +145,8 @@
size_t length = 0;
int ret = 0;
// Get the metadata from the requested field of the journal entry
- ret = sd_journal_get_data(journal, field.data(), (const void **)&data,
- &length);
+ ret = sd_journal_get_data(journal, field.data(),
+ reinterpret_cast<const void **>(&data), &length);
if (ret < 0)
{
return ret;
@@ -159,7 +159,7 @@
static int getJournalMetadata(sd_journal *journal,
const std::string_view &field, const int &base,
- int &contents)
+ long int &contents)
{
int ret = 0;
std::string_view metadata;
@@ -205,13 +205,13 @@
}
static bool getSkipParam(crow::Response &res, const crow::Request &req,
- long &skip)
+ uint64_t &skip)
{
char *skipParam = req.urlParams.get("$skip");
if (skipParam != nullptr)
{
char *ptr = nullptr;
- skip = std::strtol(skipParam, &ptr, 10);
+ skip = std::strtoul(skipParam, &ptr, 10);
if (*skipParam == '\0' || *ptr != '\0')
{
@@ -219,33 +219,26 @@
"$skip");
return false;
}
- if (skip < 0)
- {
-
- messages::queryParameterOutOfRange(res, std::to_string(skip),
- "$skip", "greater than 0");
- return false;
- }
}
return true;
}
-static constexpr const long maxEntriesPerPage = 1000;
+static constexpr const uint64_t maxEntriesPerPage = 1000;
static bool getTopParam(crow::Response &res, const crow::Request &req,
- long &top)
+ uint64_t &top)
{
char *topParam = req.urlParams.get("$top");
if (topParam != nullptr)
{
char *ptr = nullptr;
- top = std::strtol(topParam, &ptr, 10);
+ top = std::strtoul(topParam, &ptr, 10);
if (*topParam == '\0' || *ptr != '\0')
{
messages::queryParameterValueTypeError(res, std::string(topParam),
"$top");
return false;
}
- if (top < 1 || top > maxEntriesPerPage)
+ if (top < 1U || top > maxEntriesPerPage)
{
messages::queryParameterOutOfRange(
@@ -301,7 +294,7 @@
static bool getUniqueEntryID(const std::string &logEntry, std::string &entryID,
const bool firstEntry = true)
{
- static uint64_t prevTs = 0;
+ static time_t prevTs = 0;
static int index = 0;
if (firstEntry)
{
@@ -309,7 +302,7 @@
}
// Get the entry timestamp
- uint64_t curTs = 0;
+ std::time_t curTs = 0;
std::tm timeStruct = {};
std::istringstream entryStream(logEntry);
if (entryStream >> std::get_time(&timeStruct, "%Y-%m-%dT%H:%M:%S"))
@@ -338,7 +331,7 @@
}
static bool getTimestampFromID(crow::Response &res, const std::string &entryID,
- uint64_t ×tamp, uint16_t &index)
+ uint64_t ×tamp, uint64_t &index)
{
if (entryID.empty())
{
@@ -359,12 +352,12 @@
{
index = std::stoul(std::string(indexStr), &pos);
}
- catch (std::invalid_argument)
+ catch (std::invalid_argument &)
{
messages::resourceMissingAtURI(res, entryID);
return false;
}
- catch (std::out_of_range)
+ catch (std::out_of_range &)
{
messages::resourceMissingAtURI(res, entryID);
return false;
@@ -381,12 +374,12 @@
{
timestamp = std::stoull(std::string(tsStr), &pos);
}
- catch (std::invalid_argument)
+ catch (std::invalid_argument &)
{
messages::resourceMissingAtURI(res, entryID);
return false;
}
- catch (std::out_of_range)
+ catch (std::out_of_range &)
{
messages::resourceMissingAtURI(res, entryID);
return false;
@@ -685,8 +678,8 @@
const std::vector<std::string> ¶ms) override
{
std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res);
- long skip = 0;
- long top = maxEntriesPerPage; // Show max entries by default
+ uint64_t skip = 0;
+ uint64_t top = maxEntriesPerPage; // Show max entries by default
if (!getSkipParam(asyncResp->res, req, skip))
{
return;
@@ -912,7 +905,6 @@
uint32_t *id;
std::time_t timestamp;
std::string *severity, *message;
- bool *resolved;
for (auto &propertyMap : interfaceMap.second)
{
if (propertyMap.first == "Id")
@@ -933,15 +925,16 @@
{
messages::propertyMissing(asyncResp->res,
"Timestamp");
+ continue;
}
// Retrieve Created property with format:
// yyyy-mm-ddThh:mm:ss
std::chrono::milliseconds chronoTimeStamp(
*millisTimeStamp);
- timestamp =
- std::chrono::duration_cast<
- std::chrono::seconds>(chronoTimeStamp)
- .count();
+ timestamp = std::chrono::duration_cast<
+ std::chrono::duration<int>>(
+ chronoTimeStamp)
+ .count();
}
else if (propertyMap.first == "Severity")
{
@@ -1038,7 +1031,6 @@
uint32_t *id;
std::time_t timestamp;
std::string *severity, *message;
- bool *resolved;
for (auto &propertyMap : resp)
{
if (propertyMap.first == "Id")
@@ -1057,14 +1049,15 @@
{
messages::propertyMissing(asyncResp->res,
"Timestamp");
+ continue;
}
// Retrieve Created property with format:
// yyyy-mm-ddThh:mm:ss
std::chrono::milliseconds chronoTimeStamp(
*millisTimeStamp);
timestamp =
- std::chrono::duration_cast<std::chrono::seconds>(
- chronoTimeStamp)
+ std::chrono::duration_cast<
+ std::chrono::duration<int>>(chronoTimeStamp)
.count();
}
else if (propertyMap.first == "Severity")
@@ -1087,6 +1080,10 @@
}
}
}
+ if (id == nullptr || message == nullptr || severity == nullptr)
+ {
+ return;
+ }
asyncResp->res.jsonValue = {
{"@odata.type", "#LogEntry.v1_4_0.LogEntry"},
{"@odata.context", "/redfish/v1/"
@@ -1249,7 +1246,7 @@
}
// Get the severity from the PRIORITY field
- int severity = 8; // Default to an invalid priority
+ long int severity = 8; // Default to an invalid priority
ret = getJournalMetadata(journal, "PRIORITY", 10, severity);
if (ret < 0)
{
@@ -1302,8 +1299,8 @@
{
std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res);
static constexpr const long maxEntriesPerPage = 1000;
- long skip = 0;
- long top = maxEntriesPerPage; // Show max entries by default
+ uint64_t skip = 0;
+ uint64_t top = maxEntriesPerPage; // Show max entries by default
if (!getSkipParam(asyncResp->res, req, skip))
{
return;
@@ -1415,7 +1412,7 @@
const std::string &entryID = params[0];
// Convert the unique ID back to a timestamp to find the entry
uint64_t ts = 0;
- uint16_t index = 0;
+ uint64_t index = 0;
if (!getTimestampFromID(asyncResp->res, entryID, ts, index))
{
return;
@@ -1437,7 +1434,7 @@
std::string idStr;
bool firstEntry = true;
ret = sd_journal_seek_realtime_usec(journal.get(), ts);
- for (int i = 0; i <= index; i++)
+ for (uint64_t i = 0; i <= index; i++)
{
sd_journal_next(journal.get());
if (!getUniqueEntryID(journal.get(), idStr, firstEntry))
@@ -1652,7 +1649,7 @@
messages::internalError(asyncResp->res);
return;
}
- const uint8_t logId = std::atoi(params[0].c_str());
+ const int logId = std::atoi(params[0].c_str());
auto getStoredLogCallback = [asyncResp, logId](
const boost::system::error_code ec,
const std::variant<std::string> &resp) {
@@ -1728,9 +1725,9 @@
return;
}
// Make this static so it survives outside this method
- static boost::asio::deadline_timer timeout(*req.ioService);
+ static boost::asio::steady_timer timeout(*req.ioService);
- timeout.expires_from_now(boost::posix_time::seconds(30));
+ timeout.expires_after(std::chrono::seconds(30));
timeout.async_wait([asyncResp](const boost::system::error_code &ec) {
onDemandLogMatcher = nullptr;
if (ec)
@@ -1751,12 +1748,8 @@
auto onDemandLogMatcherCallback = [asyncResp](
sdbusplus::message::message &m) {
BMCWEB_LOG_DEBUG << "OnDemand log available match fired";
- boost::system::error_code ec;
- timeout.cancel(ec);
- if (ec)
- {
- BMCWEB_LOG_ERROR << "error canceling timer " << ec;
- }
+ timeout.cancel();
+
sdbusplus::message::object_path objPath;
boost::container::flat_map<
std::string, boost::container::flat_map<
@@ -1825,13 +1818,8 @@
{
messages::internalError(asyncResp->res);
}
- boost::system::error_code timeoutec;
- timeout.cancel(timeoutec);
- if (timeoutec)
- {
- BMCWEB_LOG_ERROR << "error canceling timer "
- << timeoutec;
- }
+
+ timeout.cancel();
onDemandLogMatcher = nullptr;
return;
}
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 459edad..9d2144e 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -278,7 +278,7 @@
controller["@odata.id"] =
"/redfish/v1/Managers/bmc#/Oem/"
"OpenBmc/Fan/StepwiseControllers/" +
- std::string(name);
+ name;
controller["@odata.type"] =
"#OemManager.StepwiseController";
@@ -307,7 +307,7 @@
element["@odata.id"] =
"/redfish/v1/Managers/bmc#/Oem/"
"OpenBmc/Fan/FanControllers/" +
- std::string(name);
+ name;
element["@odata.type"] =
"#OemManager.FanController";
@@ -320,7 +320,7 @@
element["@odata.id"] =
"/redfish/v1/Managers/bmc#/Oem/"
"OpenBmc/Fan/PidControllers/" +
- std::string(name);
+ name;
element["@odata.type"] =
"#OemManager.PidController";
element["@odata.context"] =
@@ -1077,8 +1077,8 @@
messages::internalError(self->asyncResp->res);
return;
}
- const std::string* current;
- const std::vector<std::string>* supported;
+ const std::string* current = nullptr;
+ const std::vector<std::string>* supported = nullptr;
for (auto& [key, value] : resp)
{
if (key == "Current")
@@ -1193,9 +1193,9 @@
struct SetPIDValues : std::enable_shared_from_this<SetPIDValues>
{
- SetPIDValues(const std::shared_ptr<AsyncResp>& asyncResp,
+ SetPIDValues(const std::shared_ptr<AsyncResp>& asyncRespIn,
nlohmann::json& data) :
- asyncResp(asyncResp)
+ asyncResp(asyncRespIn)
{
std::optional<nlohmann::json> pidControllers;
@@ -1231,14 +1231,14 @@
// interface gets more traction
crow::connections::systemBus->async_method_call(
[self](const boost::system::error_code ec,
- dbus::utility::ManagedObjectType& managedObj) {
+ dbus::utility::ManagedObjectType& mObj) {
if (ec)
{
BMCWEB_LOG_ERROR << "Error communicating to Entity Manager";
messages::internalError(self->asyncResp->res);
return;
}
- self->managedObj = std::move(managedObj);
+ self->managedObj = std::move(mObj);
},
"xyz.openbmc_project.EntityManager", "/", objectManagerIface,
"GetManagedObjects");
@@ -1266,7 +1266,7 @@
const boost::system::error_code ec,
const boost::container::flat_map<
std::string, std::variant<std::vector<std::string>,
- std::string>>& resp) {
+ std::string>>& r) {
if (ec)
{
BMCWEB_LOG_ERROR << "SetPIDValues: Can't get "
@@ -1275,9 +1275,9 @@
messages::internalError(self->asyncResp->res);
return;
}
- const std::string* current;
- const std::vector<std::string>* supported;
- for (auto& [key, value] : resp)
+ const std::string* current = nullptr;
+ const std::vector<std::string>* supported = nullptr;
+ for (auto& [key, value] : r)
{
if (key == "Current")
{
diff --git a/redfish-core/lib/message_registries.hpp b/redfish-core/lib/message_registries.hpp
index ef443af..96ce0c2 100644
--- a/redfish-core/lib/message_registries.hpp
+++ b/redfish-core/lib/message_registries.hpp
@@ -257,7 +257,7 @@
if (message.second.numberOfArgs > 0)
{
nlohmann::json &messageParamArray = obj["ParamTypes"];
- for (int i = 0; i < message.second.numberOfArgs; i++)
+ for (size_t i = 0; i < message.second.numberOfArgs; i++)
{
messageParamArray.push_back(message.second.paramTypes[i]);
}
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index 71e58cc..75d13d4 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -139,7 +139,7 @@
},
"xyz.openbmc_project.Network", "/xyz/openbmc_project/network",
"org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
-};
+}
class NetworkProtocol : public Node
{
@@ -230,32 +230,32 @@
// TODO Get eth0 interface data, and call the below callback for JSON
// preparation
- getEthernetIfaceData([this, hostName, asyncResp](
- const bool& success,
- const std::vector<std::string>& ntpServers,
- const std::vector<std::string>& domainNames) {
- if (!success)
- {
- messages::resourceNotFound(asyncResp->res, "EthernetInterface",
- "eth0");
- return;
- }
- asyncResp->res.jsonValue["NTP"]["NTPServers"] = ntpServers;
- if (hostName.empty() == false)
- {
- std::string FQDN = std::move(hostName);
- if (domainNames.empty() == false)
+ getEthernetIfaceData(
+ [hostName, asyncResp](const bool& success,
+ const std::vector<std::string>& ntpServers,
+ const std::vector<std::string>& domainNames) {
+ if (!success)
{
- FQDN += "." + domainNames[0];
+ messages::resourceNotFound(asyncResp->res,
+ "EthernetInterface", "eth0");
+ return;
}
- asyncResp->res.jsonValue["FQDN"] = std::move(FQDN);
- }
- });
+ asyncResp->res.jsonValue["NTP"]["NTPServers"] = ntpServers;
+ if (hostName.empty() == false)
+ {
+ std::string FQDN = std::move(hostName);
+ if (domainNames.empty() == false)
+ {
+ FQDN += "." + domainNames[0];
+ }
+ asyncResp->res.jsonValue["FQDN"] = std::move(FQDN);
+ }
+ });
crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code ec,
- const std::vector<UnitStruct>& resp) {
- if (ec)
+ [asyncResp](const boost::system::error_code e,
+ const std::vector<UnitStruct>& r) {
+ if (e)
{
asyncResp->res.jsonValue = nlohmann::json::object();
messages::internalError(asyncResp->res);
@@ -265,7 +265,7 @@
{"@odata.id", "/redfish/v1/Managers/bmc/NetworkProtocol/"
"HTTPS/Certificates/"}};
- for (auto& unit : resp)
+ for (auto& unit : r)
{
for (auto& kv : protocolToDBus)
{
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index ad61ff4..5b4f5c5 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -108,7 +108,7 @@
{
BMCWEB_LOG_DEBUG
<< "failed to get PCIe Device properties ec: "
- << static_cast<int>(ec.value()) << ": " << ec.message();
+ << ec.value() << ": " << ec.message();
if (ec.value() ==
boost::system::linux_error::bad_request_descriptor)
{
@@ -221,7 +221,7 @@
{
BMCWEB_LOG_DEBUG
<< "failed to get PCIe Device properties ec: "
- << static_cast<int>(ec.value()) << ": " << ec.message();
+ << ec.value() << ": " << ec.message();
if (ec.value() ==
boost::system::linux_error::bad_request_descriptor)
{
diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp
index 8c3927b..eaea5ab 100644
--- a/redfish-core/lib/power.hpp
+++ b/redfish-core/lib/power.hpp
@@ -62,13 +62,13 @@
// chassis that implements the Chassis inventory item. This prevents
// things like power supplies providing the chassis power limit
auto chassisHandler = [sensorAsyncResp](
- const boost::system::error_code ec,
+ const boost::system::error_code e,
const std::vector<std::string>&
chassisPaths) {
- if (ec)
+ if (e)
{
BMCWEB_LOG_ERROR
- << "Power Limit GetSubTreePaths handler Dbus error " << ec;
+ << "Power Limit GetSubTreePaths handler Dbus error " << e;
return;
}
@@ -178,7 +178,7 @@
}
else if (i)
{
- powerCap = *i;
+ powerCap = static_cast<double>(*i);
}
else if (u)
{
@@ -220,7 +220,7 @@
std::move(chassisHandler), "xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
- "/xyz/openbmc_project/inventory", int32_t(0),
+ "/xyz/openbmc_project/inventory", 0,
std::array<const char*, 1>{
"xyz.openbmc_project.Inventory.Item.Chassis"});
}
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 76c304f..738edc2 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -49,11 +49,11 @@
class SensorsAsyncResp
{
public:
- SensorsAsyncResp(crow::Response& response, const std::string& chassisId,
- const std::vector<const char*> types,
+ SensorsAsyncResp(crow::Response& response, const std::string& chassisIdIn,
+ const std::vector<const char*> typesIn,
const std::string& subNode) :
res(response),
- chassisId(chassisId), types(types), chassisSubNode(subNode)
+ chassisId(chassisIdIn), types(typesIn), chassisSubNode(subNode)
{
}
@@ -340,12 +340,12 @@
std::string sensorPath = *chassisPath + "/all_sensors";
crow::connections::systemBus->async_method_call(
[sensorsAsyncResp, callback{std::move(callback)}](
- const boost::system::error_code ec,
+ const boost::system::error_code& e,
const std::variant<std::vector<std::string>>&
variantEndpoints) {
- if (ec)
+ if (e)
{
- if (ec.value() != EBADR)
+ if (e.value() != EBADR)
{
messages::internalError(sensorsAsyncResp->res);
return;
@@ -381,7 +381,7 @@
respHandler, "xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
- "/xyz/openbmc_project/inventory", int32_t(0), interfaces);
+ "/xyz/openbmc_project/inventory", 0, interfaces);
BMCWEB_LOG_DEBUG << "getChassis exit";
}
@@ -452,8 +452,7 @@
crow::connections::systemBus->async_method_call(
std::move(respHandler), "xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", int32_t(0),
- interfaces);
+ "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", 0, interfaces);
BMCWEB_LOG_DEBUG << "getObjectManagerPaths exit";
}
@@ -803,10 +802,10 @@
auto interfaceProperties = interfacesDict.find(std::get<0>(p));
if (interfaceProperties != interfacesDict.end())
{
- auto valueIt = interfaceProperties->second.find(std::get<1>(p));
- if (valueIt != interfaceProperties->second.end())
+ auto thisValueIt = interfaceProperties->second.find(std::get<1>(p));
+ if (thisValueIt != interfaceProperties->second.end())
{
- const SensorVariant& valueVariant = valueIt->second;
+ const SensorVariant& valueVariant = thisValueIt->second;
// The property we want to set may be nested json, so use
// a json_pointer for easy indexing into the json structure.
@@ -820,7 +819,7 @@
double temp = 0.0;
if (int64Value != nullptr)
{
- temp = *int64Value;
+ temp = static_cast<double>(*int64Value);
}
else if (doubleValue != nullptr)
{
@@ -878,10 +877,10 @@
const std::string& owner = objDict.begin()->first;
crow::connections::systemBus->async_method_call(
[path, owner,
- sensorsAsyncResp](const boost::system::error_code ec,
+ sensorsAsyncResp](const boost::system::error_code e,
std::variant<std::vector<std::string>>
variantEndpoints) {
- if (ec)
+ if (e)
{
return; // if they don't have an association we
// can't tell what chassis is
@@ -911,13 +910,13 @@
}
crow::connections::systemBus->async_method_call(
[path, sensorsAsyncResp](
- const boost::system::error_code ec,
+ const boost::system::error_code& err,
const boost::container::flat_map<
std::string,
std::variant<uint8_t,
std::vector<std::string>,
std::string>>& ret) {
- if (ec)
+ if (err)
{
return; // don't have to have this
// interface
@@ -1016,15 +1015,16 @@
}
}
- auto& resp = sensorsAsyncResp->res
- .jsonValue["Redundancy"];
- resp.push_back(
+ nlohmann::json& jResp =
+ sensorsAsyncResp->res
+ .jsonValue["Redundancy"];
+ jResp.push_back(
{{"@odata.id",
"/refish/v1/Chassis/" +
sensorsAsyncResp->chassisId + "/" +
sensorsAsyncResp->chassisSubNode +
"#/Redundancy/" +
- std::to_string(resp.size())},
+ std::to_string(jResp.size())},
{"@odata.type",
"#Redundancy.v1_3_2.Redundancy"},
{"MinNumNeeded",
@@ -1314,7 +1314,7 @@
std::shared_ptr<boost::container::flat_set<std::string>> invConnections,
std::shared_ptr<boost::container::flat_map<std::string, std::string>>
objectMgrPaths,
- Callback&& callback, int invConnectionsIndex = 0)
+ Callback&& callback, size_t invConnectionsIndex = 0)
{
BMCWEB_LOG_DEBUG << "getInventoryItemsData enter";
@@ -1800,7 +1800,7 @@
}
else
{
- const char* fieldName = nullptr;
+ std::string fieldName;
if (sensorType == "temperature")
{
fieldName = "Temperatures";
@@ -1978,7 +1978,7 @@
// Get set of sensors in chassis
getChassis(SensorsAsyncResp, std::move(getChassisCb));
BMCWEB_LOG_DEBUG << "getChassisData exit";
-};
+}
/**
* @brief Find the requested sensorName in the list of all sensors supplied by
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index a3d7196..da88271 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -29,7 +29,7 @@
// Only allow one update at a time
static bool fwUpdateInProgress = false;
// Timer for software available
-static std::unique_ptr<boost::asio::deadline_timer> fwAvailableTimer;
+static std::unique_ptr<boost::asio::steady_timer> fwAvailableTimer;
static void cleanUp()
{
@@ -148,10 +148,9 @@
}
fwAvailableTimer =
- std::make_unique<boost::asio::deadline_timer>(*req.ioService);
+ std::make_unique<boost::asio::steady_timer>(*req.ioService);
- fwAvailableTimer->expires_from_now(
- boost::posix_time::seconds(timeoutTimeSeconds));
+ fwAvailableTimer->expires_after(std::chrono::seconds(timeoutTimeSeconds));
fwAvailableTimer->async_wait(
[asyncResp](const boost::system::error_code &ec) {
@@ -485,10 +484,6 @@
for (auto &obj : subtree)
{
- const std::vector<
- std::pair<std::string, std::vector<std::string>>>
- &connections = obj.second;
-
// if can't parse fw id then return
std::size_t idPos;
if ((idPos = obj.first.rfind("/")) == std::string::npos)
@@ -511,7 +506,8 @@
},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", int32_t(0),
+ "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/",
+ static_cast<int32_t>(0),
std::array<const char *, 1>{
"xyz.openbmc_project.Software.Version"});
}
@@ -719,7 +715,8 @@
},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", int32_t(0),
+ "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/",
+ static_cast<int32_t>(0),
std::array<const char *, 1>{
"xyz.openbmc_project.Software.Version"});
}