Clear error codes idiomatically

This commit is contained in:
Vinnie Falco
2019-01-20 09:50:43 -08:00
parent 9ea70bfbe5
commit 944b5dcda7
29 changed files with 118 additions and 112 deletions

View File

@ -1,3 +1,9 @@
Version 206
* Clear error codes idiomatically
--------------------------------------------------------------------------------
Version 205 Version 205
* Doc work * Doc work

View File

@ -154,7 +154,7 @@ detect_ssl(
{ {
// This is a fast way to indicate success // This is a fast way to indicate success
// without retrieving the default category. // without retrieving the default category.
ec.assign(0, ec.category()); ec = {};
return result; return result;
} }

View File

@ -1094,7 +1094,7 @@ read_and_print_body(
p.get().body().size = sizeof(buf); p.get().body().size = sizeof(buf);
read(stream, buffer, p, ec); read(stream, buffer, p, ec);
if(ec == error::need_buffer) if(ec == error::need_buffer)
ec.assign(0, ec.category()); ec = {};
if(ec) if(ec)
return; return;
os.write(buf, sizeof(buf) - p.get().body().size); os.write(buf, sizeof(buf) - p.get().body().size);
@ -1201,7 +1201,7 @@ print_chunked_body(
else if(ec != error::end_of_chunk) else if(ec != error::end_of_chunk)
return; return;
else else
ec.assign(0, ec.category()); ec = {};
// We got a whole chunk, print the extensions: // We got a whole chunk, print the extensions:
for(auto const& extension : ce) for(auto const& extension : ce)

View File

@ -191,7 +191,7 @@ public:
{ {
// Rationale: // Rationale:
// http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error // http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error
ec.assign(0, ec.category()); ec = {};
} }
if(ec) if(ec)
return fail(ec, "shutdown"); return fail(ec, "shutdown");

View File

@ -113,7 +113,7 @@ do_session(
{ {
// Rationale: // Rationale:
// http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error // http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error
ec.assign(0, ec.category()); ec = {};
} }
if(ec) if(ec)
return fail(ec, "shutdown"); return fail(ec, "shutdown");

View File

@ -111,7 +111,7 @@ int main(int argc, char** argv)
{ {
// Rationale: // Rationale:
// http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error // http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error
ec.assign(0, ec.category()); ec = {};
} }
if(ec) if(ec)
throw beast::system_error{ec}; throw beast::system_error{ec};

View File

@ -80,7 +80,7 @@ struct basic_dynamic_body
init(boost::optional< init(boost::optional<
std::uint64_t> const&, error_code& ec) std::uint64_t> const&, error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
template<class ConstBufferSequence> template<class ConstBufferSequence>
@ -112,7 +112,7 @@ struct basic_dynamic_body
void void
finish(error_code& ec) finish(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
}; };
#endif #endif
@ -142,13 +142,13 @@ struct basic_dynamic_body
void void
init(error_code& ec) init(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
boost::optional<std::pair<const_buffers_type, bool>> boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec) get(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
return {{body_.data(), false}}; return {{body_.data(), false}};
} }
}; };

View File

@ -319,7 +319,7 @@ init(error_code& ec)
// to indicate no error. // to indicate no error.
// //
// We don't do anything fancy so set "no error" // We don't do anything fancy so set "no error"
ec.assign(0, ec.category()); ec = {};
} }
// This function is called repeatedly by the serializer to // This function is called repeatedly by the serializer to
@ -349,7 +349,7 @@ get(error_code& ec) ->
// into the library to get the generic category because // into the library to get the generic category because
// that saves us a possibly expensive atomic operation. // that saves us a possibly expensive atomic operation.
// //
ec.assign(0, ec.category()); ec = {};
return boost::none; return boost::none;
} }
@ -373,7 +373,7 @@ get(error_code& ec) ->
// we set this bool to `false` so we will not be called // we set this bool to `false` so we will not be called
// again. // again.
// //
ec.assign(0, ec.category()); ec = {};
return {{ return {{
const_buffers_type{buf_, nread}, // buffer to return. const_buffers_type{buf_, nread}, // buffer to return.
remain_ > 0 // `true` if there are more buffers. remain_ > 0 // `true` if there are more buffers.
@ -474,7 +474,7 @@ init(
// to indicate no error. // to indicate no error.
// //
// We don't do anything fancy so set "no error" // We don't do anything fancy so set "no error"
ec.assign(0, ec.category()); ec = {};
} }
// This will get called one or more times with body buffers // This will get called one or more times with body buffers
@ -505,7 +505,7 @@ put(ConstBufferSequence const& buffers, error_code& ec)
// Indicate success // Indicate success
// This is required by the error_code specification // This is required by the error_code specification
ec.assign(0, ec.category()); ec = {};
return nwritten; return nwritten;
} }
@ -519,7 +519,7 @@ finish(error_code& ec)
{ {
// This has to be cleared before returning, to // This has to be cleared before returning, to
// indicate no error. The specification requires it. // indicate no error. The specification requires it.
ec.assign(0, ec.category()); ec = {};
} }
//] //]

View File

@ -113,7 +113,7 @@ struct buffer_body
void void
init(boost::optional<std::uint64_t> const&, error_code& ec) init(boost::optional<std::uint64_t> const&, error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
template<class ConstBufferSequence> template<class ConstBufferSequence>
@ -135,7 +135,7 @@ struct buffer_body
body_.data) + bytes_transferred; body_.data) + bytes_transferred;
body_.size -= bytes_transferred; body_.size -= bytes_transferred;
if(bytes_transferred == buffer_size(buffers)) if(bytes_transferred == buffer_size(buffers))
ec.assign(0, ec.category()); ec = {};
else else
ec = error::need_buffer; ec = error::need_buffer;
return bytes_transferred; return bytes_transferred;
@ -144,7 +144,7 @@ struct buffer_body
void void
finish(error_code& ec) finish(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
}; };
#endif #endif
@ -175,7 +175,7 @@ struct buffer_body
void void
init(error_code& ec) init(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
boost::optional< boost::optional<
@ -191,13 +191,13 @@ struct buffer_body
} }
else else
{ {
ec.assign(0, ec.category()); ec = {};
} }
return boost::none; return boost::none;
} }
if(body_.data) if(body_.data)
{ {
ec.assign(0, ec.category()); ec = {};
toggle_ = true; toggle_ = true;
return {{const_buffers_type{ return {{const_buffers_type{
body_.data, body_.size}, body_.more}}; body_.data, body_.size}, body_.more}};
@ -205,7 +205,7 @@ struct buffer_body
if(body_.more) if(body_.more)
ec = error::need_buffer; ec = error::need_buffer;
else else
ec.assign(0, ec.category()); ec = {};
return boost::none; return boost::none;
} }
}; };

