diff --git a/.clang-tidy b/.clang-tidy index 896fce86d..8b49aa806 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -4,8 +4,6 @@ # no tolerance for whitespace. Well done! # # We use clever YAML multiline-string syntax to work around this. -# -# TODO: hicpp-move-const-arg says I'm moving const refs, but looks wrong to me. Checks: > abseil-*, boost-*, @@ -146,7 +144,6 @@ Checks: > google-readability-avoid-underscore-in-googletest-name, google-readability-function-size, google-readability-namespace-comments, - google-runtime-int, google-runtime-operator, google-upgrade-googletest-case, hicpp-avoid-goto, @@ -156,14 +153,12 @@ Checks: > hicpp-function-size, hicpp-invalid-access-moved, hicpp-member-init, - hicpp-move-const-arg, hicpp-multiway-paths-covered, hicpp-new-delete-operators, hicpp-no-array-decay, hicpp-no-assembler, hicpp-no-malloc, hicpp-special-member-functions, - hicpp-static-assert, hicpp-undelegated-constructor, hicpp-use-auto, hicpp-use-emplace, @@ -172,5 +167,103 @@ Checks: > hicpp-use-noexcept, hicpp-use-nullptr, hicpp-use-override, - llvm-* + llvm-header-guard, + llvm-include-order, + llvm-namespace-comment, + llvm-prefer-isa-or-dyn-cast-in-conditionals, + llvm-prefer-register-over-unsigned, + llvm-twine-local, + misc-confusable-identifiers, + misc-const-correctness, + misc-definitions-in-headers, + misc-misleading-bidirectional, + misc-misleading-identifier, + misc-misplaced-const, + misc-new-delete-overloads, + misc-non-copyable-objects, + misc-non-private-member-variables-in-classes, + misc-redundant-expression, + misc-throw-by-value-catch-by-reference, + misc-unconventional-assign-operator, + misc-uniqueptr-reset-release, + misc-unused-alias-decls, + misc-unused-parameters, + misc-unused-using-decls, + misc-use-anonymous-namespace, + modernize-avoid-bind, + modernize-concat-nested-namespaces, + modernize-deprecated-headers, + modernize-deprecated-ios-base-aliases, + modernize-loop-convert, + modernize-macro-to-enum, + modernize-make-shared, + modernize-make-unique, + modernize-pass-by-value, + modernize-raw-string-literal, + modernize-redundant-void-arg, + modernize-replace-auto-ptr, + modernize-replace-disallow-copy-and-assign-macro, + modernize-replace-random-shuffle, + modernize-return-braced-init-list, + modernize-shrink-to-fit, + modernize-unary-static-assert, + modernize-use-auto, + modernize-use-bool-literals, + modernize-use-default-member-init, + modernize-use-emplace, + modernize-use-equals-default, + modernize-use-equals-delete, + modernize-use-nodiscard, + modernize-use-noexcept, + modernize-use-nullptr, + modernize-use-override, + modernize-use-transparent-functors, + modernize-use-uncaught-exceptions, + modernize-use-using, + performance-faster-string-find, + performance-for-range-copy, + performance-implicit-conversion-in-loop, + performance-inefficient-algorithm, + performance-inefficient-string-concatenation, + performance-inefficient-vector-operation, + performance-move-const-arg, + performance-move-constructor-init, + performance-no-automatic-move, + performance-no-int-to-ptr, + performance-trivially-destructible, + performance-type-promotion-in-math-fn, + performance-unnecessary-copy-initialization, + performance-unnecessary-value-param, + portability-restrict-system-includes, + portability-simd-intrinsics, + portability-std-allocator-const, + readability-avoid-const-params-in-decls, + readability-const-return-type, + readability-container-contains, + readability-container-data-pointer, + readability-container-size-empty, + readability-delete-null-pointer, + readability-function-size, + readability-identifier-naming, + readability-inconsistent-declaration-parameter-name, + readability-misplaced-array-index, + readability-non-const-parameter, + readability-redundant-access-specifiers, + readability-redundant-control-flow, + readability-redundant-declaration, + readability-redundant-function-ptr-dereference, + readability-redundant-member-init, + readability-redundant-preprocessor, + readability-redundant-smartptr-get, + readability-redundant-string-cstr, + readability-redundant-string-init, + readability-simplify-boolean-expr, + readability-simplify-subscript-expr, + readability-static-accessed-through-instance, + readability-static-definition-in-anonymous-namespace, + readability-string-compare, + readability-suspicious-call-argument, + readability-uniqueptr-delete-release, + readability-use-anyofallof, + zircon-temporary-objects diff --git a/include/pqxx/connection.hxx b/include/pqxx/connection.hxx index 4b5ef9251..1ebdb671d 100644 --- a/include/pqxx/connection.hxx +++ b/include/pqxx/connection.hxx @@ -101,7 +101,7 @@ concept ZKey_ZValues = std::ranges::input_range and requires(T t) { * * Ignores the `skip_init::nothing` flag. */ -void PQXX_COLD PQXX_LIBEXPORT skip_init_ssl(int flags) noexcept; +void PQXX_COLD PQXX_LIBEXPORT skip_init_ssl(int skips) noexcept; } // namespace pqxx::internal @@ -1093,7 +1093,8 @@ private: friend class internal::gate::connection_transaction; result exec(std::string_view, std::string_view = ""sv); result - PQXX_PRIVATE exec(std::shared_ptr, std::string_view = ""sv); + PQXX_PRIVATE exec( + std::shared_ptr const &, std::string_view = ""sv); void PQXX_PRIVATE register_transaction(transaction_base *); void PQXX_PRIVATE unregister_transaction(transaction_base *) noexcept; diff --git a/include/pqxx/except.hxx b/include/pqxx/except.hxx index 4e9f9a7c2..979380ae1 100644 --- a/include/pqxx/except.hxx +++ b/include/pqxx/except.hxx @@ -137,7 +137,7 @@ class PQXX_LIBEXPORT sql_error : public failure public: explicit sql_error( - std::string const &whatarg = "", std::string const &Q = "", + std::string whatarg = "", std::string const &Q = "", char const sqlstate[] = nullptr #if defined(PQXX_HAVE_SOURCE_LOCATION) , diff --git a/include/pqxx/result.hxx b/include/pqxx/result.hxx index f5f0198d8..f9df86167 100644 --- a/include/pqxx/result.hxx +++ b/include/pqxx/result.hxx @@ -325,8 +325,8 @@ private: friend class pqxx::internal::gate::result_creation; result( - std::shared_ptr rhs, - std::shared_ptr query, internal::encoding_group enc); + std::shared_ptr const &rhs, + std::shared_ptr const &query, internal::encoding_group enc); PQXX_PRIVATE void check_status(std::string_view desc = ""sv) const; diff --git a/src/blob.cxx b/src/blob.cxx index 9e16fdaa1..b8e2e0e29 100644 --- a/src/blob.cxx +++ b/src/blob.cxx @@ -25,7 +25,7 @@ constexpr int INV_WRITE{0x00020000}, INV_READ{0x00040000}; pqxx::internal::pq::PGconn * pqxx::blob::raw_conn(pqxx::connection *conn) noexcept { - pqxx::internal::gate::connection_largeobject gate{*conn}; + pqxx::internal::gate::connection_largeobject const gate{*conn}; return gate.raw_connection(); } @@ -39,7 +39,7 @@ pqxx::blob::raw_conn(pqxx::dbtransaction const &tx) noexcept std::string pqxx::blob::errmsg(connection const *conn) { - pqxx::internal::gate::const_connection_largeobject gate{*conn}; + pqxx::internal::gate::const_connection_largeobject const gate{*conn}; return gate.error_message(); } @@ -47,7 +47,7 @@ std::string pqxx::blob::errmsg(connection const *conn) pqxx::blob pqxx::blob::open_internal(dbtransaction &tx, oid id, int mode) { auto &conn{tx.conn()}; - int fd{lo_open(raw_conn(&conn), id, mode)}; + int const fd{lo_open(raw_conn(&conn), id, mode)}; if (fd == -1) throw pqxx::failure{internal::concat( "Could not open binary large object ", id, ": ", errmsg(&conn))}; @@ -57,7 +57,7 @@ pqxx::blob pqxx::blob::open_internal(dbtransaction &tx, oid id, int mode) pqxx::oid pqxx::blob::create(dbtransaction &tx, oid id) { - oid actual_id{lo_create(raw_conn(tx), id)}; + oid const actual_id{lo_create(raw_conn(tx), id)}; if (actual_id == 0) throw failure{internal::concat( "Could not create binary large object: ", errmsg(&tx.conn()))}; @@ -143,7 +143,7 @@ std::size_t pqxx::blob::raw_read(std::byte buf[], std::size_t size) throw range_error{ "Reads from a binary large object must be less than 2 GB at once."}; auto data{reinterpret_cast(buf)}; - int received{lo_read(raw_conn(m_conn), m_fd, data, size)}; + int const received{lo_read(raw_conn(m_conn), m_fd, data, size)}; if (received < 0) throw failure{ internal::concat("Could not read from binary large object: ", errmsg())}; @@ -169,7 +169,7 @@ void pqxx::blob::raw_write(std::byte const buf[], std::size_t size) throw range_error{ "Writes to a binary large object must be less than 2 GB at once."}; auto ptr{reinterpret_cast(buf)}; - int written{lo_write(raw_conn(m_conn), m_fd, ptr, size)}; + int const written{lo_write(raw_conn(m_conn), m_fd, ptr, size)}; if (written < 0) throw failure{ internal::concat("Write to binary large object failed: ", errmsg())}; @@ -190,7 +190,7 @@ std::int64_t pqxx::blob::tell() const { if (m_conn == nullptr) throw usage_error{"Attempt to tell() a closed binary large object."}; - std::int64_t offset{lo_tell64(raw_conn(m_conn), m_fd)}; + std::int64_t const offset{lo_tell64(raw_conn(m_conn), m_fd)}; if (offset < 0) throw failure{internal::concat( "Error reading binary large object position: ", errmsg())}; @@ -202,7 +202,8 @@ std::int64_t pqxx::blob::seek(std::int64_t offset, int whence) { if (m_conn == nullptr) throw usage_error{"Attempt to seek() a closed binary large object."}; - std::int64_t seek_result{lo_lseek64(raw_conn(m_conn), m_fd, offset, whence)}; + std::int64_t const seek_result{ + lo_lseek64(raw_conn(m_conn), m_fd, offset, whence)}; if (seek_result < 0) throw failure{internal::concat( "Error during seek on binary large object: ", errmsg())}; @@ -231,7 +232,7 @@ std::int64_t pqxx::blob::seek_end(std::int64_t offset) pqxx::oid pqxx::blob::from_buf( dbtransaction &tx, std::basic_string_view data, oid id) { - oid actual_id{create(tx, id)}; + oid const actual_id{create(tx, id)}; try { open_w(tx, actual_id).write(data); diff --git a/src/connection.cxx b/src/connection.cxx index 8ae284de5..29de7bdd8 100644 --- a/src/connection.cxx +++ b/src/connection.cxx @@ -93,7 +93,7 @@ void PQXX_COLD PQXX_LIBEXPORT pqxx::internal::skip_init_ssl(int skips) noexcept std::string PQXX_COLD pqxx::encrypt_password(char const user[], char const password[]) { - std::unique_ptr p{ + std::unique_ptr const p{ PQencryptPassword(password, user), pqxx::internal::pq::pqfreemem}; return {p.get()}; } @@ -219,7 +219,8 @@ pqxx::result pqxx::connection::make_result( internal::pq::PGresult *pgr, std::shared_ptr const &query, std::string_view desc) { - std::shared_ptr smart{pgr, internal::clear_result}; + std::shared_ptr const smart{ + pgr, internal::clear_result}; if (not smart) { if (is_open()) @@ -228,7 +229,7 @@ pqxx::result pqxx::connection::make_result( throw broken_connection{"Lost connection to the database server."}; } auto const enc{internal::enc_group(encoding_id())}; - auto const r{ + auto r{ pqxx::internal::gate::result_creation::create(smart, query, enc)}; pqxx::internal::gate::result_creation{r}.check_status(desc); return r; @@ -445,7 +446,7 @@ pqxx::connection::remove_receiver(pqxx::notification_receiver *T) noexcept bool const gone{R.second == ++R.first}; m_receivers.erase(i); if (gone) - exec(internal::concat("UNLISTEN ", quote_name(needle.first)).c_str()); + exec(internal::concat("UNLISTEN ", quote_name(needle.first))); } } catch (std::exception const &e) @@ -484,7 +485,7 @@ constexpr int buf_size{500u}; void PQXX_COLD pqxx::connection::cancel_query() { - std::unique_ptr cancel{ + std::unique_ptr const cancel{ PQgetCancel(m_conn), wrap_pgfreecancel}; if (cancel == nullptr) PQXX_UNLIKELY @@ -552,7 +553,7 @@ using notify_ptr = std::unique_ptr; /// Get one notification from a connection, or null. notify_ptr get_notif(pqxx::internal::pq::PGconn *conn) { - return notify_ptr(PQnotifies(conn), pqxx::internal::pq::pqfreemem); + return {PQnotifies(conn), pqxx::internal::pq::pqfreemem}; } } // namespace @@ -576,7 +577,7 @@ int pqxx::connection::get_notifs() auto const Hit{m_receivers.equal_range(std::string{N->relname})}; if (Hit.second != Hit.first) { - std::string payload{N->extra}; + std::string const payload{N->extra}; for (auto i{Hit.first}; i != Hit.second; ++i) try { (*i->second)(payload, N->be_pid); @@ -685,9 +686,9 @@ pqxx::connection::exec(std::string_view query, std::string_view desc) pqxx::result pqxx::connection::exec( - std::shared_ptr query, std::string_view desc) + std::shared_ptr const &query, std::string_view desc) { - auto const res{make_result(PQexec(m_conn, query->c_str()), query, desc)}; + auto res{make_result(PQexec(m_conn, query->c_str()), query, desc)}; get_notifs(); return res; } @@ -697,9 +698,9 @@ std::string pqxx::connection::encrypt_password( char const user[], char const password[], char const *algorithm) { auto const buf{PQencryptPasswordConn(m_conn, password, user, algorithm)}; - std::unique_ptr ptr{ + std::unique_ptr const ptr{ buf, pqxx::internal::pq::pqfreemem}; - return std::string(ptr.get()); + return (ptr.get()); } @@ -735,7 +736,7 @@ pqxx::result pqxx::connection::exec_prepared( args.values.data(), args.lengths.data(), reinterpret_cast(args.formats.data()), static_cast(format::text))}; - auto const r{make_result(pq_result, q, statement)}; + auto r{make_result(pq_result, q, statement)}; get_notifs(); return r; } @@ -872,7 +873,7 @@ void pqxx::connection::write_copy_line(std::string_view line) void pqxx::connection::end_copy_write() { - int res{PQputCopyEnd(m_conn, nullptr)}; + int const res{PQputCopyEnd(m_conn, nullptr)}; switch (res) { case -1: @@ -994,10 +995,10 @@ std::string pqxx::connection::quote(std::basic_string_view b) const std::string pqxx::connection::quote_name(std::string_view identifier) const { - std::unique_ptr buf{ + std::unique_ptr const buf{ PQescapeIdentifier(m_conn, identifier.data(), std::size(identifier)), pqxx::internal::pq::pqfreemem}; - if (buf.get() == nullptr) + if (buf == nullptr) PQXX_UNLIKELY throw failure{err_msg()}; return std::string{buf.get()}; @@ -1053,7 +1054,7 @@ int pqxx::connection::await_notification() int pqxx::connection::await_notification( std::time_t seconds, long microseconds) { - int notifs = get_notifs(); + int const notifs = get_notifs(); if (notifs == 0) { PQXX_LIKELY @@ -1136,7 +1137,7 @@ pqxx::result pqxx::connection::exec_params( args.values.data(), args.lengths.data(), reinterpret_cast(args.formats.data()), static_cast(format::text))}; - auto const r{make_result(pq_result, q)}; + auto r{make_result(pq_result, q)}; get_notifs(); return r; } @@ -1190,7 +1191,7 @@ std::string pqxx::connection::connection_string() const std::unique_ptr const params{ PQconninfo(m_conn), pqconninfofree}; - if (params.get() == nullptr) + if (params == nullptr) PQXX_UNLIKELY throw std::bad_alloc{}; diff --git a/src/cursor.cxx b/src/cursor.cxx index f7a79bc21..4adb9b8f8 100644 --- a/src/cursor.cxx +++ b/src/cursor.cxx @@ -106,7 +106,7 @@ void pqxx::icursorstream::set_stride(difference_type stride) & pqxx::result pqxx::icursorstream::fetchblock() { - result const r{m_cur.fetch(m_stride)}; + result r{m_cur.fetch(m_stride)}; m_realpos += std::size(r); if (std::empty(r)) m_done = true; diff --git a/src/encodings.cxx b/src/encodings.cxx index c9810a492..90e0d658e 100644 --- a/src/encodings.cxx +++ b/src/encodings.cxx @@ -36,15 +36,20 @@ pqxx::internal::encoding_group enc_group(std::string_view encoding_name) { struct mapping { - std::string_view name; - pqxx::internal::encoding_group group; + private: + std::string_view m_name; + pqxx::internal::encoding_group m_group; + public: constexpr mapping(std::string_view n, pqxx::internal::encoding_group g) : - name{n}, group{g} + m_name{n}, m_group{g} {} constexpr bool operator<(mapping const &rhs) const { - return name < rhs.name; + return m_name < rhs.m_name; } + [[nodiscard]] std::string_view get_name() const { return m_name; } + [[nodiscard]] pqxx::internal::encoding_group get_group() const + { return m_group; } }; // C++20: Once compilers are ready, go full constexpr, leave to the compiler. @@ -71,8 +76,8 @@ pqxx::internal::encoding_group enc_group(std::string_view encoding_name) mapping{"TW"sv, pqxx::internal::encoding_group::EUC_TW}, }; for (auto const &m : subtypes) - if (m.name == subtype) - return m.group; + if (m.get_name() == subtype) + return m.get_group(); } PQXX_UNLIKELY break; diff --git a/src/except.cxx b/src/except.cxx index 49a88f50b..0617fda2d 100644 --- a/src/except.cxx +++ b/src/except.cxx @@ -86,7 +86,7 @@ pqxx::variable_set_to_null::variable_set_to_null( pqxx::sql_error::sql_error( - std::string const &whatarg, std::string const &Q, char const sqlstate[] + std::string whatarg, std::string const &Q, char const sqlstate[] #if defined(PQXX_HAVE_SOURCE_LOCATION) , std::source_location loc @@ -94,7 +94,7 @@ pqxx::sql_error::sql_error( ) : failure { - whatarg + std::move(whatarg) #if defined(PQXX_HAVE_SOURCE_LOCATION) , loc diff --git a/src/pipeline.cxx b/src/pipeline.cxx index 63a9c38d4..f5c1baeb7 100644 --- a/src/pipeline.cxx +++ b/src/pipeline.cxx @@ -287,7 +287,8 @@ void pqxx::pipeline::obtain_dummy() PQXX_UNLIKELY internal_error("Pipeline got no result from backend when it expected one."); - result R{pqxx::internal::gate::result_creation::create(r, text, m_encoding)}; + result const R{ + pqxx::internal::gate::result_creation::create(r, text, m_encoding)}; bool OK{false}; try @@ -406,7 +407,7 @@ pqxx::pipeline::retrieve(pipeline::QueryMap::iterator q) issue(); result const R{q->second.res}; - auto const P{std::make_pair(q->first, R)}; + auto P{std::make_pair(q->first, R)}; m_queries.erase(q); diff --git a/src/result.cxx b/src/result.cxx index 673bb9cbe..ff786ef82 100644 --- a/src/result.cxx +++ b/src/result.cxx @@ -33,7 +33,7 @@ extern "C" namespace pqxx { PQXX_DECLARE_ENUM_CONVERSION(ExecStatusType); -} +} // namespace pqxx std::string const pqxx::result::s_empty_string; @@ -46,8 +46,8 @@ void pqxx::internal::clear_result(pq::PGresult const *data) noexcept pqxx::result::result( - std::shared_ptr rhs, - std::shared_ptr query, internal::encoding_group enc) : + std::shared_ptr const &rhs, + std::shared_ptr const &query, internal::encoding_group enc) : m_data{rhs}, m_query{query}, m_encoding(enc) {} @@ -357,7 +357,7 @@ char const *pqxx::result::cmd_status() const noexcept std::string const &pqxx::result::query() const & noexcept { - return (m_query.get() == nullptr) ? s_empty_string : *m_query; + return (m_query == nullptr) ? s_empty_string : *m_query; } @@ -524,7 +524,7 @@ int pqxx::result::column_type_modifier( pqxx::const_result_iterator pqxx::const_result_iterator::operator++(int) & { - const_result_iterator const old{*this}; + const_result_iterator old{*this}; m_index++; return old; } @@ -532,7 +532,7 @@ pqxx::const_result_iterator pqxx::const_result_iterator::operator++(int) & pqxx::const_result_iterator pqxx::const_result_iterator::operator--(int) & { - const_result_iterator const old{*this}; + const_result_iterator old{*this}; m_index--; return old; } diff --git a/src/row.cxx b/src/row.cxx index 4bb68a66e..5152f031e 100644 --- a/src/row.cxx +++ b/src/row.cxx @@ -210,7 +210,7 @@ bool PQXX_COLD pqxx::row::empty() const noexcept pqxx::const_row_iterator pqxx::const_row_iterator::operator++(int) & noexcept { - auto const old{*this}; + auto old{*this}; m_col++; return old; } @@ -218,7 +218,7 @@ pqxx::const_row_iterator pqxx::const_row_iterator::operator++(int) & noexcept pqxx::const_row_iterator pqxx::const_row_iterator::operator--(int) & noexcept { - auto const old{*this}; + auto old{*this}; m_col--; return old; } diff --git a/src/sql_cursor.cxx b/src/sql_cursor.cxx index cbf99fb5a..adc862557 100644 --- a/src/sql_cursor.cxx +++ b/src/sql_cursor.cxx @@ -134,7 +134,6 @@ pqxx::internal::sql_cursor::sql_cursor( cursor_base::ownership_policy op) : cursor_base{t.conn(), cname, false}, m_home{t.conn()}, - m_empty_result{}, m_ownership{op}, m_at_end{0}, m_pos{-1} @@ -233,7 +232,7 @@ pqxx::result pqxx::internal::sql_cursor::fetch( } auto const query{pqxx::internal::concat( "FETCH "sv, stridestring(rows), " IN "sv, m_home.quote_name(name()))}; - auto const r{gate::connection_sql_cursor{m_home}.exec(query.c_str())}; + auto r{gate::connection_sql_cursor{m_home}.exec(query.c_str())}; displacement = adjust(rows, difference_type(std::size(r))); return r; } diff --git a/src/strconv.cxx b/src/strconv.cxx index 0d348cb7f..82ace1fc9 100644 --- a/src/strconv.cxx +++ b/src/strconv.cxx @@ -243,7 +243,7 @@ std::string demangle_type_name(char const raw[]) // fall back to the raw name. // // When __cxa_demangle fails, it's guaranteed to return null. - std::unique_ptr demangled{ + std::unique_ptr const demangled{ abi::__cxa_demangle(raw, nullptr, nullptr, &status), [](char *x){ std::free(x); }}; #else diff --git a/src/stream_from.cxx b/src/stream_from.cxx index 8dc379236..be8274e4d 100644 --- a/src/stream_from.cxx +++ b/src/stream_from.cxx @@ -116,7 +116,7 @@ pqxx::stream_from::raw_line pqxx::stream_from::get_raw_line() try { raw_line line{gate.read_copy_line()}; - if (line.first.get() == nullptr) + if (line.first == nullptr) close(); return line; } diff --git a/src/stream_to.cxx b/src/stream_to.cxx index 270e0a615..cdf6d875d 100644 --- a/src/stream_to.cxx +++ b/src/stream_to.cxx @@ -47,6 +47,7 @@ char escape_char(char special) case '\t': return 't'; case '\v': return 'v'; case '\\': return '\\'; + default: break; } PQXX_UNLIKELY throw pqxx::internal_error{pqxx::internal::concat( "Stream escaping unexpectedly stopped at '", diff --git a/src/subtransaction.cxx b/src/subtransaction.cxx index 0d50d78e9..15c3839ec 100644 --- a/src/subtransaction.cxx +++ b/src/subtransaction.cxx @@ -46,7 +46,7 @@ pqxx::subtransaction::subtransaction( namespace { using dbtransaction_ref = pqxx::dbtransaction &; -} +} // namespace pqxx::subtransaction::subtransaction( diff --git a/src/transaction_base.cxx b/src/transaction_base.cxx index 08a1ac4e3..0d15c60c6 100644 --- a/src/transaction_base.cxx +++ b/src/transaction_base.cxx @@ -249,7 +249,7 @@ pqxx::transaction_base::exec(std::string_view query, std::string_view desc) { check_pending_error(); - command cmd{*this, desc}; + command const cmd{*this, desc}; switch (m_status) { @@ -276,7 +276,7 @@ pqxx::result pqxx::transaction_base::exec_n( result::size_type rows, zview query, std::string_view desc) { #include "pqxx/internal/ignore-deprecated-pre.hxx" - result const r{exec(query, desc)}; + result r{exec(query, desc)}; #include "pqxx/internal/ignore-deprecated-post.hxx" if (std::size(r) != rows) { @@ -314,7 +314,7 @@ void pqxx::transaction_base::check_rowcount_params( pqxx::result pqxx::transaction_base::internal_exec_prepared( zview statement, internal::c_params const &args) { - command cmd{*this, statement}; + command const cmd{*this, statement}; return pqxx::internal::gate::connection_transaction{conn()}.exec_prepared( statement, args); } @@ -323,7 +323,7 @@ pqxx::result pqxx::transaction_base::internal_exec_prepared( pqxx::result pqxx::transaction_base::internal_exec_params( zview query, internal::c_params const &args) { - command cmd{*this, query}; + command const cmd{*this, query}; return pqxx::internal::gate::connection_transaction{conn()}.exec_params( query, args); } @@ -451,7 +451,8 @@ pqxx::result pqxx::transaction_base::direct_exec( std::shared_ptr cmd, std::string_view desc) { check_pending_error(); - return pqxx::internal::gate::connection_transaction{conn()}.exec(cmd, desc); + return pqxx::internal::gate::connection_transaction{conn()}.exec( + std::move(cmd), desc); } diff --git a/src/util.cxx b/src/util.cxx index 23133cfc9..9ff547398 100644 --- a/src/util.cxx +++ b/src/util.cxx @@ -182,10 +182,10 @@ void pqxx::internal::unesc_bin( auto out{buffer}; while (in != end) { - int hi{nibble(*in++)}; + int const hi{nibble(*in++)}; if (hi < 0) throw pqxx::failure{"Invalid hex-escaped data."}; - int lo{nibble(*in++)}; + int const lo{nibble(*in++)}; if (lo < 0) throw pqxx::failure{"Invalid hex-escaped data."}; *out++ = static_cast((hi << 4) | lo);