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>
diff --git a/http/http_client.hpp b/http/http_client.hpp
index c455c7b..f4c3346 100644
--- a/http/http_client.hpp
+++ b/http/http_client.hpp
@@ -257,11 +257,11 @@
BMCWEB_LOG_DEBUG << "Attempt retry after " << retryIntervalSecs
<< " seconds. RetryCount = " << retryCount;
timer.expires_after(std::chrono::seconds(retryIntervalSecs));
- timer.async_wait([self = shared_from_this()](
- const boost::system::error_code& ec) {
- self->runningTimer = false;
- self->connStateCheck();
- });
+ timer.async_wait(
+ [self = shared_from_this()](const boost::system::error_code&) {
+ self->runningTimer = false;
+ self->connStateCheck();
+ });
return;
}
else
diff --git a/http/http_connection.h b/http/http_connection.h
index 855cc11..da46f77 100644
--- a/http/http_connection.h
+++ b/http/http_connection.h
@@ -86,8 +86,7 @@
public std::enable_shared_from_this<Connection<Adaptor, Handler>>
{
public:
- Connection(boost::asio::io_context& ioService, Handler* handlerIn,
- const std::string& ServerNameIn,
+ Connection(Handler* handlerIn, const std::string& ServerNameIn,
std::function<std::string()>& get_cached_date_str_f,
detail::TimerQueue& timerQueueIn, Adaptor adaptorIn) :
adaptor(std::move(adaptorIn)),
diff --git a/http/http_server.h b/http/http_server.h
index 0099274..b5fd4da 100644
--- a/http/http_server.h
+++ b/http/http_server.h
@@ -31,32 +31,32 @@
class Server
{
public:
- Server(Handler* handlerIn, std::unique_ptr<tcp::acceptor>&& acceptor,
+ Server(Handler* handlerIn, std::unique_ptr<tcp::acceptor>&& acceptorIn,
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)),
+ acceptor(std::move(acceptorIn)),
signals(*ioService, SIGINT, SIGTERM, SIGHUP), tickTimer(*ioService),
timer(*ioService), handler(handlerIn), adaptorCtx(adaptor_ctx)
{}
- Server(Handler* handler, const std::string& bindaddr, uint16_t port,
+ Server(Handler* handlerIn, const std::string& bindaddr, uint16_t port,
std::shared_ptr<boost::asio::ssl::context> adaptor_ctx,
std::shared_ptr<boost::asio::io_context> io =
std::make_shared<boost::asio::io_context>()) :
- Server(handler,
+ Server(handlerIn,
std::make_unique<tcp::acceptor>(
*io, tcp::endpoint(boost::asio::ip::make_address(bindaddr),
port)),
adaptor_ctx, io)
{}
- Server(Handler* handler, int existing_socket,
+ Server(Handler* handlerIn, int existing_socket,
std::shared_ptr<boost::asio::ssl::context> adaptor_ctx,
std::shared_ptr<boost::asio::io_context> io =
std::make_shared<boost::asio::io_context>()) :
- Server(handler,
+ Server(handlerIn,
std::make_unique<tcp::acceptor>(*io, boost::asio::ip::tcp::v6(),
existing_socket),
adaptor_ctx, io)
@@ -187,13 +187,13 @@
{
BMCWEB_LOG_INFO << "Receivied reload signal";
loadCertificate();
- boost::system::error_code ec;
- acceptor->cancel(ec);
- if (ec)
+ boost::system::error_code ec2;
+ acceptor->cancel(ec2);
+ if (ec2)
{
BMCWEB_LOG_ERROR
<< "Error while canceling async operations:"
- << ec.message();
+ << ec2.message();
}
this->startAsyncWaitForSignal();
}
@@ -219,7 +219,7 @@
{
adaptorTemp = Adaptor(*ioService, *adaptorCtx);
auto p = std::make_shared<Connection<Adaptor, Handler>>(
- *ioService, handler, serverName, getCachedDateStr, timerQueue,
+ handler, serverName, getCachedDateStr, timerQueue,
std::move(adaptorTemp.value()));
acceptor->async_accept(p->socket().next_layer(),
@@ -237,7 +237,7 @@
{
adaptorTemp = Adaptor(*ioService);
auto p = std::make_shared<Connection<Adaptor, Handler>>(
- *ioService, handler, serverName, getCachedDateStr, timerQueue,
+ handler, serverName, getCachedDateStr, timerQueue,
std::move(adaptorTemp.value()));
acceptor->async_accept(
diff --git a/http/logging.h b/http/logging.h
index fcac94d..4498c3d 100644
--- a/http/logging.h
+++ b/http/logging.h
@@ -40,8 +40,9 @@
}
public:
- logger(const std::string& prefix, const std::string& filename,
- const size_t line, LogLevel levelIn) :
+ logger([[maybe_unused]] const std::string& prefix,
+ [[maybe_unused]] const std::string& filename,
+ [[maybe_unused]] const size_t line, LogLevel levelIn) :
level(levelIn)
{
#ifdef BMCWEB_ENABLE_LOGGING
@@ -63,7 +64,7 @@
//
template <typename T>
- logger& operator<<(T const& value)
+ logger& operator<<([[maybe_unused]] T const& value)
{
if (level >= get_current_log_level())
{
diff --git a/http/websocket.h b/http/websocket.h
index 5ec6d0f..5e65c99 100644
--- a/http/websocket.h
+++ b/http/websocket.h
@@ -240,26 +240,26 @@
return;
}
doingWrite = true;
- ws.async_write(
- boost::asio::buffer(outBuffer.front()),
- [this, self(shared_from_this())](boost::beast::error_code ec,
- std::size_t bytes_written) {
- doingWrite = false;
- outBuffer.erase(outBuffer.begin());
- if (ec == boost::beast::websocket::error::closed)
- {
- // Do nothing here. doRead handler will call the
- // closeHandler.
- close("Write error");
- return;
- }
- if (ec)
- {
- BMCWEB_LOG_ERROR << "Error in ws.async_write " << ec;
- return;
- }
- doWrite();
- });
+ ws.async_write(boost::asio::buffer(outBuffer.front()),
+ [this, self(shared_from_this())](
+ boost::beast::error_code ec, std::size_t) {
+ doingWrite = false;
+ outBuffer.erase(outBuffer.begin());
+ if (ec == boost::beast::websocket::error::closed)
+ {
+ // Do nothing here. doRead handler will call the
+ // closeHandler.
+ close("Write error");
+ return;
+ }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "Error in ws.async_write "
+ << ec;
+ return;
+ }
+ doWrite();
+ });
}
private: