summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2019-02-17 16:16:29 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2019-02-17 16:16:29 +0000
commit26723b98d41d5238a034e552e5e4e1b8096b7b18 (patch)
treef63f6ceb046c83d42ea593d29b9dd9bbf8fc578b
parentModernize clang tidy fixes (diff)
downloadlibdbpp-26723b98d41d5238a034e552e5e4e1b8096b7b18.tar.bz2
libdbpp-26723b98d41d5238a034e552e5e4e1b8096b7b18.tar.xz
libdbpp-26723b98d41d5238a034e552e5e4e1b8096b7b18.zip
Enable hicpp checks and fix accordingly
-rw-r--r--Jamroot.jam1
-rw-r--r--libdbpp/command.cpp12
-rw-r--r--libdbpp/connection.cpp20
-rw-r--r--libdbpp/sqlParseImpl.cpp2
-rw-r--r--libdbpp/tablepatch.cpp2
-rw-r--r--libdbpp/testCore.cpp4
m---------libdbpp/unittests/libdbpp-mysql0
m---------libdbpp/unittests/libdbpp-postgresql0
8 files changed, 26 insertions, 15 deletions
diff --git a/Jamroot.jam b/Jamroot.jam
index 6857f8a..7e91686 100644
--- a/Jamroot.jam
+++ b/Jamroot.jam
@@ -20,6 +20,7 @@ project
<toolset>tidy:<checkxx>clang-*
<toolset>tidy:<checkxx>misc-*
<toolset>tidy:<checkxx>modernize-*
+ <toolset>tidy:<checkxx>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<char, BUFSIZ> 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<char, BUFSIZ> 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<typename T>
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 <typename D>
void operator()(const D & v) {
+ // NOLINTNEXTLINE(hicpp-braces-around-statements)
if constexpr (std::is_convertible<D, T>::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
-Subproject b8ddecf41c8938136b3f4a081e1b8a98584c240
+Subproject 34800459e7645fea3640214b5f7f6d7de183d33
diff --git a/libdbpp/unittests/libdbpp-postgresql b/libdbpp/unittests/libdbpp-postgresql
-Subproject 1ca0cd42419656cf4a4b9e37c5f3cfb51ccafbb
+Subproject d7ff2e0d651d6b0bc24cf2b173613d6386576bc