View File

@ -191,14 +191,14 @@ struct basic_parser_base
{ {
if(it == last) if(it == last)
{ {
ec.assign(0, ec.category()); ec = {};
return nullptr; return nullptr;
} }
if(*it == '\r') if(*it == '\r')
{ {
if(++it == last) if(++it == last)
{ {
ec.assign(0, ec.category()); ec = {};
return nullptr; return nullptr;
} }
if(*it != '\n') if(*it != '\n')
@ -206,7 +206,7 @@ struct basic_parser_base
ec = error::bad_line_ending; ec = error::bad_line_ending;
return nullptr; return nullptr;
} }
ec.assign(0, ec.category()); ec = {};
return ++it; return ++it;
} }
// VFALCO Should we handle the legacy case // VFALCO Should we handle the legacy case

View File

@ -70,7 +70,7 @@ struct empty_body
void void
init(boost::optional<std::uint64_t> const&, error_code& ec) init(boost::optional<std::uint64_t> const&, error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
template<class ConstBufferSequence> template<class ConstBufferSequence>
@ -85,7 +85,7 @@ struct empty_body
void void
finish(error_code& ec) finish(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
}; };
#endif #endif
@ -111,13 +111,13 @@ struct empty_body
void void
init(error_code& ec) init(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
boost::optional<std::pair<const_buffers_type, bool>> boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec) get(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
return boost::none; return boost::none;
} }
}; };

View File

