summaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-06-04 19:06:59 +0300
committerEd Tanous <ed@tanous.net>2022-06-28 17:56:45 +0300
commit8a5928102841d34564c7f3fcd35e64d33638bff1 (patch)
treed02a4e50cddd3e0c427577697f00b3811dc42bc5 /http
parent517d9a58b35238ba45ab74812b397e942a9f662a (diff)
downloadbmcweb-8a5928102841d34564c7f3fcd35e64d33638bff1.tar.xz
Fix shadowed variable issues
This patchset is the conclusion of a multi-year effort to try to fix shadowed variable names. Variables seem to be shadowed all over, and in most places they exist, there's a "code smell" of things that aren't doing what the author intended. This commit attempts to clean up these in several ways by: 1. Renaming variables where appropriate. 2. Preferring to refer to member variables directly when operating within a class 3. Rearranging code so that pass through variables are handled in the calling scope, rather than passing them through. These patterns are applied throughout the codebase, to the point where -Wshadow can be enabled in meson.build. Tested: Code compiles, unit tests pass. Still need to run redfish service validator. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: If703398c2282f9e096ca2694fd94515de36a098b
Diffstat (limited to 'http')
-rw-r--r--http/http_client.hpp32
-rw-r--r--http/http_connection.hpp6
-rw-r--r--http/http_server.hpp12
-rw-r--r--http/websocket.hpp16
4 files changed, 34 insertions, 32 deletions
diff --git a/http/http_client.hpp b/http/http_client.hpp
index 571b5a9465..ae077ef07b 100644
--- a/http/http_client.hpp
+++ b/http/http_client.hpp
@@ -93,11 +93,11 @@ struct PendingRequest
std::function<void(bool, uint32_t, Response&)> callback;
RetryPolicyData retryPolicy;
PendingRequest(
- boost::beast::http::request<boost::beast::http::string_body>&& req,
- const std::function<void(bool, uint32_t, Response&)>& callback,
- const RetryPolicyData& retryPolicy) :
- req(std::move(req)),
- callback(callback), retryPolicy(retryPolicy)
+ boost::beast::http::request<boost::beast::http::string_body>&& reqIn,
+ const std::function<void(bool, uint32_t, Response&)>& callbackIn,
+ const RetryPolicyData& retryPolicyIn) :
+ req(std::move(reqIn)),
+ callback(callbackIn), retryPolicy(retryPolicyIn)
{}
};
@@ -394,11 +394,12 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo>
}
public:
- explicit ConnectionInfo(boost::asio::io_context& ioc, const std::string& id,
- const std::string& destIP, const uint16_t destPort,
- const unsigned int connId) :
- subId(id),
- host(destIP), port(destPort), connId(connId), conn(ioc), timer(ioc)
+ explicit ConnectionInfo(boost::asio::io_context& ioc,
+ const std::string& idIn, const std::string& destIP,
+ const uint16_t destPort,
+ const unsigned int connIdIn) :
+ subId(idIn),
+ host(destIP), port(destPort), connId(connIdIn), conn(ioc), timer(ioc)
{}
};
@@ -598,11 +599,12 @@ class ConnectionPool : public std::enable_shared_from_this<ConnectionPool>
}
public:
- explicit ConnectionPool(boost::asio::io_context& ioc, const std::string& id,
- const std::string& destIP,
- const uint16_t destPort) :
- ioc(ioc),
- id(id), destIP(destIP), destPort(destPort)
+ explicit ConnectionPool(boost::asio::io_context& iocIn,
+ const std::string& idIn,
+ const std::string& destIPIn,
+ const uint16_t destPortIn) :
+ ioc(iocIn),
+ id(idIn), destIP(destIPIn), destPort(destPortIn)
{
std::string clientKey = destIP + ":" + std::to_string(destPort);
BMCWEB_LOG_DEBUG << "Initializing connection pool for " << destIP << ":"
diff --git a/http/http_connection.hpp b/http/http_connection.hpp
index 55ea84707c..d20fd250c4 100644
--- a/http/http_connection.hpp
+++ b/http/http_connection.hpp
@@ -151,10 +151,10 @@ class Connection :
}
// Check if certificate is OK
- int error = X509_STORE_CTX_get_error(cts);
- if (error != X509_V_OK)
+ int ctxError = X509_STORE_CTX_get_error(cts);
+ if (ctxError != X509_V_OK)
{
- BMCWEB_LOG_INFO << this << " Last TLS error is: " << error;
+ BMCWEB_LOG_INFO << this << " Last TLS error is: " << ctxError;
return true;
}
// Check that we have reached final certificate in chain
diff --git a/http/http_server.hpp b/http/http_server.hpp
index a0ccc09c5a..050a3f000e 100644
--- a/http/http_server.hpp
+++ b/http/http_server.hpp
@@ -30,34 +30,34 @@ class Server
public:
Server(Handler* handlerIn,
std::unique_ptr<boost::asio::ip::tcp::acceptor>&& acceptorIn,
- std::shared_ptr<boost::asio::ssl::context> adaptorCtx,
+ std::shared_ptr<boost::asio::ssl::context> adaptorCtxIn,
std::shared_ptr<boost::asio::io_context> io =
std::make_shared<boost::asio::io_context>()) :
ioService(std::move(io)),
acceptor(std::move(acceptorIn)),
signals(*ioService, SIGINT, SIGTERM, SIGHUP), handler(handlerIn),
- adaptorCtx(std::move(adaptorCtx))
+ adaptorCtx(std::move(adaptorCtxIn))
{}
Server(Handler* handlerIn, const std::string& bindaddr, uint16_t port,
- const std::shared_ptr<boost::asio::ssl::context>& adaptorCtx,
+ const std::shared_ptr<boost::asio::ssl::context>& adaptorCtxIn,
const std::shared_ptr<boost::asio::io_context>& io =
std::make_shared<boost::asio::io_context>()) :
Server(handlerIn,
std::make_unique<boost::asio::ip::tcp::acceptor>(
*io, boost::asio::ip::tcp::endpoint(
boost::asio::ip::make_address(bindaddr), port)),
- adaptorCtx, io)
+ adaptorCtxIn, io)
{}
Server(Handler* handlerIn, int existingSocket,
- const std::shared_ptr<boost::asio::ssl::context>& adaptorCtx,
+ const std::shared_ptr<boost::asio::ssl::context>& adaptorCtxIn,
const std::shared_ptr<boost::asio::io_context>& io =
std::make_shared<boost::asio::io_context>()) :
Server(handlerIn,
std::make_unique<boost::asio::ip::tcp::acceptor>(
*io, boost::asio::ip::tcp::v6(), existingSocket),
- adaptorCtx, io)
+ adaptorCtxIn, io)
{}
void updateDateStr()
diff --git a/http/websocket.hpp b/http/websocket.hpp
index 9a735fdabf..3aa8554e1c 100644
--- a/http/websocket.hpp
+++ b/http/websocket.hpp
@@ -70,18 +70,18 @@ class ConnectionImpl : public Connection
public:
ConnectionImpl(
const crow::Request& reqIn, Adaptor adaptorIn,
- std::function<void(Connection&)> openHandler,
+ std::function<void(Connection&)> openHandlerIn,
std::function<void(Connection&, const std::string&, bool)>
- messageHandler,
- std::function<void(Connection&, const std::string&)> closeHandler,
- std::function<void(Connection&)> errorHandler) :
+ messageHandlerIn,
+ std::function<void(Connection&, const std::string&)> closeHandlerIn,
+ std::function<void(Connection&)> errorHandlerIn) :
Connection(reqIn, reqIn.session == nullptr ? std::string{}
: reqIn.session->username),
ws(std::move(adaptorIn)), inBuffer(inString, 131088),
- openHandler(std::move(openHandler)),
- messageHandler(std::move(messageHandler)),
- closeHandler(std::move(closeHandler)),
- errorHandler(std::move(errorHandler)), session(reqIn.session)
+ openHandler(std::move(openHandlerIn)),
+ messageHandler(std::move(messageHandlerIn)),
+ closeHandler(std::move(closeHandlerIn)),
+ errorHandler(std::move(errorHandlerIn)), session(reqIn.session)
{
/* Turn on the timeouts on websocket stream to server role */
ws.set_option(boost::beast::websocket::stream_base::timeout::suggested(