diff options
| author | Ed Tanous <ed.tanous@intel.com> | 2019-10-11 13:05:49 -0700 |
|---|---|---|
| committer | Ed Tanous <ed.tanous@intel.com> | 2019-10-11 13:05:49 -0700 |
| commit | 66664f25734f59618f53f7f8416e3894ecb4db37 (patch) | |
| tree | 5b7c4411d0e4961bc9b6d79182d186af66b134db | |
| parent | a6f9392101c6adb9f4ad57d349c392b2396c2cb1 (diff) | |
| download | bmcweb-66664f25734f59618f53f7f8416e3894ecb4db37.tar.gz bmcweb-66664f25734f59618f53f7f8416e3894ecb4db37.zip | |
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
| -rw-r--r-- | include/openbmc_dbus_rest.hpp | 34 | ||||
| -rw-r--r-- | redfish-core/lib/log_services.hpp | 14 | ||||
| -rw-r--r-- | redfish-core/lib/roles.hpp | 5 |
3 files changed, 37 insertions, 16 deletions
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 @@ int convertJsonToDbus(sd_bus_message *m, const std::string &arg_type, 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 @@ int convertJsonToDbus(sd_bus_message *m, const std::string &arg_type, // 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 @@ int convertJsonToDbus(sd_bus_message *m, const std::string &arg_type, } else if (argCode == "y") { + const uint64_t *uintValue = j->get_ptr<const uint64_t *>(); if (uintValue == nullptr) { return -1; @@ -677,6 +688,7 @@ int convertJsonToDbus(sd_bus_message *m, const std::string &arg_type, } else if (argCode == "q") { + const uint64_t *uintValue = j->get_ptr<const uint64_t *>(); if (uintValue == nullptr) { return -1; @@ -691,6 +703,7 @@ int convertJsonToDbus(sd_bus_message *m, const std::string &arg_type, } else if (argCode == "u") { + const uint64_t *uintValue = j->get_ptr<const uint64_t *>(); if (uintValue == nullptr) { return -1; @@ -705,6 +718,7 @@ int convertJsonToDbus(sd_bus_message *m, const std::string &arg_type, } 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 @@ class DBusEventLogEntryCollection : public Node } 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 @@ class DBusEventLogEntry : public Node 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 @@ class RoleCollection : public Node 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); |

