diff options
-rw-r--r-- | Jamroot.jam | 4 | ||||
-rw-r--r-- | libadhocutil/Jamfile.jam | 3 | ||||
-rw-r--r-- | libadhocutil/buffer.cpp | 1 | ||||
-rw-r--r-- | libadhocutil/curlHandle.cpp | 5 | ||||
-rw-r--r-- | libadhocutil/lexer-regex.cpp | 8 | ||||
-rw-r--r-- | libadhocutil/processPipes.cpp | 7 | ||||
-rw-r--r-- | libadhocutil/unittests/testBuffer.cpp | 3 | ||||
-rw-r--r-- | libadhocutil/unittests/testCompileTimeFormatter.cpp | 2 | ||||
-rw-r--r-- | libadhocutil/unittests/testFileUtils.cpp | 11 | ||||
-rw-r--r-- | libadhocutil/unittests/testResourcePool.cpp | 1 | ||||
-rw-r--r-- | libadhocutil/uriParse.cpp | 1 |
11 files changed, 28 insertions, 18 deletions
diff --git a/Jamroot.jam b/Jamroot.jam index 0ffaffb..6c48dae 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -17,6 +17,10 @@ project <variant>debug:<cxxflags>"-W -Wall -Werror -Wextra" <variant>coverage:<cxxflags>"--coverage" <variant>coverage:<linkflags>"--coverage" + <toolset>tidy:<checkxx>boost-* + <toolset>tidy:<checkxx>bugprone-* + <toolset>tidy:<checkxx>clang-* + <toolset>tidy:<checkxx>misc-* ; build-project libadhocutil ; diff --git a/libadhocutil/Jamfile.jam b/libadhocutil/Jamfile.jam index 715874c..3bbd3df 100644 --- a/libadhocutil/Jamfile.jam +++ b/libadhocutil/Jamfile.jam @@ -8,7 +8,8 @@ lib curl ; lib dl ; lib adhocutil : - [ glob *.ll *.cpp *.ice : bin ] + [ glob *.cpp *.ice : bin ] + [ obj nvpParse : nvpParse.ll : <include>. <toolset>tidy:<checker>none ] : <include>. <library>Ice++11 diff --git a/libadhocutil/buffer.cpp b/libadhocutil/buffer.cpp index 934aee5..f0deedc 100644 --- a/libadhocutil/buffer.cpp +++ b/libadhocutil/buffer.cpp @@ -223,7 +223,6 @@ Buffer::writeto(char * buf, size_t bufSize, size_t off) const *buf++ = (**f)[c++]; } ++f; - off = 0; } *buf = '\0'; } diff --git a/libadhocutil/curlHandle.cpp b/libadhocutil/curlHandle.cpp index f68eb10..3f0263b 100644 --- a/libadhocutil/curlHandle.cpp +++ b/libadhocutil/curlHandle.cpp @@ -112,12 +112,11 @@ void CurlHandle::checkCurlCode(CURLcode res) const { if (res != CURLE_OK) { - AdHoc::Net::CurlException ce(res, curl_easy_strerror(res), IceUtil::Optional<Ice::Short>()); long http_code = 0; if (curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &http_code) == CURLE_OK) { - ce.httpcode = http_code; + throw AdHoc::Net::CurlException(res, curl_easy_strerror(res), http_code); } - throw ce; + throw AdHoc::Net::CurlException(res, curl_easy_strerror(res), IceUtil::None); } } diff --git a/libadhocutil/lexer-regex.cpp b/libadhocutil/lexer-regex.cpp index 9b2be79..493c823 100644 --- a/libadhocutil/lexer-regex.cpp +++ b/libadhocutil/lexer-regex.cpp @@ -10,9 +10,9 @@ namespace AdHoc { info(nullptr) { if (!regex) { - std::runtime_error e(std::string("Failed to create GRegex: ") + err->message); + auto msg = std::string("Failed to create GRegex: ") + err->message; g_error_free(err); - throw e; + throw std::runtime_error(msg); } } @@ -34,9 +34,9 @@ namespace AdHoc { } g_regex_match_full(regex, string, length, position, G_REGEX_MATCH_ANCHORED, &info, &err); if (err) { - std::runtime_error e(std::string("Failed to execute regex: ") + err->message); + auto msg = std::string("Failed to create GRegex: ") + err->message; g_error_free(err); - throw e; + throw std::runtime_error(msg); } str = string; return g_match_info_matches(info); diff --git a/libadhocutil/processPipes.cpp b/libadhocutil/processPipes.cpp index cca7cce..5e243d5 100644 --- a/libadhocutil/processPipes.cpp +++ b/libadhocutil/processPipes.cpp @@ -28,6 +28,9 @@ ProcessPipes::ProcessPipes(const std::vector<std::string> & args, bool i, bool o out(-1), error(-1) { + if (args.empty()) { + throw std::invalid_argument("args is empty"); + } int ipipes[2], opipes[2], epipes[2]; ScopeExit tidyUp; if (i) { @@ -76,7 +79,9 @@ ProcessPipes::ProcessPipes(const std::vector<std::string> & args, bool i, bool o *w++ = strdup(p.c_str()); } *w = NULL; - execv(buf[0], buf); + if (*buf) { + execv(buf[0], buf); + } abort(); break; } diff --git a/libadhocutil/unittests/testBuffer.cpp b/libadhocutil/unittests/testBuffer.cpp index 46a4242..d421443 100644 --- a/libadhocutil/unittests/testBuffer.cpp +++ b/libadhocutil/unittests/testBuffer.cpp @@ -9,8 +9,7 @@ BOOST_AUTO_TEST_CASE ( create ) { Buffer empty; Buffer copy("const", Buffer::Copy); - auto nonconst = (char*)malloc(9); - strcpy(nonconst, "nonconst"); + auto nonconst = strdup("nonconst"); Buffer use(nonconst, Buffer::Use); Buffer fre(nonconst, Buffer::Free); diff --git a/libadhocutil/unittests/testCompileTimeFormatter.cpp b/libadhocutil/unittests/testCompileTimeFormatter.cpp index 7313252..001349f 100644 --- a/libadhocutil/unittests/testCompileTimeFormatter.cpp +++ b/libadhocutil/unittests/testCompileTimeFormatter.cpp @@ -55,6 +55,7 @@ namespace AdHoc { template<typename P, typename ... Pn> static void write(stream & s, const P & p, const Pn & ... pn) { + // NOLINTNEXTLINE(bugprone-string-constructor) std::string d(dashes, '-'); s << d << "( " << p << " )" << d; StreamWriter::next(s, pn...); @@ -301,6 +302,7 @@ BOOST_AUTO_TEST_CASE( filestar ) size_t len = 0; FILE * strm = open_memstream(&buf, &len); BOOST_REQUIRE(strm); + // NOLINTNEXTLINE(misc-non-copyable-objects) Formatter<formatStringMulti>::write(*strm, "file", "star"); fclose(strm); BOOST_CHECK_EQUAL(len, 22); diff --git a/libadhocutil/unittests/testFileUtils.cpp b/libadhocutil/unittests/testFileUtils.cpp index 0dd61a7..2a823df 100644 --- a/libadhocutil/unittests/testFileUtils.cpp +++ b/libadhocutil/unittests/testFileUtils.cpp @@ -44,15 +44,15 @@ T moveTest(P ... p) return fh; } -class X { +class Base { public: - X(AdHoc::FileUtils::FileHandle h) : fh(std::move(h)) { } + Base(AdHoc::FileUtils::FileHandle h) : fh(std::move(h)) { } AdHoc::FileUtils::FileHandle fh; }; -class Y : public X { +class Sub : public Base { public: - Y(AdHoc::FileUtils::FileHandle h) : X(std::move(h)) { } + Sub(AdHoc::FileUtils::FileHandle h) : Base(std::move(h)) { } }; BOOST_AUTO_TEST_CASE( movePassThrough ) @@ -60,9 +60,10 @@ BOOST_AUTO_TEST_CASE( movePassThrough ) auto f = openfh<AdHoc::FileUtils::FileHandle>(); int ffd = f.fh; REQUIRE_VALID_FH(f.fh); - auto y = std::make_unique<Y>(std::move(f)); + auto y = std::make_unique<Sub>(std::move(f)); BOOST_REQUIRE_EQUAL(y->fh, ffd); REQUIRE_VALID_FH(y->fh); + // NOLINTNEXTLINE(bugprone-use-after-move) BOOST_REQUIRE_EQUAL(f.fh, -1); REQUIRE_INVALID_FH(f.fh); y.reset(); diff --git a/libadhocutil/unittests/testResourcePool.cpp b/libadhocutil/unittests/testResourcePool.cpp index ddbd57b..a7837b8 100644 --- a/libadhocutil/unittests/testResourcePool.cpp +++ b/libadhocutil/unittests/testResourcePool.cpp @@ -151,6 +151,7 @@ BOOST_AUTO_TEST_CASE( discard ) TRP pool; try { auto r1 = pool.get(); + BOOST_REQUIRE(r1); BOOST_REQUIRE_EQUAL(0, pool.availableCount()); BOOST_REQUIRE_EQUAL(1, pool.inUseCount()); throw std::exception(); diff --git a/libadhocutil/uriParse.cpp b/libadhocutil/uriParse.cpp index c42f133..2419bb6 100644 --- a/libadhocutil/uriParse.cpp +++ b/libadhocutil/uriParse.cpp @@ -168,7 +168,6 @@ namespace AdHoc { } len = tmpstr - curstr; puri->fragment = std::string(curstr, len); - curstr = tmpstr; } } |