diff --git a/config/Makefile.in b/config/Makefile.in index 51586bda2..9b1454986 100644 --- a/config/Makefile.in +++ b/config/Makefile.in @@ -124,7 +124,7 @@ am__can_run_installinfo = \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) am__DIST_COMMON = $(srcdir)/Makefile.in compile config.guess \ - config.sub install-sh ltmain.sh missing mkinstalldirs + config.sub depcomp install-sh ltmain.sh missing mkinstalldirs DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ diff --git a/src/binarystring.cxx b/src/binarystring.cxx index 8a428c906..4781976f0 100644 --- a/src/binarystring.cxx +++ b/src/binarystring.cxx @@ -36,6 +36,7 @@ std::shared_ptr PQXX_COLD copy_to_buffer(void const *data, std::size_t len) { std::shared_ptr ptr{ + // NOLINTNEXTLINE(cppcoreguidelines-no-malloc,hicpp-no-malloc) static_cast(malloc(len + 1)), std::free}; if (not ptr) throw std::bad_alloc{}; diff --git a/src/result.cxx b/src/result.cxx index 8b1599073..e88e21532 100644 --- a/src/result.cxx +++ b/src/result.cxx @@ -44,6 +44,7 @@ void pqxx::internal::clear_result(pq::PGresult const *data) noexcept // This acts as a destructor, though implemented as a regular function so we // can pass it into a smart pointer. That's why I think it's kind of fair // to treat the PGresult as const. + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) PQclear(const_cast(data)); } @@ -362,6 +363,7 @@ char const *pqxx::result::cmd_status() const noexcept // PQcmdStatus() can't take a PGresult const * because it returns a non-const // pointer into the PGresult's data, and that can't be changed without // breaking compatibility. + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) return PQcmdStatus(const_cast(m_data.get())); } @@ -383,12 +385,13 @@ pqxx::oid pqxx::result::inserted_oid() const pqxx::result::size_type pqxx::result::affected_rows() const { - // PQcmdTuples() can't take a PGresult const * because it returns a non-const - // pointer into the PGresult's data, and that can't be changed without - // breaking compatibility. - auto const rows_str{ + // PQcmdTuples() can't take a "PGresult const *" because it returns a + // non-const pointer into the PGresult's data, and that can't be changed + // without breaking compatibility. + std::string_view const rows_str{ + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) PQcmdTuples(const_cast(m_data.get()))}; - return (rows_str[0] == '\0') ? 0 : size_type(atoi(rows_str)); + return from_string(rows_str); } diff --git a/src/strconv.cxx b/src/strconv.cxx index 032ac77ae..5a7eb6fde 100644 --- a/src/strconv.cxx +++ b/src/strconv.cxx @@ -151,6 +151,7 @@ wrap_to_chars(char *begin, char *end, T const &value) namespace pqxx::internal { template +// NOLINTNEXTLINE(readability-non-const-parameter) zview integral_traits::to_buf(char *begin, char *end, T const &value) { static_assert(std::is_integral_v); @@ -236,6 +237,7 @@ std::string demangle_type_name(char const raw[]) // When __cxa_demangle fails, it's guaranteed to return null. std::unique_ptr const demangled{ abi::__cxa_demangle(raw, nullptr, nullptr, &status), + // NOLINTNEXTLINE(*-no-malloc,cppcoreguidelines-owning-memory) [](char *x) { std::free(x); }}; #else std::unique_ptr demangled{}; diff --git a/src/util.cxx b/src/util.cxx index 09cf73aa5..e600dca0d 100644 --- a/src/util.cxx +++ b/src/util.cxx @@ -110,8 +110,7 @@ constexpr std::array hex_digits{ /// Translate a number (must be between 0 and 16 exclusive) to a hex digit. constexpr char hex_digit(int c) noexcept { - assert(c >= 0 and c < pqxx::internal::ssize(hex_digits)); - return hex_digits[static_cast(c)]; + return hex_digits.at(static_cast(c)); } @@ -207,6 +206,7 @@ void pqfreemem(void const *ptr) noexcept { // Why is it OK to const_cast here? Because this is the C equivalent to a // destructor. Those apply to const objects as well as non-const ones. + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) PQfreemem(const_cast(ptr)); } } // namespace pqxx::internal::pq