diff --git a/core/collections_component.cxx b/core/collections_component.cxx index eb19d599..41d3f85f 100644 --- a/core/collections_component.cxx +++ b/core/collections_component.cxx @@ -430,7 +430,7 @@ collection_id_cache_entry_impl::refresh_collection_id( self->manager_.lock()->remove(req->scope_name_, req->collection_name_); auto queue = self->swap_queue(); queue->close(); - return queue->drain([ec](auto r) { + return queue->drain([ec](const auto& r) { r->try_callback({}, ec); }); } @@ -443,7 +443,7 @@ collection_id_cache_entry_impl::refresh_collection_id( res.collection_id); auto queue = self->swap_queue(); queue->close(); - return queue->drain([self](auto r) { + return queue->drain([self](const auto& r) { if (auto ec = self->assign_collection_id(r); ec) { CB_LOG_DEBUG("failed to set collection ID \"{}.{}\" on request (OP={}): {}", r->scope_name_, diff --git a/core/columnar/management_component.cxx b/core/columnar/management_component.cxx index c627e49c..24df4d1d 100644 --- a/core/columnar/management_component.cxx +++ b/core/columnar/management_component.cxx @@ -189,7 +189,7 @@ class management_component_impl "SELECT d.* FROM `System`.`Metadata`.`Database` AS d", options.timeout, }; - return execute(std::move(req), [cb = std::move(callback)](auto raw_res, auto err) { + return execute(std::move(req), [cb = std::move(callback)](const auto& raw_res, auto err) { if (err) { cb({}, std::move(err)); return; @@ -216,7 +216,7 @@ class management_component_impl if (options.ignore_if_exists) { req.statement += " IF NOT EXISTS"; } - return execute(std::move(req), [cb = std::move(callback)](auto /*raw_res*/, auto err) { + return execute(std::move(req), [cb = std::move(callback)](const auto& /*raw_res*/, auto err) { cb(std::move(err)); }); } @@ -231,7 +231,7 @@ class management_component_impl if (options.ignore_if_not_exists) { req.statement += " IF EXISTS"; } - return execute(std::move(req), [cb = std::move(callback)](auto /*raw_res*/, auto err) { + return execute(std::move(req), [cb = std::move(callback)](const auto& /*raw_res*/, auto err) { cb(std::move(err)); }); } diff --git a/core/columnar/query_component.cxx b/core/columnar/query_component.cxx index 2780b49b..7d463625 100644 --- a/core/columnar/query_component.cxx +++ b/core/columnar/query_component.cxx @@ -111,7 +111,7 @@ class pending_query_operation } auto streamer = std::make_shared(self->io_, resp.body(), "/results/^"); return streamer->start( - [self, streamer, resp = std::move(resp)](auto metadata_header, auto ec) mutable { + [self, streamer, resp = std::move(resp)](const auto& metadata_header, auto ec) mutable { if (ec) { self->invoke_callback({}, { maybe_convert_error_code(ec) }); return; diff --git a/core/impl/analytics_index_manager.cxx b/core/impl/analytics_index_manager.cxx index 26ed4747..334918de 100644 --- a/core/impl/analytics_index_manager.cxx +++ b/core/impl/analytics_index_manager.cxx @@ -159,7 +159,7 @@ class analytics_index_manager_impl {}, options.timeout, }, - [dataverse_name, handler = std::move(handler)](auto resp) { + [dataverse_name, handler = std::move(handler)](const auto& resp) { CB_LOG_DEBUG( "Dataverse create for {} error code = {}", dataverse_name, resp.ctx.ec.value()); handler(core::impl::make_error(resp.ctx)); @@ -177,7 +177,7 @@ class analytics_index_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) { + [handler = std::move(handler)](const auto& resp) { handler(core::impl::make_error(resp.ctx)); }); } @@ -197,7 +197,7 @@ class analytics_index_manager_impl options.timeout, options.ignore_if_exists, }, - [handler = std::move(handler)](auto resp) { + [handler = std::move(handler)](const auto& resp) { handler(core::impl::make_error(resp.ctx)); }); } @@ -214,7 +214,7 @@ class analytics_index_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) { + [handler = std::move(handler)](const auto& resp) { handler(core::impl::make_error(resp.ctx)); }); } @@ -262,7 +262,7 @@ class analytics_index_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) { + [handler = std::move(handler)](const auto& resp) { handler(core::impl::make_error(resp.ctx)); }); } @@ -281,7 +281,7 @@ class analytics_index_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) { + [handler = std::move(handler)](const auto& resp) { handler(core::impl::make_error(resp.ctx)); }); } @@ -324,7 +324,7 @@ class analytics_index_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) { + [handler = std::move(handler)](const auto& resp) { handler(core::impl::make_error(resp.ctx)); }); } @@ -339,7 +339,7 @@ class analytics_index_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) { + [handler = std::move(handler)](const auto& resp) { handler(core::impl::make_error(resp.ctx)); }); } @@ -386,7 +386,7 @@ class analytics_index_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) { + [handler = std::move(handler)](const auto& resp) { handler(core::impl::make_error(resp.ctx)); }); @@ -398,7 +398,7 @@ class analytics_index_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) { + [handler = std::move(handler)](const auto& resp) { handler(core::impl::make_error(resp.ctx)); }); @@ -410,7 +410,7 @@ class analytics_index_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) { + [handler = std::move(handler)](const auto& resp) { handler(core::impl::make_error(resp.ctx)); }); } @@ -429,7 +429,7 @@ class analytics_index_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) { + [handler = std::move(handler)](const auto& resp) { handler(core::impl::make_error(resp.ctx)); }); @@ -441,7 +441,7 @@ class analytics_index_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) { + [handler = std::move(handler)](const auto& resp) { handler(core::impl::make_error(resp.ctx)); }); @@ -453,7 +453,7 @@ class analytics_index_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) { + [handler = std::move(handler)](const auto& resp) { handler(core::impl::make_error(resp.ctx)); }); } @@ -471,7 +471,7 @@ class analytics_index_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) { + [handler = std::move(handler)](const auto& resp) { handler(core::impl::make_error(resp.ctx)); }); } diff --git a/core/impl/bucket.cxx b/core/impl/bucket.cxx index 7ef7f478..bc644684 100644 --- a/core/impl/bucket.cxx +++ b/core/impl/bucket.cxx @@ -59,7 +59,7 @@ class bucket_impl : public std::enable_shared_from_this name_, core::impl::to_core_service_types(options.service_types), options.timeout, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler({}, core::impl::build_result(resp)); }); } diff --git a/core/impl/bucket_manager.cxx b/core/impl/bucket_manager.cxx index db5e33f6..a218cf1c 100644 --- a/core/impl/bucket_manager.cxx +++ b/core/impl/bucket_manager.cxx @@ -269,7 +269,7 @@ class bucket_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx), map_bucket_settings(resp.bucket)); }); } @@ -282,7 +282,7 @@ class bucket_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx), map_all_bucket_settings(resp.buckets)); }); } @@ -297,7 +297,7 @@ class bucket_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx)); }); } @@ -312,7 +312,7 @@ class bucket_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx)); }); } @@ -327,7 +327,7 @@ class bucket_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx)); }); } @@ -342,7 +342,7 @@ class bucket_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx)); }); } diff --git a/core/impl/cluster.cxx b/core/impl/cluster.cxx index 0aee380d..5a64d55a 100644 --- a/core/impl/cluster.cxx +++ b/core/impl/cluster.cxx @@ -291,7 +291,7 @@ class cluster_impl : public std::enable_shared_from_this })); return; } - impl->transactions_ = txns; + impl->transactions_ = std::move(txns); handler(ec, couchbase::cluster(std::move(impl))); }); }); @@ -323,16 +323,17 @@ class cluster_impl : public std::enable_shared_from_this {}, core::impl::to_core_service_types(options.service_types), options.timeout, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler({}, core::impl::build_result(resp)); }); }; void diagnostics(const diagnostics_options::built& options, diagnostics_handler&& handler) const { - return core_.diagnostics(options.report_id, [handler = std::move(handler)](auto resp) mutable { - return handler({}, core::impl::build_result(resp)); - }); + return core_.diagnostics(options.report_id, + [handler = std::move(handler)](const auto& resp) mutable { + return handler({}, core::impl::build_result(resp)); + }); } void search(std::string index_name, @@ -342,7 +343,7 @@ class cluster_impl : public std::enable_shared_from_this { return core_.execute( core::impl::build_search_request(std::move(index_name), std::move(request), options, {}, {}), - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx), search_result{ internal_search_result{ resp } }); }); diff --git a/core/impl/collection.cxx b/core/impl/collection.cxx index 9e8a2253..212570e3 100644 --- a/core/impl/collection.cxx +++ b/core/impl/collection.cxx @@ -211,7 +211,7 @@ class collection_impl : public std::enable_shared_from_this options.timeout, { options.retry_strategy }, }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(std::move(resp.ctx)), result{ resp.cas }); }); } @@ -1390,7 +1390,7 @@ collection::scan(const couchbase::scan_type& scan_type, const couchbase::scan_op { auto barrier = std::make_shared>>(); auto future = barrier->get_future(); - scan(scan_type, options, [barrier](auto err, auto result) { + scan(scan_type, options, [barrier](const auto& err, auto result) { barrier->set_value({ err, std::move(result) }); }); return future; diff --git a/core/impl/collection_manager.cxx b/core/impl/collection_manager.cxx index 6b7b5df9..bffffee2 100644 --- a/core/impl/collection_manager.cxx +++ b/core/impl/collection_manager.cxx @@ -101,7 +101,7 @@ class collection_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx)); }); } @@ -122,7 +122,7 @@ class collection_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx)); }); } @@ -143,7 +143,7 @@ class collection_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx)); }); } @@ -173,7 +173,7 @@ class collection_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx)); }); } @@ -189,7 +189,7 @@ class collection_manager_impl {}, options.timeout, }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx)); }); } diff --git a/core/impl/query_index_manager.cxx b/core/impl/query_index_manager.cxx index b7e320e2..d91a2680 100644 --- a/core/impl/query_index_manager.cxx +++ b/core/impl/query_index_manager.cxx @@ -232,7 +232,7 @@ class query_index_manager_impl : public std::enable_shared_from_this>>>(); auto future = barrier->get_future(); - get_all_indexes(bucket_name, options, [barrier](auto err, auto resp) mutable { + get_all_indexes(bucket_name, options, [barrier](auto err, const auto& resp) mutable { barrier->set_value({ std::move(err), resp }); }); return future; @@ -563,7 +563,7 @@ collection_query_index_manager::get_all_indexes(const get_all_query_indexes_opti auto barrier = std::make_shared>>>(); auto future = barrier->get_future(); - get_all_indexes(options, [barrier](auto err, auto resp) mutable { + get_all_indexes(options, [barrier](auto err, const auto& resp) mutable { barrier->set_value({ std::move(err), resp }); }); return future; diff --git a/core/impl/scan_result.cxx b/core/impl/scan_result.cxx index b2b7c38d..4b2e498b 100644 --- a/core/impl/scan_result.cxx +++ b/core/impl/scan_result.cxx @@ -97,7 +97,7 @@ scan_result::next() const -> std::future>>>(); - internal_->next([barrier](auto err, auto item) mutable { + internal_->next([barrier](const auto& err, const auto& item) mutable { barrier->set_value({ err, item }); }); return barrier->get_future(); diff --git a/core/impl/search_index_manager.cxx b/core/impl/search_index_manager.cxx index f4e3fe1b..cc0a50f4 100644 --- a/core/impl/search_index_manager.cxx +++ b/core/impl/search_index_manager.cxx @@ -150,7 +150,7 @@ class search_index_manager_impl core_.execute( core::operations::management::search_index_get_request{ std::move(index_name), bucket_name_, scope_name_, {}, options.timeout }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx), map_search_index(resp.index)); }); } @@ -161,7 +161,7 @@ class search_index_manager_impl core_.execute( core::operations::management::search_index_get_all_request{ bucket_name_, scope_name_, {}, options.timeout }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx), map_all_search_indexes(resp.indexes)); }); } @@ -173,7 +173,7 @@ class search_index_manager_impl core_.execute( core::operations::management::search_index_upsert_request{ map_search_index(search_index), bucket_name_, scope_name_, {}, options.timeout }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx)); }); } @@ -185,7 +185,7 @@ class search_index_manager_impl core_.execute( core::operations::management::search_index_drop_request{ std::move(index_name), bucket_name_, scope_name_, {}, options.timeout }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx)); }); } @@ -197,7 +197,7 @@ class search_index_manager_impl core_.execute( core::operations::management::search_index_get_documents_count_request{ std::move(index_name), bucket_name_, scope_name_, {}, options.timeout }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx), resp.count); }); } @@ -209,7 +209,7 @@ class search_index_manager_impl core_.execute( core::operations::management::search_index_control_ingest_request{ std::move(index_name), true, bucket_name_, scope_name_, {}, options.timeout }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx)); }); } @@ -221,7 +221,7 @@ class search_index_manager_impl core_.execute( core::operations::management::search_index_control_ingest_request{ std::move(index_name), false, bucket_name_, scope_name_, {}, options.timeout }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx)); }); } @@ -233,7 +233,7 @@ class search_index_manager_impl core_.execute( core::operations::management::search_index_control_query_request{ std::move(index_name), true, bucket_name_, scope_name_, {}, options.timeout }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx)); }); } @@ -245,7 +245,7 @@ class search_index_manager_impl core_.execute( core::operations::management::search_index_control_query_request{ std::move(index_name), false, bucket_name_, scope_name_, {}, options.timeout }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx)); }); } @@ -257,7 +257,7 @@ class search_index_manager_impl core_.execute( core::operations::management::search_index_control_plan_freeze_request{ std::move(index_name), true, bucket_name_, scope_name_, {}, options.timeout }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx)); }); } @@ -269,7 +269,7 @@ class search_index_manager_impl core_.execute( core::operations::management::search_index_control_plan_freeze_request{ std::move(index_name), false, bucket_name_, scope_name_, {}, options.timeout }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx)); }); } @@ -286,7 +286,7 @@ class search_index_manager_impl scope_name_, {}, options.timeout }, - [handler = std::move(handler)](auto resp) mutable { + [handler = std::move(handler)](const auto& resp) mutable { return handler(core::impl::make_error(resp.ctx), convert_analysis(resp.analysis)); }); } diff --git a/core/io/mcbp_session.cxx b/core/io/mcbp_session.cxx index a38172cc..cc0e8aa2 100644 --- a/core/io/mcbp_session.cxx +++ b/core/io/mcbp_session.cxx @@ -1089,8 +1089,7 @@ class mcbp_session_impl } state_ = diag::endpoint_state::connecting; if (stream_->is_open()) { - std::string old_id = stream_->id(); - return stream_->close([self = shared_from_this(), old_id](std::error_code) { + return stream_->close([self = shared_from_this(), old_id = stream_->id()](std::error_code) { CB_LOG_DEBUG(R"({} reopened socket connection "{}" -> "{}", host="{}", port={})", self->log_prefix_, old_id, diff --git a/core/logger/custom_rotating_file_sink.cxx b/core/logger/custom_rotating_file_sink.cxx index db91e0a8..c7e8cf6e 100644 --- a/core/logger/custom_rotating_file_sink.cxx +++ b/core/logger/custom_rotating_file_sink.cxx @@ -24,6 +24,7 @@ #include "core/platform/dirutils.h" +#include #include #include #include @@ -49,9 +50,7 @@ find_first_logfile_id(const std::string& basename) -> unsigned long if (index != std::string::npos) { try { const unsigned long value = std::stoul(file.substr(index + 1)); - if (value > id) { - id = value; - } + id = std::max(value, id); } catch (const std::invalid_argument&) { continue; /* ignore */ } catch (const std::out_of_range&) { diff --git a/core/logger/logger.cxx b/core/logger/logger.cxx index 4c1546b2..72e97905 100644 --- a/core/logger/logger.cxx +++ b/core/logger/logger.cxx @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -436,9 +437,7 @@ get_lowest_log_level() -> level auto lowest = spdlog::level::off; // Apply the function to each registered spdlog::logger except protocol logger spdlog::apply_all([&lowest](const std::shared_ptr& l) { - if (auto level = l->level(); level < lowest) { - lowest = level; - } + lowest = std::min(l->level(), lowest); }); return translate_level(lowest); } diff --git a/core/platform/base64.cc b/core/platform/base64.cc index 468fcdb7..09dcf540 100644 --- a/core/platform/base64.cc +++ b/core/platform/base64.cc @@ -182,7 +182,7 @@ encode(gsl::span blob, bool pretty_print) -> std::string if (pretty_print) { // In pretty-print mode we insert a newline after adding // 16 chunks (four characters). - result.reserve(chunks * 4 + chunks / 16); + result.reserve((chunks * 4) + (chunks / 16)); } else { result.reserve(chunks * 4); } diff --git a/core/platform/random.cc b/core/platform/random.cc index 5961df3d..5ee9d1a5 100644 --- a/core/platform/random.cc +++ b/core/platform/random.cc @@ -82,6 +82,8 @@ class RandomGeneratorProvider #ifdef WIN32 return CryptGenRandom(handle, (DWORD)size, static_cast(dest)); #else + // TODO(CXXCBC-549) + // NOLINTNEXTLINE(clang-analyzer-unix.BlockInCriticalSection) return static_cast(read(handle, dest, size)) == size; #endif } diff --git a/core/row_streamer.cxx b/core/row_streamer.cxx index ed0e6927..d0d428fd 100644 --- a/core/row_streamer.cxx +++ b/core/row_streamer.cxx @@ -162,7 +162,7 @@ class row_streamer_impl : public std::enable_shared_from_this feeding_ = true; - body_.next([self = shared_from_this()](auto data, auto ec) mutable { + body_.next([self = shared_from_this()](const auto& data, auto ec) mutable { if (ec) { self->received_all_data_ = true; auto signal = row_stream_end_signal{ ec }; diff --git a/core/sasl/scram-sha/stringutils.cc b/core/sasl/scram-sha/stringutils.cc index 7b469e85..58dcae15 100644 --- a/core/sasl/scram-sha/stringutils.cc +++ b/core/sasl/scram-sha/stringutils.cc @@ -44,7 +44,7 @@ namespace couchbase::core::sasl::mechanism::scram * - Tagging characters [StringPrep, C.9] */ auto -sasl_prep(const std::string& string) -> const std::string& +sasl_prep(const std::string& string) -> std::string { for (const auto& c : string) { if ((static_cast(c) & 0x80U) != 0) { diff --git a/core/sasl/scram-sha/stringutils.h b/core/sasl/scram-sha/stringutils.h index 4ab20fe4..8e0402d4 100644 --- a/core/sasl/scram-sha/stringutils.h +++ b/core/sasl/scram-sha/stringutils.h @@ -32,8 +32,8 @@ namespace couchbase::core::sasl::mechanism::scram * @return a sasl_prep'd string * @throws std::runtime_error if we encounter a multibyte character */ -const std::string& -sasl_prep(const std::string& string); +auto +sasl_prep(const std::string& string) -> std::string; /** * According to https://www.ietf.org/rfc/rfc5802.txt all occurrences @@ -42,7 +42,7 @@ sasl_prep(const std::string& string); * @param username the username to encode * @return the escaped string */ -std::string -encode_username(const std::string& username); +auto +encode_username(const std::string& username) -> std::string; } // namespace couchbase::core::sasl::mechanism::scram diff --git a/core/transactions/attempt_context_impl.cxx b/core/transactions/attempt_context_impl.cxx index d3f4eb2f..f33a300d 100644 --- a/core/transactions/attempt_context_impl.cxx +++ b/core/transactions/attempt_context_impl.cxx @@ -2975,7 +2975,7 @@ attempt_context_impl::do_get(const core::document_id& id, allow_replica, resolving_missing_atr_entry = std::move(resolving_missing_atr_entry), cb = std::move(cb)](std::optional ec, - std::optional err_message, + const std::optional& err_message, std::optional doc) mutable { if (!ec && !doc) { // it just isn't there. @@ -3101,20 +3101,21 @@ template void execute_lookup(attempt_context_impl* ctx, LookupInRequest& req, Callback&& cb) { - ctx->overall()->cluster_ref().execute(req, [ctx, cb = std::forward(cb)](auto resp) { - auto ec = error_class_from_response(resp); - if (ec) { - CB_ATTEMPT_CTX_LOG_TRACE(ctx, "get_doc got error {} : {}", resp.ctx.ec().message(), *ec); - switch (*ec) { - case FAIL_PATH_NOT_FOUND: - return cb(ec, resp.ctx.ec().message(), transaction_get_result::create_from(resp)); - default: - return cb(ec, resp.ctx.ec().message(), std::nullopt); + ctx->overall()->cluster_ref().execute( + req, [ctx, cb = std::forward(cb)](const auto& resp) { + auto ec = error_class_from_response(resp); + if (ec) { + CB_ATTEMPT_CTX_LOG_TRACE(ctx, "get_doc got error {} : {}", resp.ctx.ec().message(), *ec); + switch (*ec) { + case FAIL_PATH_NOT_FOUND: + return cb(ec, resp.ctx.ec().message(), transaction_get_result::create_from(resp)); + default: + return cb(ec, resp.ctx.ec().message(), std::nullopt); + } + } else { + return cb({}, {}, transaction_get_result::create_from(resp)); } - } else { - return cb({}, {}, transaction_get_result::create_from(resp)); - } - }); + }); } } // namespace @@ -3161,7 +3162,7 @@ attempt_context_impl::get_doc(const core::document_id& id, template void attempt_context_impl::create_staged_insert_error_handler(const core::document_id& id, - codec::encoded_value content, + const codec::encoded_value& content, std::uint64_t cas, Delay&& delay, const std::string& op_id, diff --git a/core/transactions/attempt_context_impl.hxx b/core/transactions/attempt_context_impl.hxx index fdf9a6f2..b3c5d358 100644 --- a/core/transactions/attempt_context_impl.hxx +++ b/core/transactions/attempt_context_impl.hxx @@ -463,8 +463,8 @@ private: template void create_staged_insert_error_handler(const core::document_id& id, - codec::encoded_value content, - uint64_t cas, + const codec::encoded_value& content, + std::uint64_t cas, Delay&& delay, const std::string& op_id, Handler&& cb, diff --git a/core/transactions/staged_mutation.cxx b/core/transactions/staged_mutation.cxx index 5edb20d2..df89b47d 100644 --- a/core/transactions/staged_mutation.cxx +++ b/core/transactions/staged_mutation.cxx @@ -568,7 +568,7 @@ staged_mutation_queue::commit_doc(const std::shared_ptr& c res, item, [ambiguity_resolution_mode, cas_zero_mode, handler = std::move(handler)]( - auto e) mutable { + const auto& e) mutable { if (e) { return handler(e, ambiguity_resolution_mode, cas_zero_mode); } @@ -610,7 +610,7 @@ staged_mutation_queue::commit_doc(const std::shared_ptr& c res, item, [ambiguity_resolution_mode, cas_zero_mode, handler = std::move(handler)]( - auto e) mutable { + const auto& e) mutable { if (e) { return handler(e, ambiguity_resolution_mode, cas_zero_mode); } diff --git a/core/transactions/transactions.cxx b/core/transactions/transactions.cxx index 5fc3c7ca..f45eed3a 100644 --- a/core/transactions/transactions.cxx +++ b/core/transactions/transactions.cxx @@ -99,7 +99,7 @@ transactions::create(core::cluster cluster, { auto barrier = std::make_shared>>>(); - create(std::move(cluster), config, [barrier](auto ec, auto txns) mutable { + create(std::move(cluster), config, [barrier](auto ec, const auto& txns) mutable { barrier->set_value({ ec, txns }); }); return barrier->get_future(); @@ -171,7 +171,7 @@ wrap_public_api_run(transactions& txns, std::size_t max_attempts, Handler&& fn) -> ::couchbase::transactions::transaction_result { - return wrap_run(txns, config, max_attempts, [fn = std::forward(fn)](auto ctx) { + return wrap_run(txns, config, max_attempts, [fn = std::forward(fn)](const auto& ctx) { const couchbase::error err = fn(ctx); if (err && err.ec() != errc::transaction_op::transaction_op_failed) { if (err.ec().category() == core::impl::transaction_op_category()) {