Use BOOST_FALLTHROUGH

fix #437
This commit is contained in:
Vinnie Falco
2017-06-08 05:54:47 -07:00
parent cff5be3837
commit 55358835c6
12 changed files with 43 additions and 31 deletions

View File

@@ -3,6 +3,7 @@ Version 51
* Fix operator<< for header
* Tidy up file_body
* Fix file_body::get() not setting the more flag correctly
* Use BOOST_FALLTHROUGH
API Changes:

View File

@@ -14,6 +14,7 @@
#include <beast/http/error.hpp>
#include <beast/http/rfc7230.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/config.hpp>
#include <algorithm>
#include <utility>
@@ -114,7 +115,7 @@ loop:
return 0;
}
state_ = state::header;
// [[fallthrough]]
BOOST_FALLTHROUGH;
case state::header:
parse_header(p, n, ec);
@@ -127,7 +128,7 @@ loop:
if(ec)
goto done;
state_ = state::body;
// [[fallthrough]]
BOOST_FALLTHROUGH;
case state::body:
parse_body(p, n, ec);
@@ -140,7 +141,7 @@ loop:
if(ec)
goto done;
state_ = state::body_to_eof;
// [[fallthrough]]
BOOST_FALLTHROUGH;
case state::body_to_eof:
parse_body_to_eof(p, n, ec);
@@ -153,7 +154,7 @@ loop:
if(ec)
goto done;
state_ = state::chunk_header;
// [[fallthrough]]
BOOST_FALLTHROUGH;
case state::chunk_header:
parse_chunk_header(p, n, ec);

View File

@@ -20,6 +20,7 @@
#include <boost/asio/handler_continuation_hook.hpp>
#include <boost/asio/handler_invoke_hook.hpp>
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/optional.hpp>
#include <boost/throw_exception.hpp>
@@ -139,7 +140,7 @@ operator()(error_code ec, std::size_t bytes_transferred)
if(! ec || ec != http::error::need_more)
goto do_upcall;
ec = {};
// [[fallthrough]]
BOOST_FALLTHROUGH;
do_read:
try
@@ -277,7 +278,7 @@ operator()(error_code ec)
bind_handler(std::move(*this), ec));
}
state_ = 2;
// [[fallthrough]]
BOOST_FALLTHROUGH;
do_read:
return async_read_some(

View File

@@ -11,6 +11,7 @@
#include <beast/http/error.hpp>
#include <beast/http/status.hpp>
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <ostream>
namespace beast {
@@ -63,7 +64,7 @@ get(error_code& ec, Visit&& visit)
if(m_.has_chunked())
goto go_init_c;
s_ = do_init;
// [[fallthrough]]
BOOST_FALLTHROUGH;
}
case do_init:
@@ -89,7 +90,7 @@ get(error_code& ec, Visit&& visit)
frd_->get(),
result->first};
s_ = do_header;
// [[fallthrough]]
BOOST_FALLTHROUGH;
}
case do_header:
@@ -110,7 +111,7 @@ get(error_code& ec, Visit&& visit)
if(ec)
return;
s_ = do_body + 1;
// [[fallthrough]]
BOOST_FALLTHROUGH;
case do_body + 1:
{
@@ -122,7 +123,7 @@ get(error_code& ec, Visit&& visit)
more_ = result->second;
v_ = cb1_t{result->first};
s_ = do_body + 2;
// [[fallthrough]]
BOOST_FALLTHROUGH;
}
case do_body + 2:
@@ -167,7 +168,7 @@ get(error_code& ec, Visit&& visit)
result->first,
detail::chunk_crlf()};
s_ = do_header_c;
// [[fallthrough]]
BOOST_FALLTHROUGH;
}
case do_header_c:
@@ -188,7 +189,7 @@ get(error_code& ec, Visit&& visit)
if(ec)
return;
s_ = do_body_c + 1;
// [[fallthrough]]
BOOST_FALLTHROUGH;
case do_body_c + 1:
{
@@ -213,7 +214,7 @@ get(error_code& ec, Visit&& visit)
result->first,
detail::chunk_crlf()};
s_ = do_body_c + 2;
// [[fallthrough]]
BOOST_FALLTHROUGH;
}
case do_body_c + 2:
@@ -235,7 +236,7 @@ get(error_code& ec, Visit&& visit)
}(),
detail::chunk_crlf()};
s_ = do_final_c + 1;
// [[fallthrough]]
BOOST_FALLTHROUGH;
case do_final_c + 1:
visit(ec, boost::get<ch2_t>(v_));

View File

