summaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2020-07-25 07:45:05 +0300
committerEd Tanous <ed@tanous.net>2020-08-17 23:54:37 +0300
commit23a21a1cbed23ace4174664950e595df961e9e69 (patch)
tree12e7cc9d9301642fc1e48332a0e0834c54e8c8af /http
parent52cc112d962920b035c870127784bcbd98948fad (diff)
downloadbmcweb-23a21a1cbed23ace4174664950e595df961e9e69.tar.xz
Enable clang warnings
This commit enables clang warnings, and fixes all warnings that were found. Most of these fall into a couple categories: Variable shadow issues were fixed by renaming variables unused parameter warnings were resolved by either checking error codes that had been ignored, or removing the name of the variable from the scope. Other various warnings were fixed in the best way I was able to come up with. Note, the redfish Node class is especially insidious, as it causes all imlementers to have variables for parameters, regardless of whether or not they are used. Deprecating the Node class is on my list of things to do, as it adds extra overhead, and in general isn't a useful abstraction. For now, I have simply fixed all the handlers. Tested: Added the current meta-clang meta layer into bblayers.conf, and added TOOLCHAIN_pn-bmcweb = "clang" to my local.conf Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: Ia75b94010359170159c703e535d1c1af182fe700
Diffstat (limited to 'http')
-rw-r--r--http/app.h8
-rw-r--r--http/common.h27
-rw-r--r--http/http_client.hpp2
-rw-r--r--http/http_connection.h9
-rw-r--r--http/http_response.h2
-rw-r--r--http/http_server.h6
-rw-r--r--http/routing.h26
-rw-r--r--http/utility.h8
-rw-r--r--http/websocket.h6
9 files changed, 34 insertions, 60 deletions
diff --git a/http/app.h b/http/app.h
index dfd5304543..b8103743c3 100644
--- a/http/app.h
+++ b/http/app.h
@@ -97,13 +97,13 @@ class App
#ifdef BMCWEB_ENABLE_SSL
if (-1 == socketFd)
{
- sslServer = std::move(std::make_unique<ssl_server_t>(
- this, bindaddrStr, portUint, sslContext, io));
+ sslServer = std::make_unique<ssl_server_t>(
+ this, bindaddrStr, portUint, sslContext, io);
}
else
{
- sslServer = std::move(
- std::make_unique<ssl_server_t>(this, socketFd, sslContext, io));
+ sslServer =
+ std::make_unique<ssl_server_t>(this, socketFd, sslContext, io);
}
sslServer->setTickFunction(tickInterval, tickFunction);
sslServer->run();
diff --git a/http/common.h b/http/common.h
index 77db63c694..95cc763291 100644
--- a/http/common.h
+++ b/http/common.h
@@ -12,33 +12,6 @@
namespace crow
{
-inline std::string methodName(boost::beast::http::verb method)
-{
- switch (method)
- {
- case boost::beast::http::verb::delete_:
- return "DELETE";
- case boost::beast::http::verb::get:
- return "GET";
- case boost::beast::http::verb::head:
- return "HEAD";
- case boost::beast::http::verb::post:
- return "POST";
- case boost::beast::http::verb::put:
- return "PUT";
- case boost::beast::http::verb::connect:
- return "CONNECT";
- case boost::beast::http::verb::options:
- return "OPTIONS";
- case boost::beast::http::verb::trace:
- return "TRACE";
- case boost::beast::http::verb::patch:
- return "PATCH";
- default:
- return "invalid";
- }
-}
-
enum class ParamType
{
INT,
diff --git a/http/http_client.hpp b/http/http_client.hpp
index e6a7db1e04..c455c7bfcf 100644
--- a/http/http_client.hpp
+++ b/http/http_client.hpp
@@ -302,8 +302,6 @@ class HttpClient : public std::enable_shared_from_this<HttpClient>
sendMessage(data);
break;
}
- default:
- break;
}
}
diff --git a/http/http_connection.h b/http/http_connection.h
index 609d4a10b1..855cc11bcc 100644
--- a/http/http_connection.h
+++ b/http/http_connection.h
@@ -176,7 +176,7 @@ class Connection :
bool isKeyUsageKeyAgreement = false;
ASN1_BIT_STRING* usage = static_cast<ASN1_BIT_STRING*>(
- X509_get_ext_d2i(peerCert, NID_key_usage, NULL, NULL));
+ X509_get_ext_d2i(peerCert, NID_key_usage, nullptr, nullptr));
if (usage == nullptr)
{
@@ -208,8 +208,9 @@ class Connection :
// Determine that ExtendedKeyUsage includes Client Auth
- stack_st_ASN1_OBJECT* extUsage = static_cast<stack_st_ASN1_OBJECT*>(
- X509_get_ext_d2i(peerCert, NID_ext_key_usage, NULL, NULL));
+ stack_st_ASN1_OBJECT* extUsage =
+ static_cast<stack_st_ASN1_OBJECT*>(X509_get_ext_d2i(
+ peerCert, NID_ext_key_usage, nullptr, nullptr));
if (extUsage == nullptr)
{
@@ -348,7 +349,7 @@ class Connection :
if (!isInvalidRequest)
{
- req->socket = [this, self = shared_from_this()]() -> Adaptor& {
+ req->socket = [self = shared_from_this()]() -> Adaptor& {
return self->socket();
};
diff --git a/http/http_response.h b/http/http_response.h
index 7be6b0914c..68e3f2d228 100644
--- a/http/http_response.h
+++ b/http/http_response.h
@@ -104,7 +104,7 @@ struct Response
void preparePayload()
{
stringResponse->prepare_payload();
- };
+ }
void clear()
{
diff --git a/http/http_server.h b/http/http_server.h
index c87ddd428c..0099274a82 100644
--- a/http/http_server.h
+++ b/http/http_server.h
@@ -31,14 +31,14 @@ template <typename Handler, typename Adaptor = boost::asio::ip::tcp::socket>
class Server
{
public:
- Server(Handler* handler, std::unique_ptr<tcp::acceptor>&& acceptor,
+ Server(Handler* handlerIn, std::unique_ptr<tcp::acceptor>&& acceptor,
std::shared_ptr<boost::asio::ssl::context> adaptor_ctx,
std::shared_ptr<boost::asio::io_context> io =
std::make_shared<boost::asio::io_context>()) :
ioService(std::move(io)),
acceptor(std::move(acceptor)),
signals(*ioService, SIGINT, SIGTERM, SIGHUP), tickTimer(*ioService),
- timer(*ioService), handler(handler), adaptorCtx(adaptor_ctx)
+ timer(*ioService), handler(handlerIn), adaptorCtx(adaptor_ctx)
{}
Server(Handler* handler, const std::string& bindaddr, uint16_t port,
@@ -93,7 +93,7 @@ class Server
size_t dateStrSz =
strftime(&dateStr[0], 99, "%a, %d %b %Y %H:%M:%S GMT", &myTm);
dateStr.resize(dateStrSz);
- };
+ }
void run()
{
diff --git a/http/routing.h b/http/routing.h
index 2f90c0752d..1af1b2bc47 100644
--- a/http/routing.h
+++ b/http/routing.h
@@ -219,7 +219,7 @@ struct Wrapped
template <typename Req, typename... Args>
struct ReqHandlerWrapper
{
- ReqHandlerWrapper(Func f) : f(std::move(f))
+ ReqHandlerWrapper(Func fIn) : f(std::move(fIn))
{}
void operator()(const Request& req, Response& res, Args... args)
@@ -315,7 +315,7 @@ class WebSocketRule : public BaseRule
using self_t = WebSocketRule;
public:
- WebSocketRule(std::string rule) : BaseRule(std::move(rule))
+ WebSocketRule(std::string ruleIn) : BaseRule(std::move(ruleIn))
{}
void validate() override
@@ -428,7 +428,7 @@ struct RuleParameterTraits
}
template <typename... MethodArgs>
- self_t& requires(std::initializer_list<const char*> l)
+ self_t& privileges(std::initializer_list<const char*> l)
{
self_t* self = static_cast<self_t*>(this);
self->privilegesSet.emplace_back(l);
@@ -436,7 +436,7 @@ struct RuleParameterTraits
}
template <typename... MethodArgs>
- self_t& requires(const std::vector<redfish::Privileges>& p)
+ self_t& privileges(const std::vector<redfish::Privileges>& p)
{
self_t* self = static_cast<self_t*>(this);
for (const redfish::Privileges& privilege : p)
@@ -450,7 +450,7 @@ struct RuleParameterTraits
class DynamicRule : public BaseRule, public RuleParameterTraits<DynamicRule>
{
public:
- DynamicRule(std::string rule) : BaseRule(std::move(rule))
+ DynamicRule(std::string ruleIn) : BaseRule(std::move(ruleIn))
{}
void validate() override
@@ -982,7 +982,7 @@ class Trie
case ParamType::PATH:
BMCWEB_LOG_DEBUG << "<path>";
break;
- default:
+ case ParamType::MAX:
BMCWEB_LOG_DEBUG << "<ERROR>";
break;
}
@@ -1203,9 +1203,9 @@ class Router
// Check to see if this url exists at any verb
for (const PerMethod& p : perMethods)
{
- const std::pair<unsigned, RoutingParams>& found =
+ const std::pair<unsigned, RoutingParams>& found2 =
p.trie.find(req.url);
- if (found.first > 0)
+ if (found2.first > 0)
{
res.result(boost::beast::http::status::method_not_allowed);
res.end();
@@ -1340,7 +1340,7 @@ class Router
}
}
- // Get the user privileges from the role
+ // Get the userprivileges from the role
redfish::Privileges userPrivileges =
redfish::getUserPrivileges(userRole);
@@ -1349,10 +1349,10 @@ class Router
// value from any previous use of this session.
req.session->isConfigureSelfOnly = passwordExpired;
- // Modify privileges if isConfigureSelfOnly.
+ // Modifyprivileges if isConfigureSelfOnly.
if (req.session->isConfigureSelfOnly)
{
- // Remove all privileges except ConfigureSelf
+ // Remove allprivileges except ConfigureSelf
userPrivileges = userPrivileges.intersection(
redfish::Privileges{"ConfigureSelf"});
BMCWEB_LOG_DEBUG << "Operation limited to ConfigureSelf";
@@ -1384,8 +1384,8 @@ class Router
{
for (size_t i = 0; i < perMethods.size(); i++)
{
- BMCWEB_LOG_DEBUG
- << methodName(static_cast<boost::beast::http::verb>(i));
+ BMCWEB_LOG_DEBUG << boost::beast::http::to_string(
+ static_cast<boost::beast::http::verb>(i));
perMethods[i].trie.debugPrint();
}
}
diff --git a/http/utility.h b/http/utility.h
index 825409185a..fad212fddd 100644
--- a/http/utility.h
+++ b/http/utility.h
@@ -39,7 +39,8 @@ class ConstStr
}
constexpr char operator[](unsigned i) const
{
- return requiresInRange(i, sizeUint), beginPtr[i];
+ requiresInRange(i, sizeUint);
+ return beginPtr[i];
}
constexpr operator const char*() const
@@ -760,9 +761,8 @@ inline void escapeHtml(std::string& data)
inline void convertToLinks(std::string& s)
{
// Convert anything with a redfish path into a link
- const static std::regex redfishPath{
- "(&quot;((.*))&quot;[ \\n]*:[ "
- "\\n]*)(&quot;((?!&quot;)/redfish/.*)&quot;)"};
+ const std::regex redfishPath{"(&quot;((.*))&quot;[ \\n]*:[ "
+ "\\n]*)(&quot;((?!&quot;)/redfish/.*)&quot;)"};
s = std::regex_replace(s, redfishPath, "$1<a href=\"$5\">$4</a>");
}
diff --git a/http/websocket.h b/http/websocket.h
index 7670196521..5ec6d0ffd5 100644
--- a/http/websocket.h
+++ b/http/websocket.h
@@ -22,10 +22,12 @@ struct Connection : std::enable_shared_from_this<Connection>
{
public:
explicit Connection(const crow::Request& reqIn) :
- req(reqIn.req), userdataPtr(nullptr){};
+ req(reqIn.req), userdataPtr(nullptr)
+ {}
explicit Connection(const crow::Request& reqIn, std::string user) :
- req(reqIn.req), userName{std::move(user)}, userdataPtr(nullptr){};
+ req(reqIn.req), userName{std::move(user)}, userdataPtr(nullptr)
+ {}
virtual void sendBinary(const std::string_view msg) = 0;
virtual void sendBinary(std::string&& msg) = 0;