From 4ac149951b2020b4a6dafb0455d3f523e7c9cfe6 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 15 Feb 2022 17:34:51 +0000 Subject: Fix up all warnings from all the tools --- Jamroot.jam | 20 ++++++++++++++++++++ iwyu.json | 18 ++++++++++++++++++ src/blob.cpp | 13 ++++++++++--- src/blob.h | 9 ++++++++- src/dir.cpp | 13 +++++++++++-- src/dir.h | 6 ++++++ src/git.cpp | 5 +++-- src/git.h | 4 +++- src/main.cpp | 6 ++++++ src/repo.cpp | 11 +++++++++++ src/repo.h | 13 ++++++++++++- src/repoList.cpp | 7 ++++++- src/repoList.h | 5 +++++ unittests/config.cpp | 12 +++++++++++- unittests/core.cpp | 18 +++++++++++++++--- unittests/mockDefs.cpp | 9 ++++++++- unittests/mockDefs.h | 2 ++ unittests/service.cpp | 11 ++++++++++- 18 files changed, 165 insertions(+), 17 deletions(-) create mode 100644 iwyu.json diff --git a/Jamroot.jam b/Jamroot.jam index cfb1fe7..406c095 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -13,8 +13,25 @@ project debug:extra debug:on coverage:on + debug:-Wnon-virtual-dtor + debug:-Wold-style-cast + debug:-Wcast-align + debug:-Wunused + debug:-Woverloaded-virtual + debug:-Wpedantic + debug:-Wconversion + debug:-Wsign-conversion + debug:-Wnull-dereference + debug:-Wdouble-promotion + debug:-Wformat=2 + gcc,debug:-Wduplicated-cond + gcc,debug:-Wduplicated-branches + gcc,debug:-Wlogical-op + gcc,debug:-Wuseless-cast tidy:boost-* tidy:bugprone-* + tidy:bugprone-easily-swappable-parameters + tidy:bugprone-implicit-widening-of-multiplication-result tidy:clang-* tidy:misc-* tidy:modernize-* @@ -24,6 +41,9 @@ project tidy:hicpp-signed-bitwise tidy:hicpp-named-parameter tidy:performance-* + tidy:iwyu.json + tidy:boost + tidy:std ; lib adhocutil : : : : /usr/include/adhocutil ; diff --git a/iwyu.json b/iwyu.json new file mode 100644 index 0000000..7e89cdd --- /dev/null +++ b/iwyu.json @@ -0,0 +1,18 @@ +[ + { + "include": [ + "@", + "private", + "", + "public" + ] + }, + { + "include": [ + "@", + "private", + "", + "public" + ] + } +] diff --git a/src/blob.cpp b/src/blob.cpp index e3483b8..a5482df 100644 --- a/src/blob.cpp +++ b/src/blob.cpp @@ -1,7 +1,14 @@ #include "blob.h" #include "repo.h" +#include #include +#include +#include +#include +#include +#include #include +#include GitFS::Blob::Blob(const Repo * const r, std::string && path) : repo(r), entry(Git::TreeEntryByPath(repo->tree, path)), blob(getBlob()), blobSize(git_blob_rawsize(blob.get())), @@ -43,13 +50,13 @@ GitFS::Blob::fgetattr(ReqEnv, const ::Ice::Current &) NetFS::Buffer GitFS::Blob::read(long long int o, long long int s, const ::Ice::Current &) { - const decltype(blobSize) offset(o); - const decltype(blobSize) size(s); + const auto offset {static_cast(o)}; + const auto size {static_cast(s)}; if (offset > blobSize) { return {}; } auto len = std::min(blobSize - offset, size); - return NetFS::Buffer(blobContent + offset, blobContent + offset + len); + return {blobContent + offset, blobContent + offset + len}; } void diff --git a/src/blob.h b/src/blob.h index b873299..24e8c6f 100644 --- a/src/blob.h +++ b/src/blob.h @@ -3,6 +3,12 @@ #include "git.h" #include +#include +#include +#include +namespace Ice { + struct Current; +} namespace GitFS { using namespace NetFS; @@ -24,7 +30,8 @@ namespace GitFS { const Repo * const repo; Git::TreeEntryPtr entry; Git::BlobPtr blob; - const decltype(git_blob_rawsize({})) blobSize; + using BlobSize = decltype(git_blob_rawsize({})); + const BlobSize blobSize; const char * const blobContent; }; } diff --git a/src/dir.cpp b/src/dir.cpp index 9e524aa..f502c45 100644 --- a/src/dir.cpp +++ b/src/dir.cpp @@ -1,7 +1,16 @@ #include "dir.h" +#include "git.h" #include "repo.h" +#include #include +#include +#include +#include +#include +#include #include +#include +#include GitFS::Directory::Directory(Repo * const r, std::string && p) : repo(r), path(std::move(p)), subTreeCacheRootId({}) { @@ -39,7 +48,7 @@ GitFS::Directory::readdir(const ::Ice::Current &) { const auto subTree = getSubtree(); NetFS::NameList list; - for (int idx = git_tree_entrycount(subTree.get()); idx--;) { + for (auto idx = git_tree_entrycount(subTree.get()); idx--;) { const auto entry = git_tree_entry_byindex(subTree.get(), idx); list.push_back(git_tree_entry_name(entry)); } @@ -51,7 +60,7 @@ GitFS::Directory::listdir(const ::Ice::Current &) { const auto subTree = getSubtree(); NetFS::DirectoryContents list; - for (int idx = git_tree_entrycount(subTree.get()); idx--;) { + for (auto idx = git_tree_entrycount(subTree.get()); idx--;) { const auto entry = git_tree_entry_byindex(subTree.get(), idx); NetFS::Attr a {}; a << *entry << *repo->commit; diff --git a/src/dir.h b/src/dir.h index 91d9ddd..626d80f 100644 --- a/src/dir.h +++ b/src/dir.h @@ -3,6 +3,12 @@ #include "git.h" #include +#include +#include +#include +namespace Ice { + struct Current; +} namespace GitFS { using namespace NetFS; diff --git a/src/git.cpp b/src/git.cpp index 1c9da62..e6aed3f 100644 --- a/src/git.cpp +++ b/src/git.cpp @@ -1,6 +1,7 @@ #include "git.h" +#include +#include #include -#include #include #include @@ -99,7 +100,7 @@ namespace NetFS { operator<<(Attr & a, const git_blob & b) { a.blockSize = 1; - a.blocks = a.size = git_blob_rawsize(&b); + a.blocks = a.size = static_cast(git_blob_rawsize(&b)); return a; } } diff --git a/src/git.h b/src/git.h index 46bdb18..1dce92e 100644 --- a/src/git.h +++ b/src/git.h @@ -4,9 +4,11 @@ #include #include #include +#include +#include namespace GitFS::Git { - template[[noreturn]] void throwError(int err); + template [[noreturn]] void throwError(int err); template void diff --git a/src/main.cpp b/src/main.cpp index 91c6b15..7ee7dff 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,8 +1,14 @@ #include "repoList.h" +#include +#include +#include #include #include #include #include +#include +#include +#include namespace GitFS { class Main : public IceTray::Service { diff --git a/src/repo.cpp b/src/repo.cpp index 41e6f7d..2dca141 100644 --- a/src/repo.cpp +++ b/src/repo.cpp @@ -1,8 +1,19 @@ #include "repo.h" #include "blob.h" #include "dir.h" +#include #include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include std::string operator/(const std::string & a, const std::string & b) diff --git a/src/repo.h b/src/repo.h index 9a01c55..795dd87 100644 --- a/src/repo.h +++ b/src/repo.h @@ -2,8 +2,19 @@ #define GITFS_REPO_H #include "git.h" -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +namespace Ice { + struct Current; +} namespace GitFS { using namespace NetFS; diff --git a/src/repoList.cpp b/src/repoList.cpp index f66e019..2a50421 100644 --- a/src/repoList.cpp +++ b/src/repoList.cpp @@ -1,9 +1,14 @@ #include "repoList.h" #include "repo.h" +#include #include #include - +#include #include +#include +#include +#include +#include GitFS::RepoList::RepoList(Ice::PropertiesPtr && p) : properties(std::move(p)) { } diff --git a/src/repoList.h b/src/repoList.h index 2e876c2..d32f3b0 100644 --- a/src/repoList.h +++ b/src/repoList.h @@ -3,6 +3,11 @@ #include #include +#include +#include +namespace Ice { + struct Current; +} namespace GitFS { class RepoList : public NetFS::Service { diff --git a/unittests/config.cpp b/unittests/config.cpp index 20a025a..6e3f92c 100644 --- a/unittests/config.cpp +++ b/unittests/config.cpp @@ -1,10 +1,20 @@ #define BOOST_TEST_MODULE GitFS_Config -#include +#include // IWYU pragma: keep #include #include "mockDefs.h" #include #include +#include +#include +#include +#include +#include +#include +#include +namespace NetFS { + class ConfigError; +} using namespace GitFS; using namespace GitFS::Test; diff --git a/unittests/core.cpp b/unittests/core.cpp index 9cd7552..e64ae80 100644 --- a/unittests/core.cpp +++ b/unittests/core.cpp @@ -1,10 +1,22 @@ #define BOOST_TEST_MODULE GitFS_Core -#include +#include // IWYU pragma: keep #include #include "mockDefs.h" -#include "sys/fcntl.h" -#include "sys/stat.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace GitFS; using namespace GitFS::Test; diff --git a/unittests/mockDefs.cpp b/unittests/mockDefs.cpp index a257758..a144575 100644 --- a/unittests/mockDefs.cpp +++ b/unittests/mockDefs.cpp @@ -1,7 +1,14 @@ #include "mockDefs.h" -#include +#include // IWYU pragma: keep #include #include +#include +#include +#include +#include +#include +#include +// IWYU pragma: no_include using namespace AdHoc::literals; diff --git a/unittests/mockDefs.h b/unittests/mockDefs.h index 750a256..9efe187 100644 --- a/unittests/mockDefs.h +++ b/unittests/mockDefs.h @@ -3,7 +3,9 @@ #include #include +#include #include +#include namespace GitFS::Test { class DLL_PUBLIC Service : public IceTray::DryIce { diff --git a/unittests/service.cpp b/unittests/service.cpp index b1bab5a..e2829a6 100644 --- a/unittests/service.cpp +++ b/unittests/service.cpp @@ -1,10 +1,19 @@ #define BOOST_TEST_MODULE GitFS_Service -#include +#include // IWYU pragma: keep #include #include "mockDefs.h" #include #include +#include +#include +#include +#include +#include +namespace NetFS { + class AuthError; + class ConfigError; +} using namespace GitFS; using namespace GitFS::Test; -- cgit v1.2.3