Fix unused parameter warnings and missing includes:

fix #127

* Added beast::detail::ignore_unused based on boost::ignore_unused
* Added -Wextra compilation flag when building with gcc
* Fixed all unused parameter warnings with ignore_unused
* Fixed all missing includes when building each .hpp separately
This commit is contained in:
Andrew Whatson
2016-10-13 12:32:01 +10:00
committed by Vinnie Falco
parent 0a1c24eb9f
commit ed23fd5811
17 changed files with 47 additions and 9 deletions

View File

@@ -20,7 +20,7 @@ else()
find_package(Threads)
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wpedantic")
"${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wpedantic")
endif()
if (APPLE AND NOT DEFINED ENV{OPENSSL_ROOT_DIR})

View File

@@ -11,6 +11,8 @@
#include "file_body.hpp"
#include "mime_type.hpp"
#include <beast/http.hpp>
#include <beast/core/placeholders.hpp>
#include <beast/core/streambuf.hpp>
#include <boost/asio.hpp>
#include <cstdint>
@@ -19,6 +21,7 @@
#include <iostream>
#include <memory>
#include <mutex>
#include <thread>
#include <utility>
#include <iostream>

View File

@@ -8,6 +8,7 @@
#ifndef BEAST_TEST_STRING_STREAM_HPP
#define BEAST_TEST_STRING_STREAM_HPP
#include <beast/core/async_completion.hpp>
#include <beast/core/bind_handler.hpp>
#include <beast/core/error.hpp>
#include <boost/asio/buffer.hpp>

View File

@@ -20,6 +20,19 @@ struct make_void
template<class... Ts>
using void_t = typename make_void<Ts...>::type;
template<class... Ts>
inline
void
ignore_unused(Ts const& ...)
{
}
template<class... Ts>
inline
void
ignore_unused()
{}
} // detail
} // beast

View File

@@ -8,6 +8,7 @@
#ifndef BEAST_IMPL_BASIC_STREAMBUF_IPP
#define BEAST_IMPL_BASIC_STREAMBUF_IPP
#include <beast/core/detail/type_traits.hpp>
#include <beast/core/detail/write_dynabuf.hpp>
#include <boost/assert.hpp>
#include <algorithm>
@@ -786,6 +787,7 @@ void
basic_streambuf<Allocator>::
copy_assign(basic_streambuf const& other, std::false_type)
{
beast::detail::ignore_unused(other);
}
template<class Allocator>

View File

