Fix some warnings
-werror on the newest version of GCC finds even more stuff than was
found before. Fix all of them.
Tested: No functional change. In theory these cases can't occur unless
a dbus interface is broken.
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Change-Id: Id11e29e4851075b511e69cbc006aa8d7e1e229f0
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index 775e6e1..749e899 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -533,7 +533,6 @@
jIt++;
}
const int64_t *intValue = j->get_ptr<const int64_t *>();
- const uint64_t *uintValue = j->get_ptr<const uint64_t *>();
const std::string *stringValue = j->get_ptr<const std::string *>();
const double *doubleValue = j->get_ptr<const double *>();
const bool *b = j->get_ptr<const bool *>();
@@ -542,20 +541,31 @@
// Do some basic type conversions that make sense. uint can be
// converted to int. int and uint can be converted to double
- if (uintValue != nullptr && intValue == nullptr)
+ if (intValue == nullptr)
{
- v = static_cast<int64_t>(*uintValue);
- intValue = &v;
+ const uint64_t *uintValue = j->get_ptr<const uint64_t *>();
+ if (uintValue != nullptr)
+ {
+ v = static_cast<int64_t>(*uintValue);
+ intValue = &v;
+ }
}
- if (uintValue != nullptr && doubleValue == nullptr)
+ if (doubleValue == nullptr)
{
- d = static_cast<double>(*uintValue);
- doubleValue = &d;
+ const uint64_t *uintValue = j->get_ptr<const uint64_t *>();
+ if (uintValue != nullptr)
+ {
+ d = static_cast<double>(*uintValue);
+ doubleValue = &d;
+ }
}
- if (intValue != nullptr && doubleValue == nullptr)
+ if (doubleValue == nullptr)
{
- d = static_cast<double>(*intValue);
- doubleValue = &d;
+ if (intValue != nullptr)
+ {
+ d = static_cast<double>(*intValue);
+ doubleValue = &d;
+ }
}
if (argCode == "s")
@@ -663,6 +673,7 @@
}
else if (argCode == "y")
{
+ const uint64_t *uintValue = j->get_ptr<const uint64_t *>();
if (uintValue == nullptr)
{
return -1;
@@ -677,6 +688,7 @@
}
else if (argCode == "q")
{
+ const uint64_t *uintValue = j->get_ptr<const uint64_t *>();
if (uintValue == nullptr)
{
return -1;
@@ -691,6 +703,7 @@
}
else if (argCode == "u")
{
+ const uint64_t *uintValue = j->get_ptr<const uint64_t *>();
if (uintValue == nullptr)
{
return -1;
@@ -705,6 +718,7 @@
}
else if (argCode == "t")
{
+ const uint64_t *uintValue = j->get_ptr<const uint64_t *>();
if (uintValue == nullptr)
{
return -1;
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 7a63162..233578e 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -902,9 +902,10 @@
}
entriesArray.push_back({});
nlohmann::json &thisEntry = entriesArray.back();
- uint32_t *id;
- std::time_t timestamp;
- std::string *severity, *message;
+ uint32_t *id = nullptr;
+ std::time_t timestamp{};
+ std::string *severity = nullptr;
+ std::string *message = nullptr;
for (auto &propertyMap : interfaceMap.second)
{
if (propertyMap.first == "Id")
@@ -1028,9 +1029,10 @@
messages::internalError(asyncResp->res);
return;
}
- uint32_t *id;
- std::time_t timestamp;
- std::string *severity, *message;
+ uint32_t *id = nullptr;
+ std::time_t timestamp{};
+ std::string *severity = nullptr;
+ std::string *message = nullptr;
for (auto &propertyMap : resp)
{
if (propertyMap.first == "Id")
diff --git a/redfish-core/lib/roles.hpp b/redfish-core/lib/roles.hpp
index fbe8653..782d23c 100644
--- a/redfish-core/lib/roles.hpp
+++ b/redfish-core/lib/roles.hpp
@@ -160,6 +160,11 @@
memberArray = nlohmann::json::array();
const std::vector<std::string>* privList =
std::get_if<std::vector<std::string>>(&resp);
+ if (privList == nullptr)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
for (const std::string& priv : *privList)
{
std::string role = getRoleFromPrivileges(priv);