From 26723b98d41d5238a034e552e5e4e1b8096b7b18 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 17 Feb 2019 16:16:29 +0000 Subject: Enable hicpp checks and fix accordingly --- Jamroot.jam | 1 + libdbpp/command.cpp | 12 ++++++++---- libdbpp/connection.cpp | 20 ++++++++++++-------- libdbpp/sqlParseImpl.cpp | 2 +- libdbpp/tablepatch.cpp | 2 +- libdbpp/testCore.cpp | 4 +++- libdbpp/unittests/libdbpp-mysql | 2 +- libdbpp/unittests/libdbpp-postgresql | 2 +- 8 files changed, 28 insertions(+), 17 deletions(-) diff --git a/Jamroot.jam b/Jamroot.jam index 6857f8a..7e91686 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -20,6 +20,7 @@ project tidy:clang-* tidy:misc-* tidy:modernize-* + tidy:hicpp-* ; build-project libdbpp ; diff --git a/libdbpp/command.cpp b/libdbpp/command.cpp index 0c97403..de2563d 100644 --- a/libdbpp/command.cpp +++ b/libdbpp/command.cpp @@ -27,20 +27,24 @@ DB::CommandOptions::isSet(const CommandOptionsMap & map, const std::string & key void DB::Command::bindParamS(unsigned int i, const char * const o) { - if (o) + if (o) { bindParamS(i, std::string_view(o)); - else + } + else { bindNull(i); + } } void DB::Command::bindParamS(unsigned int i, char * const o) { - if (o) + if (o) { bindParamS(i, std::string_view(o)); - else + } + else { bindNull(i); + } } void diff --git a/libdbpp/connection.cpp b/libdbpp/connection.cpp index 8050d06..42044f9 100644 --- a/libdbpp/connection.cpp +++ b/libdbpp/connection.cpp @@ -137,11 +137,13 @@ DB::Connection::bulkUploadData(const char *, size_t) const size_t DB::Connection::bulkUploadData(std::istream & in) const { - if (!in.good()) throw std::runtime_error("Input stream is not good"); - char buf[BUFSIZ]; + if (!in.good()) { + throw std::runtime_error("Input stream is not good"); + } + std::array buf {}; size_t total = 0; - for (std::streamsize r; (r = in.readsome(buf, sizeof(buf))) > 0; ) { - bulkUploadData(buf, r); + for (std::streamsize r; (r = in.readsome(buf.data(), buf.size())) > 0; ) { + bulkUploadData(buf.data(), r); total += r; } return total; @@ -150,11 +152,13 @@ DB::Connection::bulkUploadData(std::istream & in) const size_t DB::Connection::bulkUploadData(FILE * in) const { - if (!in) throw std::runtime_error("Input file handle is null"); - char buf[BUFSIZ]; + if (!in) { + throw std::runtime_error("Input file handle is null"); + } + std::array buf {}; size_t total = 0, r; - while ((r = fread(buf, 1, sizeof(buf), in)) > 0) { - bulkUploadData(buf, r); + while ((r = fread(buf.data(), 1, buf.size(), in)) > 0) { + bulkUploadData(buf.data(), r); total += r; } if ((int)r < 0) { diff --git a/libdbpp/sqlParseImpl.cpp b/libdbpp/sqlParseImpl.cpp index f646dbe..4c3a990 100644 --- a/libdbpp/sqlParseImpl.cpp +++ b/libdbpp/sqlParseImpl.cpp @@ -24,7 +24,7 @@ namespace DB { void SqlParse::Execute() { - while (yylex()) ; + while (yylex()) {} } void diff --git a/libdbpp/tablepatch.cpp b/libdbpp/tablepatch.cpp index d270d7c..8623848 100644 --- a/libdbpp/tablepatch.cpp +++ b/libdbpp/tablepatch.cpp @@ -328,7 +328,7 @@ patchInsertsSelect(AdHoc::Buffer & toInsSql, DB::TablePatch * tp) toInsSql.append(" WHERE "); append(toInsSql, tp->pk, " AND ", " a.%s IS NULL", selfCols); if (tp->order) { - toInsSql.appendf(" ORDER BY "); + toInsSql.append(" ORDER BY "); tp->order->writeSql(toInsSql); } } diff --git a/libdbpp/testCore.cpp b/libdbpp/testCore.cpp index d142000..785d990 100644 --- a/libdbpp/testCore.cpp +++ b/libdbpp/testCore.cpp @@ -19,7 +19,7 @@ TestCore::TestCore() : template class Assert : public DB::HandleField { public: - Assert(const T & e) : expected(e) { } + explicit Assert(const T & e) : expected(e) { } void floatingpoint(double v) override { (*this)(v); } void integer(int64_t v) override { (*this)(v); } @@ -32,10 +32,12 @@ class Assert : public DB::HandleField { template void operator()(const D & v) { + // NOLINTNEXTLINE(hicpp-braces-around-statements) if constexpr (std::is_convertible::value) { BOOST_REQUIRE_EQUAL(expected, v); } else { + // NOLINTNEXTLINE(hicpp-vararg) BOOST_ERROR("Unexpected column type " << typeid(D).name()); } } diff --git a/libdbpp/unittests/libdbpp-mysql b/libdbpp/unittests/libdbpp-mysql index b8ddecf..3480045 160000 --- a/libdbpp/unittests/libdbpp-mysql +++ b/libdbpp/unittests/libdbpp-mysql @@ -1 +1 @@ -Subproject commit b8ddecf41c8938136b3f4a081e1b8a98584c2401 +Subproject commit 34800459e7645fea3640214b5f7f6d7de183d332 diff --git a/libdbpp/unittests/libdbpp-postgresql b/libdbpp/unittests/libdbpp-postgresql index 1ca0cd4..d7ff2e0 160000 --- a/libdbpp/unittests/libdbpp-postgresql +++ b/libdbpp/unittests/libdbpp-postgresql @@ -1 +1 @@ -Subproject commit 1ca0cd42419656cf4a4b9e37c5f3cfb51ccafbb5 +Subproject commit d7ff2e0d651d6b0bc24cf2b173613d6386576bc4 -- cgit v1.2.3