@@ -9,6 +9,7 @@
#define BEAST_HTTP_BASIC_DYNABUF_BODY_HPP
#include <beast/http/body_type.hpp>
#include <beast/core/detail/type_traits.hpp>
#include <boost/asio/buffer.hpp>
namespace beast {
@@ -73,6 +74,7 @@ private:
void
init(error_code& ec) noexcept
{
beast::detail::ignore_unused(ec);
}
std::uint64_t

View File

@@ -9,6 +9,7 @@
#define BEAST_HTTP_EMPTY_BODY_HPP
#include <beast/http/body_type.hpp>
#include <beast/core/detail/type_traits.hpp>
#include <boost/asio/buffer.hpp>
#include <memory>
#include <string>
@@ -39,11 +40,13 @@ private:
explicit
writer(message<isRequest, empty_body, Headers> const& m) noexcept
{
beast::detail::ignore_unused(m);
}
void
init(error_code& ec) noexcept
{
beast::detail::ignore_unused(ec);
}
std::uint64_t

View File

@@ -12,6 +12,7 @@
#include <beast/http/concepts.hpp>
#include <beast/http/rfc7230.hpp>
#include <beast/core/detail/ci_char_traits.hpp>
#include <beast/core/detail/type_traits.hpp>
#include <boost/assert.hpp>
#include <boost/optional.hpp>
#include <stdexcept>
@@ -61,6 +62,7 @@ void
prepare_options(prepare_info& pi,
message<isRequest, Body, Headers>& msg)
{
beast::detail::ignore_unused(pi, msg);
}
template<bool isRequest, class Body, class Headers>
@@ -69,6 +71,7 @@ prepare_option(prepare_info& pi,
message<isRequest, Body, Headers>& msg,
connection value)
{
beast::detail::ignore_unused(msg);
pi.connection_value = value;
}
@@ -106,6 +109,7 @@ prepare_content_length(prepare_info& pi,
message<isRequest, Body, Headers> const& msg,
std::false_type)
{
beast::detail::ignore_unused(msg);
pi.content_length = boost::none;
}

View File

@@ -12,6 +12,7 @@
#include <beast/http/headers_parser_v1.hpp>
#include <beast/http/message.hpp>
#include <beast/core/error.hpp>
#include <beast/core/detail/type_traits.hpp>
#include <boost/assert.hpp>
#include <boost/optional.hpp>
#include <functional>
@@ -231,13 +232,13 @@ private:
m_.reason = std::move(this->reason_);
}
void on_request(error_code& ec)
void on_request(error_code&)
{
on_request_or_response(
std::integral_constant<bool, isRequest>{});
}
void on_response(error_code& ec)
void on_response(error_code&)
{
on_request_or_response(
std::integral_constant<bool, isRequest>{});
@@ -256,7 +257,7 @@ private:
}
void
on_headers(std::uint64_t, error_code& ec)
on_headers(std::uint64_t, error_code&)
{
flush();
m_.version = 10 * this->http_major() + this->http_minor();

View File

@@ -9,6 +9,7 @@
#define BEAST_HTTP_STRING_BODY_HPP
#include <beast/http/body_type.hpp>
#include <beast/core/detail/type_traits.hpp>
#include <boost/asio/buffer.hpp>
#include <memory>
#include <string>
@@ -73,6 +74,7 @@ private:
void
init(error_code& ec) noexcept
{
beast::detail::ignore_unused(ec);
}
std::uint64_t

View File

@@ -11,6 +11,7 @@
#include <beast/core/detail/base64.hpp>
#include <beast/core/detail/sha1.hpp>
#include <boost/utility/string_ref.hpp>
#include <array>
#include <cstdint>
#include <string>
#include <type_traits>

View File

@@ -14,6 +14,7 @@
#include <beast/http/read.hpp>
#include <beast/core/handler_alloc.hpp>
#include <beast/core/prepare_buffers.hpp>
#include <beast/core/detail/type_traits.hpp>
#include <boost/assert.hpp>
#include <memory>
#include <type_traits>
@@ -117,6 +118,7 @@ stream<NextLayer>::accept_op<Handler>::
operator()(error_code const& ec,
std::size_t bytes_transferred, bool again)
{
beast::detail::ignore_unused(bytes_transferred);
auto& d = *d_;
d.cont = d.cont || again;
while(! ec && d.state != 99)

View File

@@ -10,6 +10,7 @@
#include <beast/core/write_dynabuf.hpp>
#include <beast/http/detail/basic_parser_v1.hpp>
#include <beast/http/detail/rfc7230.hpp>
#include <cstdint>
#include <random>
#include <string>

View File

@@ -795,7 +795,7 @@ private:
bool
on_request(unsigned method, std::string const& url,
int major, int minor, bool keep_alive, bool upgrade,
int major, int minor, bool /*keep_alive*/, bool /*upgrade*/,
std::true_type)
{
m_.method = detail::method_to_string(method);
@@ -826,6 +826,7 @@ private:
int major, int minor, bool keep_alive, bool upgrade,
std::true_type)
{
beast::detail::ignore_unused(keep_alive, upgrade);
m_.status = status;
m_.reason = reason;
m_.version = major * 10 + minor;

View File

@@ -64,7 +64,7 @@ public:
template<class ConstBufferSequence>
std::size_t
write_some(
ConstBufferSequence const& buffers, error_code& ec)
ConstBufferSequence const& buffers, error_code&)
{
auto const n = buffer_size(buffers);
using boost::asio::buffer_size;
@@ -112,6 +112,7 @@ public:
void
init(error_code& ec) noexcept
{
beast::detail::ignore_unused(ec);
}
template<class WriteFunction>

View File

@@ -490,7 +490,7 @@ public:
}
}
void testClose(endpoint_type const& ep, yield_context do_yield)
void testClose(endpoint_type const& ep, yield_context)
{
{
// payload length 1

View File

@@ -8,6 +8,7 @@
#ifndef BEAST_WEBSOCKET_SYNC_ECHO_PEER_H_INCLUDED
#define BEAST_WEBSOCKET_SYNC_ECHO_PEER_H_INCLUDED
#include <beast/core/placeholders.hpp>
#include <beast/core/streambuf.hpp>
#include <beast/websocket.hpp>
#include <boost/optional.hpp>
@@ -36,7 +37,7 @@ private:
std::thread thread_;
public:
sync_echo_server(bool server, endpoint_type ep)
sync_echo_server(bool /*server*/, endpoint_type ep)
: sock_(ios_)
, acceptor_(ios_)
{