From 8f4e7fd0a009934ad1ca9b59f2327e56c46a7763 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Thu, 22 Jun 2017 10:27:45 -0700 Subject: [PATCH] Fix unused variable warnings --- example/doc/http_examples.hpp | 6 +++++ example/echo-op/echo_op.cpp | 5 ++++- example/server-framework/file_body.hpp | 2 ++ example/server-framework/file_service.hpp | 3 +++ example/server-framework/ssl_certificate.hpp | 2 +- example/server-framework/write_msg.hpp | 1 + extras/beast/test/string_iostream.hpp | 2 +- extras/beast/test/string_istream.hpp | 2 +- extras/beast/test/string_ostream.hpp | 6 ++--- include/beast/config.hpp | 1 + include/beast/core/detail/type_traits.hpp | 13 ----------- include/beast/core/handler_alloc.hpp | 8 ++++--- include/beast/core/impl/static_string.ipp | 2 +- include/beast/http/empty_body.hpp | 2 +- include/beast/http/impl/fields.ipp | 4 ++-- include/beast/http/impl/read.ipp | 2 +- include/beast/http/impl/write.ipp | 2 +- include/beast/websocket/impl/accept.ipp | 4 ++-- include/beast/websocket/impl/write.ipp | 2 +- include/beast/websocket/stream.hpp | 4 ++-- test/benchmarks/nodejs_parser.hpp | 23 +++++++++----------- test/http/message.cpp | 2 +- test/http/test_parser.hpp | 2 +- test/http/write.cpp | 4 ++-- test/websocket/doc_snippets.cpp | 1 + 25 files changed, 54 insertions(+), 51 deletions(-) diff --git a/example/doc/http_examples.hpp b/example/doc/http_examples.hpp index dca2ab1a..1747e608 100644 --- a/example/doc/http_examples.hpp +++ b/example/doc/http_examples.hpp @@ -950,6 +950,7 @@ void custom_parser:: on_request(verb method, string_view method_str, string_view path, int version, error_code& ec) { + boost::ignore_unused(method, method_str, path, version); ec = {}; } @@ -958,6 +959,7 @@ void custom_parser:: on_response(int status, string_view reason, int version, error_code& ec) { + boost::ignore_unused(status, reason, version); ec = {}; } @@ -966,6 +968,7 @@ void custom_parser:: on_field(field f, string_view name, string_view value, error_code& ec) { + boost::ignore_unused(f, name, value); ec = {}; } @@ -981,6 +984,7 @@ void custom_parser:: on_body(boost::optional const& content_length, error_code& ec) { + boost::ignore_unused(content_length); ec = {}; } @@ -988,6 +992,7 @@ template void custom_parser:: on_data(string_view s, error_code& ec) { + boost::ignore_unused(s); ec = {}; } @@ -996,6 +1001,7 @@ void custom_parser:: on_chunk(std::uint64_t size, string_view extension, error_code& ec) { + boost::ignore_unused(size, extension); ec = {}; } diff --git a/example/echo-op/echo_op.cpp b/example/echo-op/echo_op.cpp index ecccc2f2..150c76fc 100644 --- a/example/echo-op/echo_op.cpp +++ b/example/echo-op/echo_op.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -328,7 +329,7 @@ async_echo(AsyncStream& stream, CompletionToken&& token) //] -int main() +int main(int, char** argv) { using address_type = boost::asio::ip::address; using socket_type = boost::asio::ip::tcp::socket; @@ -347,6 +348,8 @@ int main() async_echo(sock, [&](beast::error_code ec) { + if(ec) + std::cerr << argv[0] << ": " << ec.message() << std::endl; }); ios.run(); return 0; diff --git a/example/server-framework/file_body.hpp b/example/server-framework/file_body.hpp index 96bf80fa..892c40aa 100644 --- a/example/server-framework/file_body.hpp +++ b/example/server-framework/file_body.hpp @@ -346,6 +346,8 @@ void file_body::writer:: init(boost::optional const& content_length, beast::error_code& ec) { + boost::ignore_unused(content_length); + // Attempt to open the file for writing file_ = fopen(path_.string().c_str(), "wb"); diff --git a/example/server-framework/file_service.hpp b/example/server-framework/file_service.hpp index 2fa2b1ca..4101f680 100644 --- a/example/server-framework/file_service.hpp +++ b/example/server-framework/file_service.hpp @@ -111,6 +111,8 @@ public: beast::http::request&& req, Send const& send) const { + boost::ignore_unused(ep); + // Determine our action based on the method switch(req.method()) { @@ -219,6 +221,7 @@ private: beast::http::request const& req, boost::filesystem::path const& rel_path) const { + boost::ignore_unused(rel_path); beast::http::response res; res.version = req.version; res.result(beast::http::status::not_found); diff --git a/example/server-framework/ssl_certificate.hpp b/example/server-framework/ssl_certificate.hpp index d8733779..aaa2e0b8 100644 --- a/example/server-framework/ssl_certificate.hpp +++ b/example/server-framework/ssl_certificate.hpp @@ -119,7 +119,7 @@ ssl_certificate::construct() "-----END DH PARAMETERS-----\n"; ctx_.set_password_callback( - [](std::size_t size, + [](std::size_t, boost::asio::ssl::context_base::password_purpose) { return "test"; diff --git a/example/server-framework/write_msg.hpp b/example/server-framework/write_msg.hpp index 4a27f110..8bbb9b2d 100644 --- a/example/server-framework/write_msg.hpp +++ b/example/server-framework/write_msg.hpp @@ -57,6 +57,7 @@ class write_msg_op : stream(stream_) , msg(std::move(msg_)) { + boost::ignore_unused(handler); } }; diff --git a/extras/beast/test/string_iostream.hpp b/extras/beast/test/string_iostream.hpp index d735d59c..eeeb7e21 100644 --- a/extras/beast/test/string_iostream.hpp +++ b/extras/beast/test/string_iostream.hpp @@ -148,7 +148,7 @@ public: friend void teardown(websocket::teardown_tag, - string_iostream& stream, + string_iostream&, boost::system::error_code& ec) { ec.assign(0, ec.category()); diff --git a/extras/beast/test/string_istream.hpp b/extras/beast/test/string_istream.hpp index 2e610f79..c9692b87 100644 --- a/extras/beast/test/string_istream.hpp +++ b/extras/beast/test/string_istream.hpp @@ -136,7 +136,7 @@ public: friend void teardown(websocket::teardown_tag, - string_istream& stream, + string_istream&, boost::system::error_code& ec) { ec.assign(0, ec.category()); diff --git a/extras/beast/test/string_ostream.hpp b/extras/beast/test/string_ostream.hpp index 530d623a..dd57d8a9 100644 --- a/extras/beast/test/string_ostream.hpp +++ b/extras/beast/test/string_ostream.hpp @@ -57,7 +57,7 @@ public: template std::size_t - read_some(MutableBufferSequence const& buffers, + read_some(MutableBufferSequence const&, error_code& ec) { ec = boost::asio::error::eof; @@ -67,7 +67,7 @@ public: template async_return_type< ReadHandler, void(error_code, std::size_t)> - async_read_some(MutableBufferSequence const& buffers, + async_read_some(MutableBufferSequence const&, ReadHandler&& handler) { async_completion #include /* diff --git a/include/beast/core/detail/type_traits.hpp b/include/beast/core/detail/type_traits.hpp index 28125f9c..f80f6fe4 100644 --- a/include/beast/core/detail/type_traits.hpp +++ b/include/beast/core/detail/type_traits.hpp @@ -62,19 +62,6 @@ inline void accept_rv(T){} -template -inline -void -ignore_unused(Ts const& ...) -{ -} - -template -inline -void -ignore_unused() -{} - template std::size_t constexpr max_sizeof() diff --git a/include/beast/core/handler_alloc.hpp b/include/beast/core/handler_alloc.hpp index 492d84b6..b7656a88 100644 --- a/include/beast/core/handler_alloc.hpp +++ b/include/beast/core/handler_alloc.hpp @@ -134,8 +134,9 @@ public: template friend bool - operator==(handler_alloc const& lhs, - handler_alloc const& rhs) + operator==( + handler_alloc const&, + handler_alloc const&) { return true; } @@ -143,7 +144,8 @@ public: template friend bool - operator!=(handler_alloc const& lhs, + operator!=( + handler_alloc const& lhs, handler_alloc const& rhs) { return ! (lhs == rhs); diff --git a/include/beast/core/impl/static_string.ipp b/include/beast/core/impl/static_string.ipp index 6ad4562a..9dd4391f 100644 --- a/include/beast/core/impl/static_string.ipp +++ b/include/beast/core/impl/static_string.ipp @@ -524,7 +524,7 @@ assign_char(CharT ch, std::true_type) -> template auto static_string:: -assign_char(CharT ch, std::false_type) -> +assign_char(CharT, std::false_type) -> static_string& { BOOST_THROW_EXCEPTION(std::length_error{ diff --git a/include/beast/http/empty_body.hpp b/include/beast/http/empty_body.hpp index 8ee8bb71..9aa1b118 100644 --- a/include/beast/http/empty_body.hpp +++ b/include/beast/http/empty_body.hpp @@ -90,7 +90,7 @@ struct empty_body { template explicit - writer(message& msg) + writer(message&) { } diff --git a/include/beast/http/impl/fields.ipp b/include/beast/http/impl/fields.ipp index bbfce4ce..0cb9db8f 100644 --- a/include/beast/http/impl/fields.ipp +++ b/include/beast/http/impl/fields.ipp @@ -230,7 +230,7 @@ template template void basic_fields::reader:: -prepare(String& s, basic_fields const& f, +prepare(String& s, basic_fields const&, unsigned version, verb v) { if(v == verb::unknown) @@ -271,7 +271,7 @@ template template void basic_fields::reader:: -prepare(String& s,basic_fields const& f, +prepare(String& s, basic_fields const&, unsigned version, unsigned code) { if(version == 11) diff --git a/include/beast/http/impl/read.ipp b/include/beast/http/impl/read.ipp index b530a1c3..08e7c552 100644 --- a/include/beast/http/impl/read.ipp +++ b/include/beast/http/impl/read.ipp @@ -318,7 +318,7 @@ class read_msg_op message_type& m; parser_type p; - data(Handler& handler, Stream& s_, + data(Handler&, Stream& s_, DynamicBuffer& b_, message_type& m_) : s(s_) , b(b_) diff --git a/include/beast/http/impl/write.ipp b/include/beast/http/impl/write.ipp index 3f781856..2077611f 100644 --- a/include/beast/http/impl/write.ipp +++ b/include/beast/http/impl/write.ipp @@ -358,7 +358,7 @@ class write_msg_op serializer sr; - data(Handler& h, Stream& s_, message< + data(Handler&, Stream& s_, message< isRequest, Body, Fields>& m_) : s(s_) , sr(m_, no_chunk_decorator{}) diff --git a/include/beast/websocket/impl/accept.ipp b/include/beast/websocket/impl/accept.ipp index a13baceb..86a3a32b 100644 --- a/include/beast/websocket/impl/accept.ipp +++ b/include/beast/websocket/impl/accept.ipp @@ -175,7 +175,7 @@ class stream::accept_op Decorator decorator; http::request_parser p; - data(Handler& handler, stream& ws_, + data(Handler&, stream& ws_, Decorator const& decorator_) : ws(ws_) , decorator(decorator_) @@ -183,7 +183,7 @@ class stream::accept_op } template - data(Handler& handler, stream& ws_, + data(Handler&, stream& ws_, Buffers const& buffers, Decorator const& decorator_) : ws(ws_) diff --git a/include/beast/websocket/impl/write.ipp b/include/beast/websocket/impl/write.ipp index b533423b..9bc819ff 100644 --- a/include/beast/websocket/impl/write.ipp +++ b/include/beast/websocket/impl/write.ipp @@ -559,7 +559,7 @@ class stream::write_op consuming_buffers cb; std::size_t remain; - data(Handler& handler, stream& ws_, + data(Handler&, stream& ws_, Buffers const& bs) : ws(ws_) , cb(bs) diff --git a/include/beast/websocket/stream.hpp b/include/beast/websocket/stream.hpp index ceee5774..e068f6a3 100644 --- a/include/beast/websocket/stream.hpp +++ b/include/beast/websocket/stream.hpp @@ -3099,13 +3099,13 @@ private: static void - default_decorate_req(request_type& res) + default_decorate_req(request_type&) { } static void - default_decorate_res(response_type& res) + default_decorate_res(response_type&) { } diff --git a/test/benchmarks/nodejs_parser.hpp b/test/benchmarks/nodejs_parser.hpp index c430a6c8..f1a76b63 100644 --- a/test/benchmarks/nodejs_parser.hpp +++ b/test/benchmarks/nodejs_parser.hpp @@ -768,31 +768,30 @@ private: } void - on_field(std::string const& field, std::string const& value) + on_field(std::string const&, std::string const&) { } void - on_headers_complete(error_code&) + on_headers_complete(error_code& ec) { // vFALCO TODO Decode the Content-Length and // Transfer-Encoding, see if we can reserve the buffer. // // r_.reserve(content_length) + ec.assign(0, ec.category()); } bool - on_request(unsigned method, std::string const& url, - int major, int minor, bool /*keep_alive*/, bool /*upgrade*/, - std::true_type) + on_request(unsigned, std::string const&, + int, int, bool, bool, std::true_type) { return true; } bool on_request(unsigned, std::string const&, - int, int, bool, bool, - std::false_type) + int, int, bool, bool, std::false_type) { return true; } @@ -808,11 +807,9 @@ private: } bool - on_response(int status, std::string const& reason, - int major, int minor, bool keep_alive, bool upgrade, - std::true_type) + on_response(int, std::string const&, + int, int, bool, bool, std::true_type) { - beast::detail::ignore_unused(keep_alive, upgrade); return true; } @@ -833,9 +830,9 @@ private: } void - on_body(void const* data, - std::size_t size, error_code& ec) + on_body(void const*, std::size_t, error_code& ec) { + ec.assign(0, ec.category()); } void diff --git a/test/http/message.cpp b/test/http/message.cpp index 7d085ce8..d9469755 100644 --- a/test/http/message.cpp +++ b/test/http/message.cpp @@ -160,7 +160,7 @@ public: other.moved_from = true; } - MoveFields& operator=(MoveFields&& other) + MoveFields& operator=(MoveFields&&) { return *this; } diff --git a/test/http/test_parser.hpp b/test/http/test_parser.hpp index c45570f8..0892bdcd 100644 --- a/test/http/test_parser.hpp +++ b/test/http/test_parser.hpp @@ -79,7 +79,7 @@ public: } void - on_field(field f, string_view, + on_field(field, string_view, string_view, error_code& ec) { got_on_field = true; diff --git a/test/http/write.cpp b/test/http/write.cpp index 5fe31a95..9df14ae8 100644 --- a/test/http/write.cpp +++ b/test/http/write.cpp @@ -678,7 +678,7 @@ public: isRequest, Body, Fields> const& m, error_code& ec, Decorator const& decorator = Decorator{}) { - serializer sr{m}; + serializer sr{m, decorator}; for(;;) { stream.nwrite = 0; @@ -700,7 +700,7 @@ public: error_code& ec, yield_context yield, Decorator const& decorator = Decorator{}) { - serializer sr{m}; + serializer sr{m, decorator}; for(;;) { stream.nwrite = 0; diff --git a/test/websocket/doc_snippets.cpp b/test/websocket/doc_snippets.cpp index 3d60e7fb..87733ec1 100644 --- a/test/websocket/doc_snippets.cpp +++ b/test/websocket/doc_snippets.cpp @@ -191,6 +191,7 @@ boost::asio::ip::tcp::socket sock{ios}; [](bool is_pong, ping_data const& payload) { // Do something with the payload + boost::ignore_unused(is_pong, payload); }); //]