@ -100,7 +100,7 @@ put(ConstBufferSequence const& buffers,
auto const last = net::buffer_sequence_end(buffers); auto const last = net::buffer_sequence_end(buffers);
if(p == last) if(p == last)
{ {
ec.assign(0, ec.category()); ec = {};
return 0; return 0;
} }
if(std::next(p) == last) if(std::next(p) == last)
@ -136,7 +136,7 @@ put(net::const_buffer const& buffer,
auto n = buffer.size(); auto n = buffer.size();
auto const p0 = p; auto const p0 = p;
auto const p1 = p0 + n; auto const p1 = p0 + n;
ec.assign(0, ec.category()); ec = {};
loop: loop:
switch(state_) switch(state_)
{ {
@ -255,7 +255,7 @@ loop:
break; break;
case state::complete: case state::complete:
ec.assign(0, ec.category()); ec = {};
goto done; goto done;
} }
if(p < p1 && ! is_done() && eager()) if(p < p1 && ! is_done() && eager())
@ -286,7 +286,7 @@ put_eof(error_code& ec)
ec = error::partial_message; ec = error::partial_message;
return; return;
} }
ec.assign(0, ec.category()); ec = {};
return; return;
} }
impl().on_finish_impl(ec); impl().on_finish_impl(ec);
@ -841,7 +841,7 @@ do_field(field f,
continue; continue;
} }
} }
ec.assign(0, ec.category()); ec = {};
return; return;
} }
@ -870,7 +870,7 @@ do_field(field f,
return; return;
} }
ec.assign(0, ec.category()); ec = {};
len_ = v; len_ = v;
f_ |= flagContentLength; f_ |= flagContentLength;
return; return;
@ -893,7 +893,7 @@ do_field(field f,
return; return;
} }
ec.assign(0, ec.category()); ec = {};
auto const v = token_list{value}; auto const v = token_list{value};
auto const p = std::find_if(v.begin(), v.end(), auto const p = std::find_if(v.begin(), v.end(),
[&](typename token_list::value_type const& s) [&](typename token_list::value_type const& s)
@ -912,12 +912,12 @@ do_field(field f,
// Upgrade // Upgrade
if(f == field::upgrade) if(f == field::upgrade)
{ {
ec.assign(0, ec.category()); ec = {};
f_ |= flagUpgrade; f_ |= flagUpgrade;
return; return;
} }
ec.assign(0, ec.category()); ec = {};
} }
} // http } // http

View File

@ -387,7 +387,7 @@ do_parse(FwdIt it, FwdIt last, error_code& ec)
loop: loop:
if(it == last) if(it == last)
{ {
ec.assign(0, ec.category()); ec = {};
return it; return it;
} }
// BWS // BWS

View File

@ -142,7 +142,7 @@ struct basic_file_body<file_win32>
beast::detail::clamp(body_.last_ - pos_)); beast::detail::clamp(body_.last_ - pos_));
if(n == 0) if(n == 0)
{ {
ec.assign(0, ec.category()); ec = {};
return boost::none; return boost::none;
} }
auto const nread = body_.file_.read(buf_, n, ec); auto const nread = body_.file_.read(buf_, n, ec);
@ -150,7 +150,7 @@ struct basic_file_body<file_win32>
return boost::none; return boost::none;
BOOST_ASSERT(nread != 0); BOOST_ASSERT(nread != 0);
pos_ += nread; pos_ += nread;
ec.assign(0, ec.category()); ec = {};
return {{ return {{
{buf_, nread}, // buffer to return. {buf_, nread}, // buffer to return.
pos_ < body_.last_}}; // `true` if there are more buffers. pos_ < body_.last_}}; // `true` if there are more buffers.
@ -179,7 +179,7 @@ struct basic_file_body<file_win32>
// VFALCO We could reserve space in the file // VFALCO We could reserve space in the file
boost::ignore_unused(content_length); boost::ignore_unused(content_length);
BOOST_ASSERT(body_.file_.is_open()); BOOST_ASSERT(body_.file_.is_open());
ec.assign(0, ec.category()); ec = {};
} }
template<class ConstBufferSequence> template<class ConstBufferSequence>
@ -195,14 +195,14 @@ struct basic_file_body<file_win32>
if(ec) if(ec)
return nwritten; return nwritten;
} }
ec.assign(0, ec.category()); ec = {};
return nwritten; return nwritten;
} }
void void
finish(error_code& ec) finish(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
}; };
@ -496,7 +496,7 @@ write_some(
BOOST_ASSERT(w.pos_ <= w.body_.last_); BOOST_ASSERT(w.pos_ <= w.body_.last_);
if(w.pos_ < w.body_.last_) if(w.pos_ < w.body_.last_)
{ {
ec.assign(0, ec.category()); ec = {};
} }
else else
{ {

View File

@ -327,7 +327,7 @@ write_some_impl(
sr.consume(f.bytes_transferred); sr.consume(f.bytes_transferred);
return f.bytes_transferred; return f.bytes_transferred;
} }
ec.assign(0, ec.category()); ec = {};
return 0; return 0;
} }
@ -475,7 +475,7 @@ write_header(
} }
else else
{ {
ec.assign(0, ec.category()); ec = {};
} }
return bytes_transferred; return bytes_transferred;
} }
@ -764,7 +764,7 @@ public:
operator()(error_code& ec, operator()(error_code& ec,
ConstBufferSequence const& buffers) const ConstBufferSequence const& buffers) const
{ {
ec.assign(0, ec.category()); ec = {};
if(os_.fail()) if(os_.fail())
return; return;
std::size_t bytes_transferred = 0; std::size_t bytes_transferred = 0;

View File

@ -347,7 +347,7 @@ private:
m_.method(method); m_.method(method);
else else
m_.method_string(method_str); m_.method_string(method_str);
ec.assign(0, ec.category()); ec = {};
} }
catch(std::bad_alloc const&) catch(std::bad_alloc const&)
{ {
@ -368,7 +368,7 @@ private:
try try
{ {
m_.reason(reason); m_.reason(reason);
ec.assign(0, ec.category()); ec = {};
} }
catch(std::bad_alloc const&) catch(std::bad_alloc const&)
{ {
@ -386,7 +386,7 @@ private:
try try
{ {
m_.insert(name, name_string, value); m_.insert(name, name_string, value);
ec.assign(0, ec.category()); ec = {};
} }
catch(std::bad_alloc const&) catch(std::bad_alloc const&)
{ {
@ -397,7 +397,7 @@ private:
void void
on_header_impl(error_code& ec) on_header_impl(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
void void
@ -426,7 +426,7 @@ private:
{ {
if(cb_h_) if(cb_h_)
return cb_h_(size, extensions, ec); return cb_h_(size, extensions, ec);
ec.assign(0, ec.category()); ec = {};
} }
std::size_t std::size_t

View File

@ -87,7 +87,7 @@ public:
ec = error::buffer_overflow; ec = error::buffer_overflow;
return; return;
} }
ec.assign(0, ec.category()); ec = {};
} }
template<class ConstBufferSequence> template<class ConstBufferSequence>
@ -104,7 +104,7 @@ public:
ec = error::buffer_overflow; ec = error::buffer_overflow;
return 0; return 0;
} }
ec.assign(0, ec.category()); ec = {};
buffer_copy(net::buffer( buffer_copy(net::buffer(
body_.data(), n), buffers); body_.data(), n), buffers);
body_ = value_type{ body_ = value_type{
@ -115,7 +115,7 @@ public:
void void
finish(error_code& ec) finish(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
}; };
#endif #endif
@ -145,13 +145,13 @@ public:
void void
init(error_code& ec) init(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
boost::optional<std::pair<const_buffers_type, bool>> boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec) get(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
return {{ return {{
{ body_.data(), { body_.data(),
body_.size() * sizeof(typename body_.size() * sizeof(typename

View File

@ -109,7 +109,7 @@ public:
return; return;
} }
} }
ec.assign(0, ec.category()); ec = {};
} }
template<class ConstBufferSequence> template<class ConstBufferSequence>
@ -130,7 +130,7 @@ public:
ec = error::buffer_overflow; ec = error::buffer_overflow;
return 0; return 0;
} }
ec.assign(0, ec.category()); ec = {};
CharT* dest = &body_[size]; CharT* dest = &body_[size];
for(auto b : beast::buffers_range_ref(buffers)) for(auto b : beast::buffers_range_ref(buffers))
{ {
@ -144,7 +144,7 @@ public:
void void
finish(error_code& ec) finish(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
}; };
#endif #endif
@ -174,13 +174,13 @@ public:
void void
init(error_code& ec) init(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
boost::optional<std::pair<const_buffers_type, bool>> boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec) get(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
return {{const_buffers_type{ return {{const_buffers_type{
body_.data(), body_.size()}, false}}; body_.data(), body_.size()}, false}};
} }

View File

@ -103,7 +103,7 @@ public:
return; return;
} }
} }
ec.assign(0, ec.category()); ec = {};
} }
template<class ConstBufferSequence> template<class ConstBufferSequence>
@ -124,7 +124,7 @@ public:
ec = error::buffer_overflow; ec = error::buffer_overflow;
return 0; return 0;
} }
ec.assign(0, ec.category()); ec = {};
return buffer_copy(net::buffer( return buffer_copy(net::buffer(
&body_[0] + len, n), buffers); &body_[0] + len, n), buffers);
} }
@ -132,7 +132,7 @@ public:
void void
finish(error_code& ec) finish(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
}; };
#endif #endif
@ -162,13 +162,13 @@ public:
void void
init(error_code& ec) init(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
boost::optional<std::pair<const_buffers_type, bool>> boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec) get(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
return {{const_buffers_type{ return {{const_buffers_type{
body_.data(), body_.size()}, false}}; body_.data(), body_.size()}, false}};
} }

View File

@ -259,7 +259,7 @@ read_close(
if(n == 0) if(n == 0)
{ {
cr = close_reason{}; cr = close_reason{};
ec.assign(0, ec.category()); ec = {};
return; return;
} }
if(n == 1) if(n == 1)
@ -298,7 +298,7 @@ read_close(
{ {
cr.reason = ""; cr.reason = "";
} }
ec.assign(0, ec.category()); ec = {};
} }
} // detail } // detail

View File

@ -3388,7 +3388,7 @@ private:
ec = net::error::operation_aborted; ec = net::error::operation_aborted;
return false; return false;
} }
ec.assign(0, ec.category()); ec = {};
return true; return true;
} }

View File

@ -1006,7 +1006,7 @@ doParams(z_params& zs, int level, Strategy strategy, error_code& ec)
// Flush the last buffer: // Flush the last buffer:
doWrite(zs, Flush::block, ec); doWrite(zs, Flush::block, ec);
if(ec == error::need_buffers && pending_ == 0) if(ec == error::need_buffers && pending_ == 0)
ec.assign(0, ec.category()); ec = {};
} }
if(level_ != level) if(level_ != level)
{ {

View File

@ -97,7 +97,7 @@ public:
p.put(buffer(s.data(), n), ec); p.put(buffer(s.data(), n), ec);
s.remove_prefix(used); s.remove_prefix(used);
if(ec == error::need_more) if(ec == error::need_more)
ec.assign(0, ec.category()); ec = {};
if(! BEAST_EXPECTS(! ec, ec.message())) if(! BEAST_EXPECTS(! ec, ec.message()))
continue; continue;
BEAST_EXPECT(! p.is_done()); BEAST_EXPECT(! p.is_done());
@ -258,7 +258,7 @@ public:
used = p.put(b.data(), ec); used = p.put(b.data(), ec);
b.consume(used); b.consume(used);
BEAST_EXPECT(ec == error::need_more); BEAST_EXPECT(ec == error::need_more);
ec.assign(0, ec.category()); ec = {};
BEAST_EXPECT(! p.is_done()); BEAST_EXPECT(! p.is_done());
ostream(b) << ostream(b) <<
"\r\n"; // final crlf to end message "\r\n"; // final crlf to end message
@ -302,7 +302,7 @@ public:
used = p.put(b.data(), ec); used = p.put(b.data(), ec);
BEAST_EXPECTS(ec == error::need_more, ec.message()); BEAST_EXPECTS(ec == error::need_more, ec.message());
b.consume(used); b.consume(used);
ec.assign(0, ec.category()); ec = {};
ostream(b) << ostream(b) <<
"User-Agent: test\r\n" "User-Agent: test\r\n"
"\r\n"; "\r\n";
@ -323,7 +323,7 @@ public:
BEAST_EXPECT(ec == error::need_more); BEAST_EXPECT(ec == error::need_more);
BEAST_EXPECT(! p.got_some()); BEAST_EXPECT(! p.got_some());
BEAST_EXPECT(used == 0); BEAST_EXPECT(used == 0);
ec.assign(0, ec.category()); ec = {};
used = p.put(buf("G"), ec); used = p.put(buf("G"), ec);
BEAST_EXPECT(ec == error::need_more); BEAST_EXPECT(ec == error::need_more);
BEAST_EXPECT(p.got_some()); BEAST_EXPECT(p.got_some());

View File

@ -66,7 +66,7 @@ public:
if(fc_) if(fc_)
fc_->fail(ec); fc_->fail(ec);
else else
ec.assign(0, ec.category()); ec = {};
} }
void void
@ -82,7 +82,7 @@ public:
if(fc_) if(fc_)
fc_->fail(ec); fc_->fail(ec);
else else
ec.assign(0, ec.category()); ec = {};
} }
void void
@ -93,7 +93,7 @@ public:
if(fc_) if(fc_)
fc_->fail(ec); fc_->fail(ec);
else else
ec.assign(0, ec.category()); ec = {};
fields[name.to_string()] = value.to_string(); fields[name.to_string()] = value.to_string();
} }
@ -104,7 +104,7 @@ public:
if(fc_) if(fc_)
fc_->fail(ec); fc_->fail(ec);
else else
ec.assign(0, ec.category()); ec = {};
} }
void void
@ -118,7 +118,7 @@ public:
if(fc_) if(fc_)
fc_->fail(ec); fc_->fail(ec);
else else
ec.assign(0, ec.category()); ec = {};
} }
std::size_t std::size_t
@ -129,7 +129,7 @@ public:
if(fc_) if(fc_)
fc_->fail(ec); fc_->fail(ec);
else else
ec.assign(0, ec.category()); ec = {};
return s.size(); return s.size();
} }
@ -143,7 +143,7 @@ public:
if(fc_) if(fc_)
fc_->fail(ec); fc_->fail(ec);
else else
ec.assign(0, ec.category()); ec = {};
} }
std::size_t std::size_t
@ -156,7 +156,7 @@ public:
if(fc_) if(fc_)
fc_->fail(ec); fc_->fail(ec);
else else
ec.assign(0, ec.category()); ec = {};
return s.size(); return s.size();
} }
@ -168,7 +168,7 @@ public:
if(fc_) if(fc_)
fc_->fail(ec); fc_->fail(ec);
else else
ec.assign(0, ec.category()); ec = {};
} }
}; };

