diff --git a/CHANGELOG.md b/CHANGELOG.md index 75e03e2c13a..9a1c7bfebf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ ### Fixed * ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?) -* None. +* Fix some clang static analyzer warnings. None of them were actual bugs ([PR #6675](https://github.com/realm/realm-core/pull/6675)). ### Breaking changes * None. diff --git a/src/realm/bplustree.cpp b/src/realm/bplustree.cpp index 50bd30e603f..35d8178f534 100644 --- a/src/realm/bplustree.cpp +++ b/src/realm/bplustree.cpp @@ -742,9 +742,9 @@ void BPlusTreeBase::bptree_erase(size_t n, BPlusTreeNode::EraseFunc func) ref_type new_root_ref = node->clear_first_bp_node_ref(); node->destroy_deep(); - auto new_root = create_root_from_ref(new_root_ref); - - replace_root(std::move(new_root)); + if (auto new_root = create_root_from_ref(new_root_ref)) { + replace_root(std::move(new_root)); + } root_size = m_root->get_node_size(); } } @@ -757,7 +757,7 @@ std::unique_ptr BPlusTreeBase::create_root_from_ref(ref_type ref) if (reuse_root) { m_root->init_from_ref(ref); - return std::move(m_root); + return nullptr; } if (is_leaf) { diff --git a/src/realm/bplustree.hpp b/src/realm/bplustree.hpp index 8555d335b64..aa143b4201d 100644 --- a/src/realm/bplustree.hpp +++ b/src/realm/bplustree.hpp @@ -172,10 +172,10 @@ class BPlusTreeBase { void init_from_ref(ref_type ref) { - auto new_root = create_root_from_ref(ref); - new_root->bp_set_parent(m_parent, m_ndx_in_parent); - - m_root = std::move(new_root); + if (auto new_root = create_root_from_ref(ref)) { + new_root->bp_set_parent(m_parent, m_ndx_in_parent); + m_root = std::move(new_root); + } invalidate_leaf_cache(); m_size = m_root->get_tree_size(); @@ -187,9 +187,10 @@ class BPlusTreeBase { if (!ref) { return false; } - auto new_root = create_root_from_ref(ref); - new_root->bp_set_parent(m_parent, m_ndx_in_parent); - m_root = std::move(new_root); + if (auto new_root = create_root_from_ref(ref)) { + new_root->bp_set_parent(m_parent, m_ndx_in_parent); + m_root = std::move(new_root); + } invalidate_leaf_cache(); m_size = m_root->get_tree_size(); return true; @@ -374,6 +375,11 @@ class BPlusTree : public BPlusTreeBase { REALM_NOINLINE T get_uncached(size_t n) const { T value; +#ifdef __clang_analyzer__ + // Clang's static analyzer can't see that value will always be initialized + // inside bptree_access() + value = {}; +#endif auto func = [&value](BPlusTreeNode* node, size_t ndx) { LeafNode* leaf = static_cast(node); diff --git a/src/realm/object-store/c_api/realm.cpp b/src/realm/object-store/c_api/realm.cpp index edf1d5ad819..de887223d8e 100644 --- a/src/realm/object-store/c_api/realm.cpp +++ b/src/realm/object-store/c_api/realm.cpp @@ -305,7 +305,8 @@ RLM_API bool realm_remove_table(realm_t* realm, const char* table_name, bool* ta "Attempt to remove a table that is currently part of the schema"); } (*realm)->read_group().remove_table(table->get_key()); - *table_deleted = true; + if (table_deleted) + *table_deleted = true; } return true; }); diff --git a/src/realm/sync/CMakeLists.txt b/src/realm/sync/CMakeLists.txt index 17011aef965..872d24f2214 100644 --- a/src/realm/sync/CMakeLists.txt +++ b/src/realm/sync/CMakeLists.txt @@ -80,8 +80,10 @@ set(NOINST_HEADERS noinst/sync_metadata_schema.hpp ) -set(SYNC_HEADERS ${IMPL_INSTALL_HEADESR} +set(SYNC_HEADERS + ${IMPL_INSTALL_HEADESR} ${SYNC_INSTALL_HEADERS} + ${SYNC_NETWORK_INSTALL_HEADERS} ${NOINST_HEADERS}) add_library(Sync STATIC ${SYNC_SOURCES} ${SYNC_HEADERS}) diff --git a/src/realm/sync/network/network.hpp b/src/realm/sync/network/network.hpp index 16b352d764b..526dbd62e30 100644 --- a/src/realm/sync/network/network.hpp +++ b/src/realm/sync/network/network.hpp @@ -1998,7 +1998,7 @@ class Service::PostOper : public PostOperBase { public: PostOper(std::size_t size, Impl& service, H&& handler) : PostOperBase{size, service} - , m_handler{std::move(handler)} + , m_handler{std::forward(handler)} { } void recycle_and_execute() override final @@ -2256,7 +2256,7 @@ class Service::BasicStreamOps { char* begin = buffer; char* end = buffer + size; LendersReadOperPtr op = Service::alloc>(stream.lowest_layer().m_read_oper, stream, is_read_some, - begin, end, std::move(handler)); // Throws + begin, end, std::forward(handler)); // Throws stream.lowest_layer().m_desc.initiate_oper(std::move(op)); // Throws } @@ -2265,8 +2265,9 @@ class Service::BasicStreamOps { { const char* begin = data; const char* end = data + size; - LendersWriteOperPtr op = Service::alloc>( - stream.lowest_layer().m_write_oper, stream, is_write_some, begin, end, std::move(handler)); // Throws + LendersWriteOperPtr op = + Service::alloc>(stream.lowest_layer().m_write_oper, stream, is_write_some, begin, end, + std::forward(handler)); // Throws stream.lowest_layer().m_desc.initiate_oper(std::move(op)); // Throws } @@ -2278,7 +2279,7 @@ class Service::BasicStreamOps { char* end = buffer + size; LendersBufferedReadOperPtr op = Service::alloc>(stream.lowest_layer().m_read_oper, stream, begin, end, delim, rab, - std::move(handler)); // Throws + std::forward(handler)); // Throws stream.lowest_layer().m_desc.initiate_oper(std::move(op)); // Throws } }; @@ -2554,7 +2555,7 @@ class Service::BasicStreamOps::ReadOper : public ReadOperBase { public: ReadOper(std::size_t size, S& stream, bool is_read_some, char* begin, char* end, H&& handler) : ReadOperBase{size, stream, is_read_some, begin, end} - , m_handler{std::move(handler)} + , m_handler{std::forward(handler)} { } void recycle_and_execute() override final @@ -2584,7 +2585,7 @@ class Service::BasicStreamOps::WriteOper : public WriteOperBase { public: WriteOper(std::size_t size, S& stream, bool is_write_some, const char* begin, const char* end, H&& handler) : WriteOperBase{size, stream, is_write_some, begin, end} - , m_handler{std::move(handler)} + , m_handler{std::forward(handler)} { } void recycle_and_execute() override final @@ -2615,7 +2616,7 @@ class Service::BasicStreamOps::BufferedReadOper : public BufferedReadOperBase BufferedReadOper(std::size_t size, S& stream, char* begin, char* end, int delim, ReadAheadBuffer& rab, H&& handler) : BufferedReadOperBase{size, stream, begin, end, delim, rab} - , m_handler{std::move(handler)} + , m_handler{std::forward(handler)} { } void recycle_and_execute() override final @@ -2703,7 +2704,7 @@ template inline Service::PostOperBase* Service::post_oper_constr(void* addr, std::size_t size, Impl& service, void* cookie) { H& handler = *static_cast(cookie); - return new (addr) PostOper(size, service, std::move(handler)); // Throws + return new (addr) PostOper(size, service, std::forward(handler)); // Throws } inline bool Service::AsyncOper::in_use() const noexcept @@ -2769,10 +2770,8 @@ inline void Service::AsyncOper::do_recycle_and_execute(bool orphaned, H& handler // happens. For that reason, copying and moving of arguments must not // happen until we are in a scope (this scope) that catches and deals // correctly with such exceptions. - do_recycle_and_execute_helper(orphaned, was_recycled, std::move(handler), + do_recycle_and_execute_helper(orphaned, was_recycled, std::forward(handler), std::forward(args)...); // Throws - - // Removed catch to prevent truncating the stack trace on exception } template @@ -2805,7 +2804,7 @@ class Resolver::ResolveOper : public Service::ResolveOperBase { public: ResolveOper(std::size_t size, Resolver& r, Query q, H&& handler) : ResolveOperBase{size, r, std::move(q)} - , m_handler{std::move(handler)} + , m_handler{std::forward(handler)} { } void recycle_and_execute() override final @@ -2847,7 +2846,7 @@ template void Resolver::async_resolve(Query query, H&& handler) { Service::LendersResolveOperPtr op = Service::alloc>(m_resolve_oper, *this, std::move(query), - std::move(handler)); // Throws + std::forward(handler)); // Throws initiate_oper(std::move(op)); // Throws } @@ -3086,7 +3085,7 @@ class Socket::ConnectOper : public ConnectOperBase { public: ConnectOper(std::size_t size, Socket& sock, H&& handler) : ConnectOperBase{size, sock} - , m_handler{std::move(handler)} + , m_handler{std::forward(handler)} { } void recycle_and_execute() override final @@ -3214,7 +3213,8 @@ inline std::size_t Socket::write_some(const char* data, std::size_t size, std::e template inline void Socket::async_connect(const Endpoint& ep, H&& handler) { - LendersConnectOperPtr op = Service::alloc>(m_write_oper, *this, std::move(handler)); // Throws + LendersConnectOperPtr op = + Service::alloc>(m_write_oper, *this, std::forward(handler)); // Throws m_desc.initiate_oper(std::move(op), ep); // Throws } @@ -3222,42 +3222,42 @@ template inline void Socket::async_read(char* buffer, std::size_t size, H&& handler) { bool is_read_some = false; - StreamOps::async_read(*this, buffer, size, is_read_some, std::move(handler)); // Throws + StreamOps::async_read(*this, buffer, size, is_read_some, std::forward(handler)); // Throws } template inline void Socket::async_read(char* buffer, std::size_t size, ReadAheadBuffer& rab, H&& handler) { int delim = std::char_traits::eof(); - StreamOps::async_buffered_read(*this, buffer, size, delim, rab, std::move(handler)); // Throws + StreamOps::async_buffered_read(*this, buffer, size, delim, rab, std::forward(handler)); // Throws } template inline void Socket::async_read_until(char* buffer, std::size_t size, char delim, ReadAheadBuffer& rab, H&& handler) { int delim_2 = std::char_traits::to_int_type(delim); - StreamOps::async_buffered_read(*this, buffer, size, delim_2, rab, std::move(handler)); // Throws + StreamOps::async_buffered_read(*this, buffer, size, delim_2, rab, std::forward(handler)); // Throws } template inline void Socket::async_write(const char* data, std::size_t size, H&& handler) { bool is_write_some = false; - StreamOps::async_write(*this, data, size, is_write_some, std::move(handler)); // Throws + StreamOps::async_write(*this, data, size, is_write_some, std::forward(handler)); // Throws } template inline void Socket::async_read_some(char* buffer, std::size_t size, H&& handler) { bool is_read_some = true; - StreamOps::async_read(*this, buffer, size, is_read_some, std::move(handler)); // Throws + StreamOps::async_read(*this, buffer, size, is_read_some, std::forward(handler)); // Throws } template inline void Socket::async_write_some(const char* data, std::size_t size, H&& handler) { bool is_write_some = true; - StreamOps::async_write(*this, data, size, is_write_some, std::move(handler)); // Throws + StreamOps::async_write(*this, data, size, is_write_some, std::forward(handler)); // Throws } inline void Socket::shutdown(shutdown_type what) @@ -3394,7 +3394,7 @@ class Acceptor::AcceptOper : public AcceptOperBase { public: AcceptOper(std::size_t size, Acceptor& a, Socket& s, Endpoint* e, H&& handler) : AcceptOperBase{size, a, s, e} - , m_handler{std::move(handler)} + , m_handler{std::forward(handler)} { } void recycle_and_execute() override final @@ -3456,13 +3456,13 @@ template inline void Acceptor::async_accept(Socket& sock, H&& handler) { Endpoint* ep = nullptr; - async_accept(sock, ep, std::move(handler)); // Throws + async_accept(sock, ep, std::forward(handler)); // Throws } template inline void Acceptor::async_accept(Socket& sock, Endpoint& ep, H&& handler) { - async_accept(sock, &ep, std::move(handler)); // Throws + async_accept(sock, &ep, std::forward(handler)); // Throws } inline std::error_code Acceptor::accept(Socket& socket, Endpoint* ep, std::error_code& ec) @@ -3491,7 +3491,7 @@ inline void Acceptor::async_accept(Socket& sock, Endpoint* ep, H&& handler) if (REALM_UNLIKELY(sock.is_open())) throw util::runtime_error("Socket is already open"); LendersAcceptOperPtr op = Service::alloc>(m_read_oper, *this, sock, ep, - std::move(handler)); // Throws + std::forward(handler)); // Throws m_desc.initiate_oper(std::move(op)); // Throws } @@ -3502,7 +3502,7 @@ class DeadlineTimer::WaitOper : public Service::WaitOperBase { public: WaitOper(std::size_t size, DeadlineTimer& timer, clock::time_point expiration_time, H&& handler) : Service::WaitOperBase{size, timer, expiration_time} - , m_handler{std::move(handler)} + , m_handler{std::forward(handler)} { } void recycle_and_execute() override final @@ -3542,7 +3542,7 @@ inline void DeadlineTimer::async_wait(std::chrono::duration delay, H&& han throw util::overflow_error("Expiration time overflow"); clock::time_point expiration_time = now + delay; initiate_oper(Service::alloc>(m_wait_oper, *this, expiration_time, - std::move(handler))); // Throws + std::forward(handler))); // Throws } // ---------------- ReadAheadBuffer ---------------- diff --git a/src/realm/table.cpp b/src/realm/table.cpp index 9c5eff2639b..4db212cd2e8 100644 --- a/src/realm/table.cpp +++ b/src/realm/table.cpp @@ -560,6 +560,7 @@ void Table::remove_recursive(CascadeState& cascade_state) REALM_ASSERT(group); cascade_state.m_group = group; + std::vector> to_delete; do { cascade_state.send_notifications(); @@ -572,14 +573,15 @@ void Table::remove_recursive(CascadeState& cascade_state) } cascade_state.m_to_be_nullified.clear(); - auto to_delete = std::move(cascade_state.m_to_be_deleted); - for (auto obj : to_delete) { - auto table = group->get_table(obj.first); + to_delete.swap(cascade_state.m_to_be_deleted); + for (auto [table_key, obj_key] : to_delete) { + auto table = group->get_table(table_key); // This might add to the list of objects that should be deleted - REALM_ASSERT(!obj.second.is_unresolved()); - table->m_clusters.erase(obj.second, cascade_state); + REALM_ASSERT(!obj_key.is_unresolved()); + table->m_clusters.erase(obj_key, cascade_state); } nullify_links(cascade_state); + to_delete.clear(); } while (!cascade_state.m_to_be_deleted.empty() || !cascade_state.m_to_be_nullified.empty()); } @@ -1679,7 +1681,7 @@ void copy_list(ref_type sub_table_ref, Obj& obj, ColKey col, Allocato void Table::create_columns() { - size_t cnt; + size_t cnt = 0; auto get_column_cnt = [&cnt](const Cluster* cluster) { cnt = cluster->nb_columns(); return IteratorControl::Stop; diff --git a/src/realm/util/thread.hpp b/src/realm/util/thread.hpp index 9906e9c26f0..1e40b229120 100644 --- a/src/realm/util/thread.hpp +++ b/src/realm/util/thread.hpp @@ -557,6 +557,7 @@ inline void Mutex::unlock() noexcept #else int r = pthread_mutex_unlock(&m_impl); REALM_ASSERT(r == 0); + static_cast(r); #endif } @@ -780,6 +781,7 @@ inline void CondVar::notify() noexcept #else int r = pthread_cond_signal(&m_impl); REALM_ASSERT(r == 0); + static_cast(r); #endif } @@ -790,6 +792,7 @@ inline void CondVar::notify_all() noexcept #else int r = pthread_cond_broadcast(&m_impl); REALM_ASSERT(r == 0); + static_cast(r); #endif } diff --git a/src/realm/uuid.cpp b/src/realm/uuid.cpp index a347e597929..3de36c165da 100644 --- a/src/realm/uuid.cpp +++ b/src/realm/uuid.cpp @@ -45,7 +45,7 @@ bool is_hex_digit(unsigned char c) return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); } -char parse_xdigit(char ch) +uint8_t parse_xdigit(char ch) { if (ch >= '0' && ch <= '9') return ch - '0'; @@ -53,7 +53,7 @@ char parse_xdigit(char ch) return ch - 'a' + 10; if (ch >= 'A' && ch <= 'F') return ch - 'A' + 10; - return char(-1); + REALM_UNREACHABLE(); } } // anonymous namespace @@ -80,7 +80,6 @@ bool UUID::is_valid_string(StringData str) noexcept } UUID::UUID(StringData init) - : m_bytes{} { if (!is_valid_string(init)) { throw InvalidUUIDString{ diff --git a/test/object-store/util/test_utils.hpp b/test/object-store/util/test_utils.hpp index 38f3e8f1ef3..1792af48f0f 100644 --- a/test/object-store/util/test_utils.hpp +++ b/test/object-store/util/test_utils.hpp @@ -105,7 +105,7 @@ namespace _impl { template ExceptionMatcher make_exception_matcher(ErrorCodes::Error code, T&& matcher) { - return ExceptionMatcher(code, std::move(matcher)); + return ExceptionMatcher(code, std::forward(matcher)); } inline ExceptionMatcher make_exception_matcher(ErrorCodes::Error code, const char* msg) { diff --git a/test/test_sync.cpp b/test/test_sync.cpp index 074eb8f4b92..89f15b6a57c 100644 --- a/test/test_sync.cpp +++ b/test/test_sync.cpp @@ -1736,7 +1736,7 @@ class RequestWithContentLength { auto handler = [&](std::error_code ec, size_t nbytes) { this->read_completion_handler(ec, nbytes); }; - m_socket.async_read_until(m_buffer, m_buf_size, '\n', m_read_ahead_buffer, handler); + m_socket.async_read_until(m_buffer, m_buf_size, '\n', m_read_ahead_buffer, std::move(handler)); } void read_completion_handler(std::error_code ec, size_t nbytes) @@ -1755,7 +1755,7 @@ class RequestWithContentLength { auto handler = [&](std::error_code ec, size_t nbytes) { this->write_completion_handler(ec, nbytes); }; - m_socket.async_write(m_request.data(), m_request.size(), handler); + m_socket.async_write(m_request.data(), m_request.size(), std::move(handler)); } private: diff --git a/test/test_util_network.cpp b/test/test_util_network.cpp index e9291d1c375..d7d5c4456d2 100644 --- a/test/test_util_network.cpp +++ b/test/test_util_network.cpp @@ -530,7 +530,7 @@ TEST(Network_AsyncReadWriteLargeAmount) CHECK_NOT(ec); read_chunk(); }; - socket_1.async_read(buffer.get(), buffer_size, rab, handler); + socket_1.async_read(buffer.get(), buffer_size, rab, std::move(handler)); }; read_chunk(); service_1.run(); @@ -553,7 +553,7 @@ TEST(Network_AsyncReadWriteLargeAmount) write_chunk(i + 1); } }; - socket_2.async_write(chunk.get(), num_bytes_per_chunk, handler); + socket_2.async_write(chunk.get(), num_bytes_per_chunk, std::move(handler)); }; write_chunk(0); service_2.run(); @@ -616,13 +616,13 @@ TEST(Network_CancelAsyncAccept) if (ec == error::operation_aborted) accept_was_canceled = true; }; - acceptor.async_accept(socket, handler); + acceptor.async_accept(socket, std::move(handler)); acceptor.cancel(); service.run(); CHECK(accept_was_canceled); accept_was_canceled = false; - acceptor.async_accept(socket, handler); + acceptor.async_accept(socket, std::move(handler)); acceptor.close(); service.run(); CHECK(accept_was_canceled); @@ -665,7 +665,7 @@ TEST(Network_CancelAsyncReadWrite) if (!ec) was_accepted = true; }; - acceptor.async_accept(socket_1, accept_handler); + acceptor.async_accept(socket_1, std::move(accept_handler)); network::Socket socket_2{service}; socket_2.connect(acceptor.local_endpoint()); socket_2.set_option(network::SocketBase::no_delay(true)); @@ -679,7 +679,7 @@ TEST(Network_CancelAsyncReadWrite) if (ec == error::operation_aborted) write_was_canceled = true; }; - socket_2.async_write(data, size, write_handler); + socket_2.async_write(data, size, std::move(write_handler)); network::ReadAheadBuffer rab; char buffer[size]; bool read_was_canceled = false; @@ -687,7 +687,7 @@ TEST(Network_CancelAsyncReadWrite) if (ec == error::operation_aborted) read_was_canceled = true; }; - socket_2.async_read(buffer, size, rab, read_handler); + socket_2.async_read(buffer, size, rab, std::move(read_handler)); socket_2.close(); service.run(); CHECK(read_was_canceled); @@ -710,14 +710,14 @@ TEST(Network_CancelEmptyRead) if (ec == error::operation_aborted) write_was_canceled = true; }; - socket_2.async_write(data, size, write_handler); + socket_2.async_write(data, size, std::move(write_handler)); char buffer[size]; bool read_was_canceled = false; auto read_handler = [&](std::error_code ec, size_t) { if (ec == error::operation_aborted) read_was_canceled = true; }; - socket_2.async_read(buffer, 0, rab, read_handler); + socket_2.async_read(buffer, 0, rab, std::move(read_handler)); socket_2.close(); service.run(); CHECK(read_was_canceled); @@ -739,14 +739,14 @@ TEST(Network_CancelEmptyWrite) if (ec == error::operation_aborted) read_was_canceled = true; }; - socket_2.async_read(buffer, 1, rab, read_handler); + socket_2.async_read(buffer, 1, rab, std::move(read_handler)); char data[1] = {'a'}; bool write_was_canceled = false; auto write_handler = [&](std::error_code ec, size_t) { if (ec == error::operation_aborted) write_was_canceled = true; }; - socket_2.async_write(data, 0, write_handler); + socket_2.async_write(data, 0, std::move(write_handler)); socket_2.close(); service.run(); CHECK(read_was_canceled); @@ -789,12 +789,12 @@ TEST(Network_CancelReadByDestroy) } CHECK_EQUAL(error::operation_aborted, ec); }; - read_sockets[i]->async_read_until(input_buffers[i], 2, '\n', *read_ahead_buffers[i], read_handler); + read_sockets[i]->async_read_until(input_buffers[i], 2, '\n', *read_ahead_buffers[i], std::move(read_handler)); auto write_handler = [&](std::error_code ec, size_t) { CHECK_NOT(ec); }; int n = (i == num_connections / 2 ? 2 : 1); - write_sockets[i]->async_write(output_buffer, n, write_handler); + write_sockets[i]->async_write(output_buffer, n, std::move(write_handler)); } service.run(); } @@ -831,7 +831,7 @@ TEST(Network_AcceptorMixedAsyncSync) if (!ec) was_accepted = true; }; - acceptor.async_accept(socket, accept_handler); + acceptor.async_accept(socket, std::move(accept_handler)); service.run(); CHECK(was_accepted); CHECK_NOT(thread.join()); @@ -883,7 +883,7 @@ TEST(Network_SocketMixedAsyncSync) if (!ec) was_written = true; }; - socket.async_write(message, strlen(message), write_handler); + socket.async_write(message, strlen(message), std::move(write_handler)); service.run(); CHECK(was_written); @@ -930,7 +930,7 @@ TEST(Network_SocketMixedAsyncSync) CHECK(std::equal(buffer.get(), buffer.get() + size, message)); } }; - socket.async_read(buffer.get(), buffer_size, rab, read_handler); + socket.async_read(buffer.get(), buffer_size, rab, std::move(read_handler)); service.run(); CHECK_NOT(thread.join()); @@ -1469,7 +1469,7 @@ class async_server { handle_accept(ec); }; network::Endpoint endpoint; - m_acceptor.async_accept(m_socket, endpoint, handler); + m_acceptor.async_accept(m_socket, endpoint, std::move(handler)); m_service.run(); } @@ -1492,7 +1492,7 @@ class async_server { auto handler = [this](std::error_code handler_ec, size_t handler_n) { handle_read_header(handler_ec, handler_n); }; - m_socket.async_read_until(m_header_buffer, s_max_header_size, '\n', m_read_ahead_buffer, handler); + m_socket.async_read_until(m_header_buffer, s_max_header_size, '\n', m_read_ahead_buffer, std::move(handler)); } void handle_read_header(std::error_code ec, size_t n) @@ -1521,7 +1521,7 @@ class async_server { handle_read_body(handler_ec, handler_n); }; m_body_buffer.reset(new char[m_body_size]); - m_socket.async_read(m_body_buffer.get(), m_body_size, m_read_ahead_buffer, handler); + m_socket.async_read(m_body_buffer.get(), m_body_size, m_read_ahead_buffer, std::move(handler)); } void handle_read_body(std::error_code ec, size_t n) @@ -1537,7 +1537,7 @@ class async_server { auto handler = [this](std::error_code handler_ec, size_t) { handle_write_header(handler_ec); }; - m_socket.async_write(m_header_buffer, out.size(), handler); + m_socket.async_write(m_header_buffer, out.size(), std::move(handler)); } void handle_write_header(std::error_code ec) @@ -1547,7 +1547,7 @@ class async_server { auto handler = [this](std::error_code handler_ec, size_t) { handle_write_body(handler_ec); }; - m_socket.async_write(m_body_buffer.get(), m_body_size, handler); + m_socket.async_write(m_body_buffer.get(), m_body_size, std::move(handler)); } void handle_write_body(std::error_code ec) @@ -1557,7 +1557,7 @@ class async_server { auto handler = [this](std::error_code handler_ec, size_t) { handle_read_header_2(handler_ec); }; - m_socket.async_read_until(m_header_buffer, s_max_header_size, '\n', m_read_ahead_buffer, handler); + m_socket.async_read_until(m_header_buffer, s_max_header_size, '\n', m_read_ahead_buffer, std::move(handler)); } void handle_read_header_2(std::error_code ec) @@ -1596,7 +1596,7 @@ class async_client { auto handler = [this](std::error_code ec, size_t) { handle_write_header(ec); }; - m_socket.async_write(m_header_buffer, out.size(), handler); + m_socket.async_write(m_header_buffer, out.size(), std::move(handler)); m_service.run(); @@ -1621,7 +1621,7 @@ class async_client { auto handler = [this](std::error_code handler_ec, size_t) { handle_write_body(handler_ec); }; - m_socket.async_write(echo_body, sizeof echo_body, handler); + m_socket.async_write(echo_body, sizeof echo_body, std::move(handler)); } void handle_write_body(std::error_code ec) @@ -1631,7 +1631,7 @@ class async_client { auto handler = [this](std::error_code handler_ec, size_t handler_n) { handle_read_header(handler_ec, handler_n); }; - m_socket.async_read_until(m_header_buffer, s_max_header_size, '\n', m_read_ahead_buffer, handler); + m_socket.async_read_until(m_header_buffer, s_max_header_size, '\n', m_read_ahead_buffer, std::move(handler)); } void handle_read_header(std::error_code ec, size_t n) @@ -1660,7 +1660,7 @@ class async_client { handle_read_body(handler_ec, handler_n); }; m_body_buffer.reset(new char[m_body_size]); - m_socket.async_read(m_body_buffer.get(), m_body_size, m_read_ahead_buffer, handler); + m_socket.async_read(m_body_buffer.get(), m_body_size, m_read_ahead_buffer, std::move(handler)); } void handle_read_body(std::error_code ec, size_t n) @@ -1776,7 +1776,7 @@ TEST(Network_RepeatedCancelAndRestartRead) CHECK(!ec || ec == error::operation_aborted); initiate_read(); }; - socket_2.async_read(read_buffer, read_buffer_size, rab, handler); + socket_2.async_read(read_buffer, read_buffer_size, rab, std::move(handler)); }; initiate_read();