bmcweb: fix compiler warnings
This patchset attempts to fix all compiler warnings in bmcweb owned
files. There are 2 warnings left, both in sdbusplus, which will be
resolved in a patchset there.
Tested By:
Recompiled, observed warning count went from 30, to zero.
Change-Id: Ife90207aa5773bc28faa8b04c732cafa5a56e4e4
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/crow/include/crow/common.h b/crow/include/crow/common.h
index 428da7d..9dc8220 100644
--- a/crow/include/crow/common.h
+++ b/crow/include/crow/common.h
@@ -33,8 +33,9 @@
return "TRACE";
case boost::beast::http::verb::patch:
return "PATCH";
+ default:
+ return "invalid";
}
- return "invalid";
}
enum class ParamType
@@ -124,4 +125,4 @@
crow::black_magic::isEquP(str, "PURGE", 5) ? verb::purge :
throw std::runtime_error("invalid http method");
// clang-format on
-}
\ No newline at end of file
+}
diff --git a/crow/include/crow/http_connection.h b/crow/include/crow/http_connection.h
index bd2a824..f056f27 100644
--- a/crow/include/crow/http_connection.h
+++ b/crow/include/crow/http_connection.h
@@ -312,8 +312,6 @@
{
cancelDeadlineTimer();
bool isInvalidRequest = false;
- const boost::string_view connection =
- req->getHeaderValue(boost::beast::http::field::connection);
// Check for HTTP version 1.1.
if (req->version() == 11)
diff --git a/crow/include/crow/http_request.h b/crow/include/crow/http_request.h
index ac5f78d..7de618f 100644
--- a/crow/include/crow/http_request.h
+++ b/crow/include/crow/http_request.h
@@ -12,6 +12,7 @@
struct Request
{
+ boost::beast::http::request<boost::beast::http::string_body>& req;
boost::string_view url{};
QueryString urlParams{};
bool isSecure{false};
@@ -65,8 +66,6 @@
{
return req.keep_alive();
}
-
- boost::beast::http::request<boost::beast::http::string_body>& req;
};
} // namespace crow
diff --git a/crow/include/crow/logging.h b/crow/include/crow/logging.h
index 353a448..9da47b7 100644
--- a/crow/include/crow/logging.h
+++ b/crow/include/crow/logging.h
@@ -71,24 +71,24 @@
}
~logger()
{
-#ifdef BMCWEB_ENABLE_LOGGING
if (level >= get_current_log_level())
{
+#ifdef BMCWEB_ENABLE_LOGGING
stringstream << std::endl;
getHandlerRef()->log(stringstream.str(), level);
- }
#endif
+ }
}
//
template <typename T> logger& operator<<(T const& value)
{
-#ifdef BMCWEB_ENABLE_LOGGING
if (level >= get_current_log_level())
{
+#ifdef BMCWEB_ENABLE_LOGGING
stringstream << value;
- }
#endif
+ }
return *this;
}
diff --git a/crow/include/crow/websocket.h b/crow/include/crow/websocket.h
index b545b5a..6ce7e05 100644
--- a/crow/include/crow/websocket.h
+++ b/crow/include/crow/websocket.h
@@ -54,8 +54,8 @@
message_handler,
std::function<void(Connection&, const std::string&)> close_handler,
std::function<void(Connection&)> error_handler) :
- inString(),
- inBuffer(inString, 4096), ws(std::move(adaptorIn)), Connection(req),
+ Connection(req),
+ ws(std::move(adaptorIn)), inString(), inBuffer(inString, 4096),
openHandler(std::move(open_handler)),
messageHandler(std::move(message_handler)),
closeHandler(std::move(close_handler)),
@@ -129,7 +129,7 @@
{
ws.async_close(
boost::beast::websocket::close_code::normal,
- [this, self(shared_from_this())](boost::system::error_code ec) {
+ [self(shared_from_this())](boost::system::error_code ec) {
if (ec == boost::asio::error::operation_aborted)
{
return;
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index aecfc21..a7018a4 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -632,8 +632,7 @@
const std::string &address,
std::shared_ptr<AsyncResp> asyncResp)
{
- auto createIpHandler = [ipIdx,
- asyncResp](const boost::system::error_code ec) {
+ auto createIpHandler = [asyncResp](const boost::system::error_code ec) {
if (ec)
{
messages::internalError(asyncResp->res);
@@ -1634,8 +1633,7 @@
// Get eth interface list, and call the below callback for JSON
// preparation
getEthernetIfaceList(
- [this, asyncResp,
- rootInterfaceName{std::string(rootInterfaceName)}](
+ [asyncResp, rootInterfaceName{std::string(rootInterfaceName)}](
const bool &success,
const std::vector<std::string> &iface_list) {
if (!success)
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 3f181c7..e9120f3 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -166,7 +166,6 @@
configRoot["@odata.context"] =
"/redfish/v1/$metadata#OemManager.Fan";
- bool propertyError = false;
for (const auto& pathPair : managedObj)
{
for (const auto& intfPair : pathPair.second)
@@ -945,7 +944,6 @@
"xyz.openbmc_project.Software.Version")
{
// Cut out everyting until last "/", ...
- const std::string& iface_id = objpath.first;
for (auto& property : interface.second)
{
if (property.first == "Version")
@@ -1005,7 +1003,7 @@
return;
}
std::array<
- std::pair<const char*, std::optional<nlohmann::json>*>, 4>
+ std::pair<std::string, std::optional<nlohmann::json>*>, 4>
sections = {
std::make_pair("PidControllers", &pidControllers),
std::make_pair("FanControllers", &fanControllers),
@@ -1020,7 +1018,7 @@
{
continue;
}
- const char* type = containerPair.first;
+ std::string& type = containerPair.first;
for (auto& record : container->items())
{
@@ -1180,31 +1178,26 @@
if (oem)
{
- for (const auto& oemLevel : oem->items())
+ std::optional<nlohmann::json> openbmc;
+ if (!redfish::json_util::readJson(*oem, res, "OpenBmc", openbmc))
{
- std::optional<nlohmann::json> openbmc;
- if (!redfish::json_util::readJson(*oem, res, "OpenBmc",
- openbmc))
+ BMCWEB_LOG_ERROR << "Line:" << __LINE__ << ", Illegal Property "
+ << oem->dump();
+ return;
+ }
+ if (openbmc)
+ {
+ std::optional<nlohmann::json> fan;
+ if (!redfish::json_util::readJson(*openbmc, res, "Fan", fan))
{
BMCWEB_LOG_ERROR << "Line:" << __LINE__
- << ", Illegal Property " << oem->dump();
+ << ", Illegal Property "
+ << openbmc->dump();
return;
}
- if (openbmc)
+ if (fan)
{
- std::optional<nlohmann::json> fan;
- if (!redfish::json_util::readJson(*openbmc, res, "Fan",
- fan))
- {
- BMCWEB_LOG_ERROR << "Line:" << __LINE__
- << ", Illegal Property "
- << openbmc->dump();
- return;
- }
- if (fan)
- {
- setPidValues(response, *fan);
- }
+ setPidValues(response, *fan);
}
}
}
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index 044d8d0..009be05 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -155,8 +155,7 @@
"running";
crow::connections::systemBus->async_method_call(
- [asyncResp, service{std::string(service)},
- socketPath](
+ [asyncResp, service{std::string(service)}](
const boost::system::error_code ec,
const std::variant<std::vector<std::tuple<
std::string, std::string>>>& resp) {
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 28dc358..9fa5d88 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -50,8 +50,8 @@
SensorsAsyncResp(crow::Response& response, const std::string& chassisId,
const std::initializer_list<const char*> types,
const std::string& subNode) :
- chassisId(chassisId),
- res(response), types(types), chassisSubNode(subNode)
+ res(response),
+ chassisId(chassisId), types(types), chassisSubNode(subNode)
{
res.jsonValue["@odata.id"] =
"/redfish/v1/Chassis/" + chassisId + "/Thermal";
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index 5d5b3ea..9e6ea4f 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -116,7 +116,6 @@
auto callback = [&res](sdbusplus::message::message &m) {
BMCWEB_LOG_DEBUG << "Match fired";
- bool flag = false;
if (m.is_method_error())
{