View File

@ -60,13 +60,13 @@ public:
void void
init(error_code& ec) init(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
boost::optional<std::pair<const_buffers_type, bool>> boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec) get(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
return {{const_buffers_type{ return {{const_buffers_type{
body_.data(), body_.size()}, false}}; body_.data(), body_.size()}, false}};
} }
@ -105,13 +105,13 @@ public:
void void
init(error_code& ec) init(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
boost::optional<std::pair<const_buffers_type, bool>> boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec) get(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
body_.read = true; body_.read = true;
return get( return get(
std::integral_constant<bool, isSplit>{}, std::integral_constant<bool, isSplit>{},
@ -916,13 +916,13 @@ public:
void void
init(error_code& ec) init(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
boost::optional<std::pair<const_buffers_type, bool>> boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec) get(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
return {{const_buffers_type{"", 0}, false}}; return {{const_buffers_type{"", 0}, false}};
} }
}; };
@ -947,13 +947,13 @@ public:
void void
init(error_code& ec) init(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
boost::optional<std::pair<const_buffers_type, bool>> boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec) get(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
return {{const_buffers_type{"", 0}, false}}; return {{const_buffers_type{"", 0}, false}};
} }
}; };

View File

@ -164,7 +164,7 @@ public:
on_request_impl(verb, string_view, on_request_impl(verb, string_view,
string_view, int, error_code& ec) string_view, int, error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
void void
@ -172,20 +172,20 @@ public:
string_view, string_view,
int, error_code& ec) int, error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
void void
on_field_impl(field, on_field_impl(field,
string_view, string_view, error_code& ec) string_view, string_view, error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
void void
on_header_impl(error_code& ec) on_header_impl(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
void void
@ -193,13 +193,13 @@ public:
boost::optional<std::uint64_t> const&, boost::optional<std::uint64_t> const&,
error_code& ec) error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
std::size_t std::size_t
on_body_impl(string_view s, error_code& ec) on_body_impl(string_view s, error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
return s.size(); return s.size();
} }
@ -207,21 +207,21 @@ public:
on_chunk_header_impl(std::uint64_t, on_chunk_header_impl(std::uint64_t,
string_view, error_code& ec) string_view, error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
std::size_t std::size_t
on_chunk_body_impl(std::uint64_t, on_chunk_body_impl(std::uint64_t,
string_view s, error_code& ec) string_view s, error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
return s.size(); return s.size();
} }
void void
on_finish_impl(error_code& ec) on_finish_impl(error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
}; };