@@ -8,6 +8,7 @@
#ifndef BEAST_HTTP_IMPL_STATUS_IPP
#define BEAST_HTTP_IMPL_STATUS_IPP
#include <boost/config.hpp>
#include <boost/throw_exception.hpp>
namespace beast {
@@ -24,7 +25,7 @@ int_to_status(int v)
case status::continue_:
case status::switching_protocols:
case status::processing:
// [[fallthrough]]
BOOST_FALLTHROUGH;
// 2xx
case status::ok:
@@ -37,7 +38,7 @@ int_to_status(int v)
case status::multi_status:
case status::already_reported:
case status::im_used:
// [[fallthrough]]
BOOST_FALLTHROUGH;
// 3xx
case status::multiple_choices:
@@ -48,7 +49,7 @@ int_to_status(int v)
case status::use_proxy:
case status::temporary_redirect:
case status::permanent_redirect:
// [[fallthrough]]
BOOST_FALLTHROUGH;
// 4xx
case status::bad_request:
@@ -80,7 +81,7 @@ int_to_status(int v)
case status::connection_closed_without_response:
case status::unavailable_for_legal_reasons:
case status::client_closed_request:
// [[fallthrough]]
BOOST_FALLTHROUGH;
// 5xx
case status::internal_server_error:

View File

@@ -8,6 +8,7 @@
#ifndef BEAST_HTTP_IMPL_VERB_IPP
#define BEAST_HTTP_IMPL_VERB_IPP
#include <boost/config.hpp>
#include <boost/throw_exception.hpp>
#include <stdexcept>
@@ -155,7 +156,7 @@ string_to_verb(string_view v)
return verb::connect;
if(eq(v, "PY"))
return verb::copy;
// [[fallthrough]]
BOOST_FALLTHROUGH;
default:
break;
@@ -216,7 +217,7 @@ string_to_verb(string_view v)
case 'O':
if(eq(v, "VE"))
return verb::move;
// [[fallthrough]]
BOOST_FALLTHROUGH;
default:
break;
@@ -260,7 +261,7 @@ string_to_verb(string_view v)
return verb::purge;
if(eq(v, "T"))
return verb::put;
// [[fallthrough]]
BOOST_FALLTHROUGH;
default:
break;

View File

@@ -18,6 +18,7 @@
#include <boost/asio/handler_continuation_hook.hpp>
#include <boost/asio/handler_invoke_hook.hpp>
#include <boost/asio/write.hpp>
#include <boost/config.hpp>
#include <boost/optional.hpp>
#include <boost/throw_exception.hpp>
#include <ostream>
@@ -317,7 +318,7 @@ operator()(error_code ec,
case 2:
state_ = 3;
// [[fallthrough]]
BOOST_FALLTHROUGH;
case 3:
{

View File

@@ -14,6 +14,7 @@
#include <boost/asio/handler_alloc_hook.hpp>
#include <boost/asio/handler_continuation_hook.hpp>
#include <boost/asio/handler_invoke_hook.hpp>
#include <boost/config.hpp>
#include <boost/throw_exception.hpp>
#include <memory>
@@ -153,7 +154,7 @@ operator()(error_code ec, bool again)
return;
}
d.ws.wr_block_ = &d;
// [[fallthrough]]
BOOST_FALLTHROUGH;
case 1:
// send close frame

View File

@@ -15,6 +15,7 @@
#include <boost/asio/handler_alloc_hook.hpp>
#include <boost/asio/handler_continuation_hook.hpp>
#include <boost/asio/handler_invoke_hook.hpp>
#include <boost/config.hpp>
#include <boost/throw_exception.hpp>
#include <memory>
@@ -152,7 +153,7 @@ operator()(error_code ec, bool again)
return;
}
d.ws.wr_block_ = &d;
// [[fallthrough]]
BOOST_FALLTHROUGH;
case 1:
// send ping frame

View File

@@ -18,6 +18,7 @@
#include <boost/asio/handler_continuation_hook.hpp>
#include <boost/asio/handler_invoke_hook.hpp>
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/optional.hpp>
#include <boost/throw_exception.hpp>
#include <limits>
@@ -522,7 +523,7 @@ operator()(error_code ec,
ec = boost::asio::error::operation_aborted;
goto upcall;
}
// [[fallthrough]]
BOOST_FALLTHROUGH;
//------------------------------------------------------------------

View File

@@ -21,6 +21,7 @@
#include <boost/asio/handler_continuation_hook.hpp>
#include <boost/asio/handler_invoke_hook.hpp>
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/throw_exception.hpp>
#include <algorithm>
#include <memory>
@@ -230,7 +231,7 @@ operator()(error_code ec,
case do_nomask_nofrag:
BOOST_ASSERT(! d.ws.wr_block_);
d.ws.wr_block_ = &d;
// [[fallthrough]]
BOOST_FALLTHROUGH;
case do_nomask_nofrag + 1:
{
@@ -253,7 +254,7 @@ operator()(error_code ec,
case do_nomask_frag:
BOOST_ASSERT(! d.ws.wr_block_);
d.ws.wr_block_ = &d;
// [[fallthrough]]
BOOST_FALLTHROUGH;
case do_nomask_frag + 1:
{
@@ -301,7 +302,7 @@ operator()(error_code ec,
case do_mask_nofrag:
BOOST_ASSERT(! d.ws.wr_block_);
d.ws.wr_block_ = &d;
// [[fallthrough]]
BOOST_FALLTHROUGH;
case do_mask_nofrag + 1:
{
@@ -353,7 +354,7 @@ operator()(error_code ec,
case do_mask_frag:
BOOST_ASSERT(! d.ws.wr_block_);
d.ws.wr_block_ = &d;
// [[fallthrough]]
BOOST_FALLTHROUGH;
case do_mask_frag + 1:
{
@@ -406,7 +407,7 @@ operator()(error_code ec,
case do_deflate:
BOOST_ASSERT(! d.ws.wr_block_);
d.ws.wr_block_ = &d;
// [[fallthrough]]
BOOST_FALLTHROUGH;
case do_deflate + 1:
{

View File

@@ -12,6 +12,7 @@
#include <beast/websocket/ssl.hpp>
#include <beast/websocket/stream.hpp>
#include <boost/asio/ssl.hpp>
#include <boost/config.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/optional.hpp>
#include <atomic>
@@ -234,7 +235,7 @@ private:
case 2:
if(ec)
return fail("async_handshake", ec);
// [[fallthrough]]
BOOST_FALLTHROUGH;
// WebSocket read
case 3: