summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan.goodliffe@octal.co.uk>2022-02-15 17:34:51 +0000
committerDan Goodliffe <dan.goodliffe@octal.co.uk>2022-02-15 17:34:51 +0000
commit4ac149951b2020b4a6dafb0455d3f523e7c9cfe6 (patch)
tree698d4471463b68bc16ce2f291a0eaab86bcb5e13
parentBump to C++20 for compat with other libs (diff)
downloadnetfs-gitfs-4ac149951b2020b4a6dafb0455d3f523e7c9cfe6.tar.bz2
netfs-gitfs-4ac149951b2020b4a6dafb0455d3f523e7c9cfe6.tar.xz
netfs-gitfs-4ac149951b2020b4a6dafb0455d3f523e7c9cfe6.zip
Fix up all warnings from all the toolsnetfs-gitfs-0.2.2
-rw-r--r--Jamroot.jam20
-rw-r--r--iwyu.json18
-rw-r--r--src/blob.cpp13
-rw-r--r--src/blob.h9
-rw-r--r--src/dir.cpp13
-rw-r--r--src/dir.h6
-rw-r--r--src/git.cpp5
-rw-r--r--src/git.h4
-rw-r--r--src/main.cpp6
-rw-r--r--src/repo.cpp11
-rw-r--r--src/repo.h13
-rw-r--r--src/repoList.cpp7
-rw-r--r--src/repoList.h5
-rw-r--r--unittests/config.cpp12
-rw-r--r--unittests/core.cpp18
-rw-r--r--unittests/mockDefs.cpp9
-rw-r--r--unittests/mockDefs.h2
-rw-r--r--unittests/service.cpp11
18 files changed, 165 insertions, 17 deletions
diff --git a/Jamroot.jam b/Jamroot.jam
index cfb1fe7..406c095 100644
--- a/Jamroot.jam
+++ b/Jamroot.jam
@@ -13,8 +13,25 @@ project
<variant>debug:<warnings>extra
<variant>debug:<warnings-as-errors>on
<variant>coverage:<coverage>on
+ <variant>debug:<cflags>-Wnon-virtual-dtor
+ <variant>debug:<cflags>-Wold-style-cast
+ <variant>debug:<cflags>-Wcast-align
+ <variant>debug:<cflags>-Wunused
+ <variant>debug:<cflags>-Woverloaded-virtual
+ <variant>debug:<cflags>-Wpedantic
+ <variant>debug:<cflags>-Wconversion
+ <variant>debug:<cflags>-Wsign-conversion
+ <variant>debug:<cflags>-Wnull-dereference
+ <variant>debug:<cflags>-Wdouble-promotion
+ <variant>debug:<cflags>-Wformat=2
+ <toolset>gcc,<variant>debug:<cflags>-Wduplicated-cond
+ <toolset>gcc,<variant>debug:<cflags>-Wduplicated-branches
+ <toolset>gcc,<variant>debug:<cflags>-Wlogical-op
+ <toolset>gcc,<variant>debug:<cflags>-Wuseless-cast
<toolset>tidy:<checkxx>boost-*
<toolset>tidy:<checkxx>bugprone-*
+ <toolset>tidy:<xcheckxx>bugprone-easily-swappable-parameters
+ <toolset>tidy:<xcheckxx>bugprone-implicit-widening-of-multiplication-result
<toolset>tidy:<checkxx>clang-*
<toolset>tidy:<checkxx>misc-*
<toolset>tidy:<checkxx>modernize-*
@@ -24,6 +41,9 @@ project
<toolset>tidy:<xcheckxx>hicpp-signed-bitwise
<toolset>tidy:<xcheckxx>hicpp-named-parameter
<toolset>tidy:<checkxx>performance-*
+ <toolset>tidy:<mapping>iwyu.json
+ <toolset>tidy:<librarydef>boost
+ <toolset>tidy:<librarydef>std
;
lib adhocutil : : : : <include>/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": [
+ "@<git2/.*\\.h>",
+ "private",
+ "<git2.h>",
+ "public"
+ ]
+ },
+ {
+ "include": [
+ "@<boost/.*>",
+ "private",
+ "<boost/test/unit_test.hpp>",
+ "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 <Ice/Current.h>
#include <Ice/ObjectAdapter.h>
+#include <algorithm>
+#include <cerrno>
+#include <exceptions.h>
+#include <file.h>
+#include <memory>
#include <sys/stat.h>
+#include <types.h>
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<BlobSize>(o)};
+ const auto size {static_cast<BlobSize>(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 <file.h>
+#include <git2.h>
+#include <string>
+#include <types.h>
+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 <Ice/Current.h>
#include <Ice/ObjectAdapter.h>
+#include <cerrno>
+#include <exceptions.h>
+#include <git2.h>
+#include <memory>
+#include <string>
#include <sys/stat.h>
+#include <types.h>
+#include <utility>
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 <directory.h>
+#include <git2.h>
+#include <string>
+#include <types.h>
+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 <array>
+#include <cerrno>
#include <exceptions.h>
-#include <execinfo.h>
#include <sys/stat.h>
#include <types.h>
@@ -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<decltype(Attr::blocks)>(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 <git2.h>
#include <memory>
#include <ostream>
+#include <string>
+#include <string_view>
namespace GitFS::Git {
- template<typename E>[[noreturn]] void throwError(int err);
+ template<typename E> [[noreturn]] void throwError(int err);
template<typename E, typename... P, typename... A>
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 <Ice/BuiltinSequences.h>
+#include <Ice/Communicator.h>
+#include <Ice/ObjectAdapter.h>
#include <factory.h>
#include <git2.h>
#include <icecube.h>
#include <icetrayService.h>
+#include <memory>
+#include <service.h>
+#include <string>
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 <Ice/Current.h>
#include <Ice/ObjectAdapter.h>
+#include <Ice/Proxy.h>
+#include <cerrno>
+#include <directory.h>
+#include <exceptions.h>
+#include <file.h>
+#include <git2.h>
+#include <memory>
#include <sys/stat.h>
+#include <types.h>
+#include <unistd.h>
+#include <utility>
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 <Ice/Properties.h>
+#include <Ice/Config.h>
+#include <Ice/Optional.h>
+#include <ctime>
+#include <directory.h>
+#include <file.h>
+#include <functional>
+#include <string>
+#include <string_view>
+#include <types.h>
#include <volume.h>
+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 <Ice/Current.h>
#include <Ice/ObjectAdapter.h>
#include <Ice/Properties.h>
-
+#include <Ice/Proxy.h>
#include <compileTimeFormatter.h>
+#include <exceptions.h>
+#include <memory>
+#include <utility>
+#include <volume.h>
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 <Ice/Properties.h>
#include <service.h>
+#include <string>
+#include <volume.h>
+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 <boost/test/data/test_case.hpp>
+#include <boost/test/data/test_case.hpp> // IWYU pragma: keep
#include <boost/test/unit_test.hpp>
#include "mockDefs.h"
#include <compileTimeFormatter.h>
#include <definedDirs.h>
+#include <dryice.h>
+#include <filesystem>
+#include <map>
+#include <memory>
+#include <service.h>
+#include <string>
+#include <volume.h>
+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 <boost/test/data/test_case.hpp>
+#include <boost/test/data/test_case.hpp> // IWYU pragma: keep
#include <boost/test/unit_test.hpp>
#include "mockDefs.h"
-#include "sys/fcntl.h"
-#include "sys/stat.h"
+#include <algorithm>
+#include <cerrno>
+#include <cstdio>
+#include <exceptions.h>
+#include <fcntl.h>
+#include <map>
+#include <memory>
+#include <ostream>
+#include <string>
+#include <sys/stat.h>
+#include <tuple>
+#include <unistd.h>
+#include <vector>
+#include <volume.h>
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 <boost/test/test_tools.hpp>
+#include <boost/test/test_tools.hpp> // IWYU pragma: keep
#include <compileTimeFormatter.h>
#include <definedDirs.h>
+#include <dryice.h>
+#include <filesystem>
+#include <memory>
+#include <service.h>
+#include <string>
+#include <volume.h>
+// IWYU pragma: no_include <boost/test/unit_test.hpp>
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 <dryice.h>
#include <service.h>
+#include <types.h>
#include <visibility.h>
+#include <volume.h>
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 <boost/test/data/test_case.hpp>
+#include <boost/test/data/test_case.hpp> // IWYU pragma: keep
#include <boost/test/unit_test.hpp>
#include "mockDefs.h"
#include <compileTimeFormatter.h>
#include <definedDirs.h>
+#include <dryice.h>
+#include <filesystem>
+#include <memory>
+#include <service.h>
+#include <string>
+namespace NetFS {
+ class AuthError;
+ class ConfigError;
+}
using namespace GitFS;
using namespace GitFS::Test;