View File

@ -572,7 +572,7 @@ private:
// Transfer-Encoding, see if we can reserve the buffer. // Transfer-Encoding, see if we can reserve the buffer.
// //
// r_.reserve(content_length) // r_.reserve(content_length)
ec.assign(0, ec.category()); ec = {};
} }
bool bool
@ -625,7 +625,7 @@ private:
void void
on_body(void const*, std::size_t, error_code& ec) on_body(void const*, std::size_t, error_code& ec)
{ {
ec.assign(0, ec.category()); ec = {};
} }
void void

View File

@ -76,7 +76,7 @@ public:
init(error_code& ec) init(error_code& ec)
{ {
// The specification requires this to indicate "no error" // The specification requires this to indicate "no error"
ec.assign(0, ec.category()); ec = {};
} }
/** Returns the next buffer in the body. /** Returns the next buffer in the body.
@ -101,7 +101,7 @@ public:
get(error_code& ec) get(error_code& ec)
{ {
// The specification requires this to indicate "no error" // The specification requires this to indicate "no error"
ec.assign(0, ec.category()); ec = {};
return boost::none; // for exposition only return boost::none; // for exposition only
} }
@ -144,7 +144,7 @@ struct BodyReader
boost::ignore_unused(content_length); boost::ignore_unused(content_length);
// The specification requires this to indicate "no error" // The specification requires this to indicate "no error"
ec.assign(0, ec.category()); ec = {};
} }
/** Store buffers. /** Store buffers.

View File

@ -365,7 +365,7 @@ print_cxx14(message<isRequest, Body, Fields> const& m)
sr.next(ec, sr.next(ec,
[&sr](error_code& ec, auto const& buffer) [&sr](error_code& ec, auto const& buffer)
{ {
ec.assign(0, ec.category()); ec = {};
std::cout << buffers(buffer); std::cout << buffers(buffer);
sr.consume(net::buffer_size(buffer)); sr.consume(net::buffer_size(buffer));
}); });
@ -392,7 +392,7 @@ struct lambda
template<class ConstBufferSequence> template<class ConstBufferSequence>
void operator()(error_code& ec, ConstBufferSequence const& buffer) const void operator()(error_code& ec, ConstBufferSequence const& buffer) const
{ {
ec.assign(0, ec.category()); ec = {};
std::cout << buffers(buffer); std::cout << buffers(buffer);
sr.consume(net::buffer_size(buffer)); sr.consume(net::buffer_size(buffer));
} }
@ -433,7 +433,7 @@ split_print_cxx14(message<isRequest, Body, Fields> const& m)
sr.next(ec, sr.next(ec,
[&sr](error_code& ec, auto const& buffer) [&sr](error_code& ec, auto const& buffer)
{ {
ec.assign(0, ec.category()); ec = {};
std::cout << buffers(buffer); std::cout << buffers(buffer);
sr.consume(net::buffer_size(buffer)); sr.consume(net::buffer_size(buffer));
}); });
@ -447,7 +447,7 @@ split_print_cxx14(message<isRequest, Body, Fields> const& m)
sr.next(ec, sr.next(ec,
[&sr](error_code& ec, auto const& buffer) [&sr](error_code& ec, auto const& buffer)
{ {
ec.assign(0, ec.category()); ec = {};
std::cout << buffers(buffer); std::cout << buffers(buffer);
sr.consume(net::buffer_size(buffer)); sr.consume(net::buffer_size(buffer));
}); });