From b5939e3565cc4b3e8aecd35bd6e77b8b5462fa33 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 16 Feb 2019 13:20:13 +0000 Subject: More clang tidy fixes --- Jamroot.jam | 4 ++++ libdbpp/connection.cpp | 9 ++++++++- libdbpp/tablepatch.cpp | 3 +-- libdbpp/unittests/Jamfile.jam | 2 +- libdbpp/unittests/libdbpp-postgresql | 2 +- libdbpp/unittests/testUtils.cpp | 3 ++- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Jamroot.jam b/Jamroot.jam index c480c8a..c9d6c33 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -15,6 +15,10 @@ project debug:"-W -Wall -Werror -Wextra" coverage:"--coverage" coverage:"--coverage" + tidy:boost-* + tidy:bugprone-* + tidy:clang-* + tidy:misc-* ; build-project libdbpp ; diff --git a/libdbpp/connection.cpp b/libdbpp/connection.cpp index 69e1e92..a3ae615 100644 --- a/libdbpp/connection.cpp +++ b/libdbpp/connection.cpp @@ -189,10 +189,17 @@ DB::TransactionScope::TransactionScope(DB::Connection & c) : conn.beginTx(); } +// It is acceptable for a commit to fail +// NOLINTNEXTLINE(bugprone-exception-escape) DB::TransactionScope::~TransactionScope() { if (std::uncaught_exceptions()) { - conn.rollbackTx(); + try { + conn.rollbackTx(); + } + catch (...) { + // Nothing we can do here + } } else { conn.commitTx(); diff --git a/libdbpp/tablepatch.cpp b/libdbpp/tablepatch.cpp index 3c3796d..5df2aca 100644 --- a/libdbpp/tablepatch.cpp +++ b/libdbpp/tablepatch.cpp @@ -92,8 +92,7 @@ self(const typename Container::const_iterator & i) return *i; } #define selfCols self -#define isKey(tp) [tp](auto i){ return AdHoc::containerContains(tp->pk, *i); } -#define isNotKey(tp) [tp](auto i){ return !AdHoc::containerContains(tp->pk, *i); } +#define isNotKey(tp) [tp](auto i){ return !AdHoc::containerContains((tp)->pk, *i); } static void diff --git a/libdbpp/unittests/Jamfile.jam b/libdbpp/unittests/Jamfile.jam index a8fca66..95921cd 100644 --- a/libdbpp/unittests/Jamfile.jam +++ b/libdbpp/unittests/Jamfile.jam @@ -6,7 +6,7 @@ lib pq ; lib mysqlclient : : : : /usr/include/mysql ; lib boost_date_time ; lib boost_system ; -lib boost_utf : : boost_unit_test_framework ; +lib boost_utf : : boost_unit_test_framework : : tidy:hicpp-* ; lib Ice++11 ; run diff --git a/libdbpp/unittests/libdbpp-postgresql b/libdbpp/unittests/libdbpp-postgresql index 283047d..6b91313 160000 --- a/libdbpp/unittests/libdbpp-postgresql +++ b/libdbpp/unittests/libdbpp-postgresql @@ -1 +1 @@ -Subproject commit 283047d0db99da4579c54ac50bbc71ff358360d4 +Subproject commit 6b913137275cacde9f938058f961d4cbb64f584b diff --git a/libdbpp/unittests/testUtils.cpp b/libdbpp/unittests/testUtils.cpp index 4c28538..092140b 100644 --- a/libdbpp/unittests/testUtils.cpp +++ b/libdbpp/unittests/testUtils.cpp @@ -293,7 +293,7 @@ BOOST_AUTO_TEST_CASE( bindIntPtr ) ins->execute(); delete is2; auto sel = db->select("SELECT a, b FROM forEachRow"); - unsigned int total = 0; + double total = 0; for (const auto & row : sel->as, std::optional>()) { BOOST_REQUIRE(row[0].isNull()); BOOST_REQUIRE(!row[1].isNull()); @@ -381,6 +381,7 @@ testExtractT(DB::SelectCommandPtr sel) { #ifdef __clang__ // Clang cannot compile this for reasons largely todo with ambiguousness in the spec // Fixed when we move to std::chrono + // NOLINTNEXTLINE(bugprone-suspicious-semicolon) if constexpr (!std::is_same::value) { #else if constexpr (true) { -- cgit v1.2.3