Skip to content

Commit

Permalink
More lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtv committed Dec 23, 2023
1 parent f77ee7b commit a4b292a
Show file tree
Hide file tree
Showing 19 changed files with 172 additions and 69 deletions.
105 changes: 99 additions & 6 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -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-*,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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
5 changes: 3 additions & 2 deletions include/pqxx/connection.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ concept ZKey_ZValues = std::ranges::input_range<T> 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


Expand Down Expand Up @@ -1110,7 +1110,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>, std::string_view = ""sv);
PQXX_PRIVATE exec(
std::shared_ptr<std::string> const &, std::string_view = ""sv);
void PQXX_PRIVATE register_transaction(transaction_base *);
void PQXX_PRIVATE unregister_transaction(transaction_base *) noexcept;

Expand Down
2 changes: 1 addition & 1 deletion include/pqxx/except.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
,
Expand Down
4 changes: 2 additions & 2 deletions include/pqxx/result.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ private:

friend class pqxx::internal::gate::result_creation;
result(
std::shared_ptr<internal::pq::PGresult> rhs,
std::shared_ptr<std::string> query, internal::encoding_group enc);
std::shared_ptr<internal::pq::PGresult> const &rhs,
std::shared_ptr<std::string> const &query, internal::encoding_group enc);

PQXX_PRIVATE void check_status(std::string_view desc = ""sv) const;

Expand Down
19 changes: 10 additions & 9 deletions src/blob.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -39,15 +39,15 @@ 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();
}


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))};
Expand All @@ -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()))};
Expand Down Expand Up @@ -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<char *>(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())};
Expand All @@ -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<char const *>(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())};
Expand All @@ -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())};
Expand All @@ -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())};
Expand Down Expand Up @@ -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<std::byte> data, oid id)
{
oid actual_id{create(tx, id)};
oid const actual_id{create(tx, id)};
try
{
open_w(tx, actual_id).write(data);
Expand Down
Loading

0 comments on commit a4b292a

Please sign in to comment.