diff options
author | Ed Tanous <ed@tanous.net> | 2020-07-25 22:02:03 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2020-08-17 23:54:37 +0300 |
commit | cb13a39253848ece442971301ade9c09d98bf08e (patch) | |
tree | 62f2a64fbc98d8ee635a0a81f3ef07afa541981d /redfish-core/include | |
parent | 23a21a1cbed23ace4174664950e595df961e9e69 (diff) | |
download | bmcweb-cb13a39253848ece442971301ade9c09d98bf08e.tar.xz |
Enable unused variable warnings and resolve
This commit enables the "unused variables" warning in clang. Throughout
this, it did point out several issues that would've been functional
bugs, so I think it was worthwhile. It also cleaned up several unused
variable from old constructs that no longer exist.
Tested:
Built with clang. Code no longer emits warnings.
Downloaded bmcweb to system and pulled up the webui, observed webui
loads and logs in properly.
Change-Id: I51505f4222cc147d6f2b87b14d7e2ac4a74cafa8
Signed-off-by: Ed Tanous <ed@tanous.net>
Diffstat (limited to 'redfish-core/include')
-rw-r--r-- | redfish-core/include/node.hpp | 22 | ||||
-rw-r--r-- | redfish-core/include/privileges.hpp | 2 | ||||
-rw-r--r-- | redfish-core/include/server_sent_events.hpp | 11 | ||||
-rw-r--r-- | redfish-core/include/utils/json_utils.hpp | 17 |
4 files changed, 26 insertions, 26 deletions
diff --git a/redfish-core/include/node.hpp b/redfish-core/include/node.hpp index b21fba542b..797160db7f 100644 --- a/redfish-core/include/node.hpp +++ b/redfish-core/include/node.hpp @@ -53,7 +53,7 @@ class Node { public: template <typename... Params> - Node(App& app, std::string&& entityUrl, Params... paramsIn) + Node(App& app, std::string&& entityUrl, [[maybe_unused]] Params... paramsIn) { crow::DynamicRule& get = app.routeDynamic(entityUrl.c_str()); getRule = &get; @@ -157,36 +157,36 @@ class Node protected: // Node is designed to be an abstract class, so doGet is pure virtual - virtual void doGet(crow::Response& res, const crow::Request& req, - const std::vector<std::string>& params) + virtual void doGet(crow::Response& res, const crow::Request&, + const std::vector<std::string>&) { res.result(boost::beast::http::status::method_not_allowed); res.end(); } - virtual void doPatch(crow::Response& res, const crow::Request& req, - const std::vector<std::string>& params) + virtual void doPatch(crow::Response& res, const crow::Request&, + const std::vector<std::string>&) { res.result(boost::beast::http::status::method_not_allowed); res.end(); } - virtual void doPost(crow::Response& res, const crow::Request& req, - const std::vector<std::string>& params) + virtual void doPost(crow::Response& res, const crow::Request&, + const std::vector<std::string>&) { res.result(boost::beast::http::status::method_not_allowed); res.end(); } - virtual void doPut(crow::Response& res, const crow::Request& req, - const std::vector<std::string>& params) + virtual void doPut(crow::Response& res, const crow::Request&, + const std::vector<std::string>&) { res.result(boost::beast::http::status::method_not_allowed); res.end(); } - virtual void doDelete(crow::Response& res, const crow::Request& req, - const std::vector<std::string>& params) + virtual void doDelete(crow::Response& res, const crow::Request&, + const std::vector<std::string>&) { res.result(boost::beast::http::status::method_not_allowed); res.end(); diff --git a/redfish-core/include/privileges.hpp b/redfish-core/include/privileges.hpp index d9bf1fc458..2d44545462 100644 --- a/redfish-core/include/privileges.hpp +++ b/redfish-core/include/privileges.hpp @@ -309,7 +309,7 @@ inline bool isMethodAllowedWithPrivileges(const boost::beast::http::verb method, */ inline bool isMethodAllowedForUser(const boost::beast::http::verb method, const OperationMap& operationMap, - const std::string& user) + const std::string&) { // TODO: load user privileges from configuration as soon as its available // now we are granting all privileges to everyone. diff --git a/redfish-core/include/server_sent_events.hpp b/redfish-core/include/server_sent_events.hpp index 9f0da8ff02..ada5da7b22 100644 --- a/redfish-core/include/server_sent_events.hpp +++ b/redfish-core/include/server_sent_events.hpp @@ -107,8 +107,9 @@ class ServerSentEvents : public std::enable_shared_from_this<ServerSentEvents> sseConn->async_write_some( boost::asio::buffer(outBuffer.data(), outBuffer.size()), - [self(shared_from_this())](boost::beast::error_code ec, - const std::size_t& bytesTransferred) { + [self(shared_from_this())]( + boost::beast::error_code ec, + [[maybe_unused]] const std::size_t& bytesTransferred) { self->outBuffer.erase(0, bytesTransferred); if (ec == boost::asio::error::eof) @@ -131,7 +132,6 @@ class ServerSentEvents : public std::enable_shared_from_this<ServerSentEvents> } BMCWEB_LOG_DEBUG << "async_write_some() bytes transferred: " << bytesTransferred; - boost::ignore_unused(bytesTransferred); self->doWrite(); }); @@ -164,8 +164,9 @@ class ServerSentEvents : public std::enable_shared_from_this<ServerSentEvents> boost::beast::http::async_write_header( *sseConn, *serializer, - [this, response, serializer](const boost::beast::error_code& ec, - const std::size_t& bytesTransferred) { + [this, response, + serializer](const boost::beast::error_code& ec, + [[maybe_unused]] const std::size_t& bytesTransferred) { if (ec) { BMCWEB_LOG_ERROR << "Error sending header" << ec; diff --git a/redfish-core/include/utils/json_utils.hpp b/redfish-core/include/utils/json_utils.hpp index d578de4c46..c4f54d719c 100644 --- a/redfish-core/include/utils/json_utils.hpp +++ b/redfish-core/include/utils/json_utils.hpp @@ -86,8 +86,7 @@ enum class UnpackErrorCode }; template <typename ToType, typename FromType> -bool checkRange(const FromType& from, nlohmann::json& jsonValue, - const std::string& key) +bool checkRange(const FromType& from, const std::string& key) { if (from > std::numeric_limits<ToType>::max()) { @@ -137,7 +136,7 @@ UnpackErrorCode unpackValueWithErrorCode(nlohmann::json& jsonValue, { return UnpackErrorCode::invalidType; } - if (!checkRange<Type>(*jsonPtr, jsonValue, key)) + if (!checkRange<Type>(*jsonPtr, key)) { return UnpackErrorCode::outOfRange; } @@ -151,7 +150,7 @@ UnpackErrorCode unpackValueWithErrorCode(nlohmann::json& jsonValue, { return UnpackErrorCode::invalidType; } - if (!checkRange<Type>(*jsonPtr, jsonValue, key)) + if (!checkRange<Type>(*jsonPtr, key)) { return UnpackErrorCode::outOfRange; } @@ -166,7 +165,7 @@ UnpackErrorCode unpackValueWithErrorCode(nlohmann::json& jsonValue, { return UnpackErrorCode::invalidType; } - if (!checkRange<Type>(*jsonPtr, jsonValue, key)) + if (!checkRange<Type>(*jsonPtr, key)) { return UnpackErrorCode::outOfRange; } @@ -326,8 +325,8 @@ bool unpackValue(nlohmann::json& jsonValue, const std::string& key, Type& value) } template <size_t Count, size_t Index> -bool readJsonValues(const std::string& key, nlohmann::json& jsonValue, - crow::Response& res, std::bitset<Count>& handled) +bool readJsonValues(const std::string& key, nlohmann::json&, + crow::Response& res, std::bitset<Count>&) { BMCWEB_LOG_DEBUG << "Unable to find variable for key" << key; messages::propertyUnknown(res, key); @@ -356,7 +355,7 @@ bool readJsonValues(const std::string& key, nlohmann::json& jsonValue, } template <size_t Index = 0, size_t Count> -bool handleMissing(std::bitset<Count>& handled, crow::Response& res) +bool handleMissing(std::bitset<Count>&, crow::Response&) { return true; } @@ -364,7 +363,7 @@ bool handleMissing(std::bitset<Count>& handled, crow::Response& res) template <size_t Index = 0, size_t Count, typename ValueType, typename... UnpackTypes> bool handleMissing(std::bitset<Count>& handled, crow::Response& res, - const char* key, ValueType& unused, UnpackTypes&... in) + const char* key, ValueType&, UnpackTypes&... in) { bool ret = true; if (!handled.test(Index) && !is_optional_v<ValueType>) |