Revert "bmcweb: Fix a bunch of warnings"
This reverts commit 6ea007a2faec52ad62680015d2a3f00371a1e351.
Reason for revert: Reports of bmcweb seg faults.
Change-Id: I408f1bb29c2f8e427a6621cdaac8c31b847ebf06
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index b992018..476e03a 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -302,8 +302,7 @@
boost::container::flat_set<IPv4AddressData>::iterator,
bool>
it = ipv4_config.insert(
- {objpath.first.str.substr(ipv4PathStart.size()), "",
- "", "", "", "", LinkType::Local});
+ {objpath.first.str.substr(ipv4PathStart.size())});
IPv4AddressData &ipv4_address = *it.first;
for (auto &property : interface.second)
{
@@ -479,6 +478,45 @@
}
/**
+ * @brief Changes IPv4 address type property (Address, Gateway)
+ *
+ * @param[in] ifaceId Id of interface whose IP should be modified
+ * @param[in] ipIdx Index of IP in input array that should be modified
+ * @param[in] ipHash DBus Hash id of modified IP
+ * @param[in] name Name of field in JSON representation
+ * @param[in] newValue New value that should be written
+ * @param[io] asyncResp Response object that will be returned to client
+ *
+ * @return true if give IP is valid and has been sent do D-Bus, false
+ * otherwise
+ */
+inline void changeIPv4AddressProperty(
+ const std::string &ifaceId, int ipIdx, const std::string &ipHash,
+ const std::string &name, const std::string &newValue,
+ const std::shared_ptr<AsyncResp> asyncResp)
+{
+ auto callback = [asyncResp, ipIdx, name{std::string(name)},
+ newValue{std::move(newValue)}](
+ const boost::system::error_code ec) {
+ if (ec)
+ {
+ messages::internalError(asyncResp->res);
+ }
+ else
+ {
+ asyncResp->res.jsonValue["IPv4Addresses"][ipIdx][name] = newValue;
+ }
+ };
+
+ crow::connections::systemBus->async_method_call(
+ std::move(callback), "xyz.openbmc_project.Network",
+ "/xyz/openbmc_project/network/" + ifaceId + "/ipv4/" + ipHash,
+ "org.freedesktop.DBus.Properties", "Set",
+ "xyz.openbmc_project.Network.IP", name,
+ std::variant<std::string>(newValue));
+}
+
+/**
* @brief Changes IPv4 address origin property
*
* @param[in] ifaceId Id of interface whose IP should be modified
@@ -492,7 +530,7 @@
* @return true if give IP is valid and has been sent do D-Bus, false
* otherwise
*/
-inline void changeIPv4Origin(const std::string &ifaceId, size_t ipIdx,
+inline void changeIPv4Origin(const std::string &ifaceId, int ipIdx,
const std::string &ipHash,
const std::string &newValue,
const std::string &newValueDbus,
@@ -532,8 +570,7 @@
*
* @return None
*/
-inline void changeIPv4SubnetMaskProperty(const std::string &ifaceId,
- size_t ipIdx,
+inline void changeIPv4SubnetMaskProperty(const std::string &ifaceId, int ipIdx,
const std::string &ipHash,
const std::string &newValueStr,
uint8_t &newValue,
@@ -600,8 +637,9 @@
*
* @return None
*/
-inline void createIPv4(const std::string &ifaceId, uint8_t subnetMask,
- const std::string &gateway, const std::string &address,
+inline void createIPv4(const std::string &ifaceId, unsigned int ipIdx,
+ uint8_t subnetMask, const std::string &gateway,
+ const std::string &address,
std::shared_ptr<AsyncResp> asyncResp)
{
auto createIpHandler = [asyncResp](const boost::system::error_code ec) {
@@ -1061,7 +1099,6 @@
if (gateway)
{
if (!ipv4VerifyIpAndGetBitcount(*gateway))
-
{
messages::propertyValueFormatError(asyncResp->res, *gateway,
pathString + "/Gateway");
@@ -1161,7 +1198,8 @@
continue;
}
- createIPv4(ifaceId, entryIdx, *gateway, *address, asyncResp);
+ createIPv4(ifaceId, entryIdx, prefixLength, *gateway, *address,
+ asyncResp);
nlohmann::json &ipv4AddressJson =
asyncResp->res.jsonValue["IPv4Addresses"][entryIdx];
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index b07d6b1..61cbd9e 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -46,8 +46,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(),
- reinterpret_cast<const void **>(&data), &length);
+ ret = sd_journal_get_data(journal, field.data(), (const void **)&data,
+ &length);
if (ret < 0)
{
return ret;
@@ -70,7 +70,7 @@
{
return ret;
}
- contents = static_cast<int>(strtol(metadata.data(), nullptr, base));
+ contents = strtol(metadata.data(), nullptr, base);
return ret;
}
@@ -215,12 +215,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;
@@ -237,12 +237,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;
@@ -382,8 +382,8 @@
{
continue;
}
- unsigned long argNum = std::strtoul(field.data(), nullptr, 10);
- if (argNum == 0 || argNum > std::numeric_limits<size_t>::max())
+ int argNum = std::strtoul(field.data(), nullptr, 10);
+ if (argNum == 0)
{
continue;
}
@@ -392,7 +392,7 @@
// Make sure we have enough space in messageArgs
if (argNum > messageArgs.size())
{
- messageArgs.resize(static_cast<size_t>(argNum));
+ messageArgs.resize(argNum);
}
messageArgs[argNum - 1] = std::string(field);
}
@@ -482,7 +482,7 @@
std::unique_ptr<sd_journal, decltype(&sd_journal_close)> journal(
journalTmp, sd_journal_close);
journalTmp = nullptr;
- long entryCount = 0;
+ uint64_t entryCount = 0;
SD_JOURNAL_FOREACH(journal.get())
{
// Look for only journal entries that contain a REDFISH_MESSAGE_ID
@@ -803,7 +803,7 @@
std::unique_ptr<sd_journal, decltype(&sd_journal_close)> journal(
journalTmp, sd_journal_close);
journalTmp = nullptr;
- long entryCount = 0;
+ uint64_t entryCount = 0;
SD_JOURNAL_FOREACH(journal.get())
{
entryCount++;
@@ -1094,7 +1094,7 @@
messages::internalError(asyncResp->res);
return;
}
- const int logId = std::atoi(params[0].c_str());
+ const uint8_t logId = std::atoi(params[0].c_str());
auto getStoredLogCallback = [asyncResp, logId](
const boost::system::error_code ec,
const std::variant<std::string> &resp) {
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 0aa4478..f9c2f38 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -785,10 +785,10 @@
for (auto& step : *steps)
{
double target;
- double out;
+ double output;
if (!redfish::json_util::readJson(step, response->res, "Target",
- target, "Output", out))
+ target, "Output", output))
{
BMCWEB_LOG_ERROR << "Line:" << __LINE__
<< ", Illegal Property "
@@ -796,7 +796,7 @@
return CreatePIDRet::fail;
}
readings.emplace_back(target);
- outputs.emplace_back(out);
+ outputs.emplace_back(output);
}
output["Reading"] = std::move(readings);
output["Output"] = std::move(outputs);
diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp
index 78f1d8a..b1df101 100644
--- a/redfish-core/lib/power.hpp
+++ b/redfish-core/lib/power.hpp
@@ -38,8 +38,9 @@
}
private:
- std::vector<const char*> typeList = {"/xyz/openbmc_project/sensors/voltage",
- "/xyz/openbmc_project/sensors/power"};
+ std::initializer_list<const char*> typeList = {
+ "/xyz/openbmc_project/sensors/voltage",
+ "/xyz/openbmc_project/sensors/power"};
void doGet(crow::Response& res, const crow::Request& req,
const std::vector<std::string>& params) override
{
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 51895ee..bbed047 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -49,7 +49,7 @@
{
public:
SensorsAsyncResp(crow::Response& response, const std::string& chassisId,
- const std::vector<const char*> types,
+ const std::initializer_list<const char*> types,
const std::string& subNode) :
res(response),
chassisId(chassisId), types(types), chassisSubNode(subNode)
@@ -539,11 +539,11 @@
auto interfaceProperties = interfacesDict.find(std::get<0>(p));
if (interfaceProperties != interfacesDict.end())
{
- auto valIt = interfaceProperties->second.find(std::get<1>(p));
- if (valIt != interfaceProperties->second.end())
+ auto valueIt = interfaceProperties->second.find(std::get<1>(p));
+ if (valueIt != interfaceProperties->second.end())
{
- const SensorVariant& valueVariant = valIt->second;
- nlohmann::json& jValueIt = sensor_json[std::get<2>(p)];
+ const SensorVariant& valueVariant = valueIt->second;
+ nlohmann::json& valueIt = sensor_json[std::get<2>(p)];
// Attempt to pull the int64 directly
const int64_t* int64Value = std::get_if<int64_t>(&valueVariant);
@@ -566,11 +566,11 @@
temp = temp * std::pow(10, scaleMultiplier);
if (forceToInt)
{
- jValueIt = static_cast<int64_t>(temp);
+ valueIt = static_cast<int64_t>(temp);
}
else
{
- jValueIt = temp;
+ valueIt = temp;
}
}
}
@@ -985,7 +985,7 @@
*/
void setSensorOverride(crow::Response& res, const crow::Request& req,
const std::vector<std::string>& params,
- const std::vector<const char*> typeList,
+ const std::initializer_list<const char*> typeList,
const std::string& chassisSubNode)
{
diff --git a/redfish-core/lib/thermal.hpp b/redfish-core/lib/thermal.hpp
index 58e7cd4..f266c40 100644
--- a/redfish-core/lib/thermal.hpp
+++ b/redfish-core/lib/thermal.hpp
@@ -37,7 +37,7 @@
}
private:
- std::vector<const char*> typeList = {
+ std::initializer_list<const char*> typeList = {
"/xyz/openbmc_project/sensors/fan_tach",
"/xyz/openbmc_project/sensors/temperature",
"/xyz/openbmc_project/sensors/fan_pwm"};