summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2020-03-29 11:29:42 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2020-03-29 11:29:42 +0100
commitc830a78d7bae91619561c4e86b39572837453bbc (patch)
tree3f9c41825752f945dcfc10f7026c27d91b57d9dd
parentImplement copy range (diff)
downloadnetfs-c830a78d7bae91619561c4e86b39572837453bbc.tar.bz2
netfs-c830a78d7bae91619561c4e86b39572837453bbc.tar.xz
netfs-c830a78d7bae91619561c4e86b39572837453bbc.zip
Modernize and tidy
-rw-r--r--Jamroot.jam9
-rw-r--r--netfs/daemon/daemon.h11
-rw-r--r--netfs/daemon/daemonDirectory.h6
-rw-r--r--netfs/daemon/daemonFile.h12
-rw-r--r--netfs/daemon/daemonService.h4
-rw-r--r--netfs/daemon/daemonVolume.h38
-rw-r--r--netfs/daemon/modeCheck.h6
-rw-r--r--netfs/fuse/fuseApp.h21
-rw-r--r--netfs/fuse/fuseAppBase.h16
-rw-r--r--netfs/unittests/mockDaemon.h2
-rw-r--r--netfs/unittests/mockFuse.cpp1
-rw-r--r--netfs/unittests/testEdgeCases.cpp2
12 files changed, 73 insertions, 55 deletions
diff --git a/Jamroot.jam b/Jamroot.jam
index 69a042f..1dd6e98 100644
--- a/Jamroot.jam
+++ b/Jamroot.jam
@@ -26,11 +26,20 @@ project
<toolset>tidy:<checkxx>misc-*
<toolset>tidy:<checkxx>modernize-*
<toolset>tidy:<xcheckxx>modernize-use-trailing-return-type
+ <toolset>tidy:<xcheckxx>misc-non-private-member-variables-in-classes
<toolset>tidy:<checkxx>hicpp-*
<toolset>tidy:<xcheckxx>hicpp-vararg
<toolset>tidy:<xcheckxx>hicpp-signed-bitwise
<toolset>tidy:<xcheckxx>hicpp-no-array-decay
<toolset>tidy:<checkxx>performance-*
+ <toolset>tidy:<exclude>daemonConfig.h
+ <toolset>tidy:<exclude>fuseConfig.h
+ <toolset>tidy:<exclude>directory.h
+ <toolset>tidy:<exclude>exceptions.h
+ <toolset>tidy:<exclude>file.h
+ <toolset>tidy:<exclude>service.h
+ <toolset>tidy:<exclude>types.h
+ <toolset>tidy:<exclude>volume.h
;
build-project netfs ;
diff --git a/netfs/daemon/daemon.h b/netfs/daemon/daemon.h
index bc12973..cea9643 100644
--- a/netfs/daemon/daemon.h
+++ b/netfs/daemon/daemon.h
@@ -6,16 +6,19 @@
#include <daemonConfig.h>
#include <filesystem>
#include <visibility.h>
+#include <c++11Helpers.h>
class DLL_PUBLIC NetFSDaemon : public IceBox::Service {
public:
- virtual ~NetFSDaemon();
+ NetFSDaemon() = default;
+ SPECIAL_MEMBERS_MOVE_RO(NetFSDaemon);
+ ~NetFSDaemon() override;
- virtual void start(const std::string&, const Ice::CommunicatorPtr&, const Ice::StringSeq&) override;
- virtual void stop() override;
+ void start(const std::string&, const Ice::CommunicatorPtr&, const Ice::StringSeq&) override;
+ void stop() override;
protected:
- virtual NetFS::Daemon::ConfigurationPtr ReadConfiguration(const std::filesystem::path & path) const;
+ [[nodiscard]] virtual NetFS::Daemon::ConfigurationPtr ReadConfiguration(const std::filesystem::path & path) const;
private:
void LoadConfiguration(const std::filesystem::path & path);
diff --git a/netfs/daemon/daemonDirectory.h b/netfs/daemon/daemonDirectory.h
index d0f4e9d..e74f5dc 100644
--- a/netfs/daemon/daemonDirectory.h
+++ b/netfs/daemon/daemonDirectory.h
@@ -9,9 +9,9 @@ class DirectoryServer : public NetFS::Directory, EntryTypeConverter {
public:
DirectoryServer(DIR * od, EntryTypeConverter &);
- virtual void close(const Ice::Current&) override;
- virtual NetFS::NameList readdir(const Ice::Current&) override;
- virtual NetFS::DirectoryContents listdir(const Ice::Current&) override;
+ void close(const Ice::Current&) override;
+ NetFS::NameList readdir(const Ice::Current&) override;
+ NetFS::DirectoryContents listdir(const Ice::Current&) override;
private:
DIR * od;
diff --git a/netfs/daemon/daemonFile.h b/netfs/daemon/daemonFile.h
index d61e37d..7c4c121 100644
--- a/netfs/daemon/daemonFile.h
+++ b/netfs/daemon/daemonFile.h
@@ -8,13 +8,13 @@ class FileServer : public NetFS::File, EntryTypeConverter {
public:
FileServer(int fd, EntryTypeConverter &);
- virtual void close(const Ice::Current&) override;
- virtual void ftruncate(const NetFS::ReqEnv, Ice::Long size, const Ice::Current&) override;
- virtual NetFS::Attr fgetattr(const NetFS::ReqEnv, const Ice::Current&) override;
+ void close(const Ice::Current&) override;
+ void ftruncate(const NetFS::ReqEnv, Ice::Long size, const Ice::Current&) override;
+ NetFS::Attr fgetattr(const NetFS::ReqEnv, const Ice::Current&) override;
- virtual NetFS::Buffer read(Ice::Long offset, Ice::Long size, const Ice::Current&) override;
- virtual void write(Ice::Long offset, Ice::Long size, const NetFS::Buffer data, const Ice::Current&) override;
- virtual Ice::Long copyrange(NetFS::FilePrxPtr, Ice::Long, Ice::Long, Ice::Long, Ice::Int, const Ice::Current&) override;
+ NetFS::Buffer read(Ice::Long offset, Ice::Long size, const Ice::Current&) override;
+ void write(Ice::Long offset, Ice::Long size, const NetFS::Buffer data, const Ice::Current&) override;
+ Ice::Long copyrange(NetFS::FilePrxPtr, Ice::Long, Ice::Long, Ice::Long, Ice::Int, const Ice::Current&) override;
private:
const int fd;
diff --git a/netfs/daemon/daemonService.h b/netfs/daemon/daemonService.h
index d1c77b3..64ae45c 100644
--- a/netfs/daemon/daemonService.h
+++ b/netfs/daemon/daemonService.h
@@ -8,9 +8,9 @@
class ServiceServer : public NetFS::Service {
public:
- ServiceServer(NetFS::Daemon::ConfigurationPtr c);
+ explicit ServiceServer(NetFS::Daemon::ConfigurationPtr c);
- virtual NetFS::VolumePrxPtr connect(const std::string share, const std::string auth, const Ice::Current&) override;
+ NetFS::VolumePrxPtr connect(const std::string share, const std::string auth, const Ice::Current&) override;
private:
EntCache<User> userLookup;
diff --git a/netfs/daemon/daemonVolume.h b/netfs/daemon/daemonVolume.h
index 235adf4..0f91f67 100644
--- a/netfs/daemon/daemonVolume.h
+++ b/netfs/daemon/daemonVolume.h
@@ -11,32 +11,32 @@ class VolumeServer : public NetFS::Volume {
public:
VolumeServer(const std::filesystem::path & root, const EntCache<User> &, const EntCache<Group> &);
- virtual NetFS::DirectoryPrxPtr opendir(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
+ NetFS::DirectoryPrxPtr opendir(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
- virtual void mkdir(const NetFS::ReqEnv, std::string path, Ice::Int id, const Ice::Current&) override;
- virtual void rmdir(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
+ void mkdir(const NetFS::ReqEnv, std::string path, Ice::Int id, const Ice::Current&) override;
+ void rmdir(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
- virtual void truncate(const NetFS::ReqEnv, std::string path, Ice::Long size, const Ice::Current&) override;
+ void truncate(const NetFS::ReqEnv, std::string path, Ice::Long size, const Ice::Current&) override;
- virtual void unlink(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
+ void unlink(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
- virtual NetFS::FilePrxPtr open(const NetFS::ReqEnv, std::string path, Ice::Int flags, const Ice::Current&) override;
- virtual NetFS::FilePrxPtr create(const NetFS::ReqEnv, std::string path, Ice::Int flags, Ice::Int mode, const Ice::Current&) override;
+ NetFS::FilePrxPtr open(const NetFS::ReqEnv, std::string path, Ice::Int flags, const Ice::Current&) override;
+ NetFS::FilePrxPtr create(const NetFS::ReqEnv, std::string path, Ice::Int flags, Ice::Int mode, const Ice::Current&) override;
- virtual NetFS::VFS statfs(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
+ NetFS::VFS statfs(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
- virtual Ice::Int access(const NetFS::ReqEnv, std::string path, Ice::Int mode, const Ice::Current&) override;
- virtual NetFS::Attr getattr(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
- virtual void mknod(const NetFS::ReqEnv, std::string path, Ice::Int mode, Ice::Int dev, const Ice::Current&) override;
- virtual void symlink(const NetFS::ReqEnv, const std::string path1, const std::string path2, const Ice::Current&) override;
- virtual void link(const NetFS::ReqEnv, std::string path1, std::string path2, const Ice::Current&) override;
- virtual void rename(const NetFS::ReqEnv, std::string path1, const std::string path2, const Ice::optional<Ice::Int>, const Ice::Current&) override;
- virtual std::string readlink(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
- virtual void chmod(const NetFS::ReqEnv, std::string path, Ice::Int mode, const Ice::Current&) override;
- virtual void chown(const NetFS::ReqEnv, std::string path, Ice::Int uid, Ice::Int gid, const Ice::Current&) override;
- virtual void utimens(const NetFS::ReqEnv, std::string path, Ice::Long, Ice::Long, Ice::Long, Ice::Long, const Ice::Current&) override;
+ Ice::Int access(const NetFS::ReqEnv, std::string path, Ice::Int mode, const Ice::Current&) override;
+ NetFS::Attr getattr(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
+ void mknod(const NetFS::ReqEnv, std::string path, Ice::Int mode, Ice::Int dev, const Ice::Current&) override;
+ void symlink(const NetFS::ReqEnv, const std::string path1, const std::string path2, const Ice::Current&) override;
+ void link(const NetFS::ReqEnv, std::string path1, std::string path2, const Ice::Current&) override;
+ void rename(const NetFS::ReqEnv, std::string path1, const std::string path2, const Ice::optional<Ice::Int>, const Ice::Current&) override;
+ std::string readlink(const NetFS::ReqEnv, std::string path, const Ice::Current&) override;
+ void chmod(const NetFS::ReqEnv, std::string path, Ice::Int mode, const Ice::Current&) override;
+ void chown(const NetFS::ReqEnv, std::string path, Ice::Int uid, Ice::Int gid, const Ice::Current&) override;
+ void utimens(const NetFS::ReqEnv, std::string path, Ice::Long, Ice::Long, Ice::Long, Ice::Long, const Ice::Current&) override;
- virtual void disconnect(const Ice::Current&) override;
+ void disconnect(const Ice::Current&) override;
protected:
inline std::filesystem::path resolvePath(std::string && path) const;
diff --git a/netfs/daemon/modeCheck.h b/netfs/daemon/modeCheck.h
index 78c1708..01e9ecb 100644
--- a/netfs/daemon/modeCheck.h
+++ b/netfs/daemon/modeCheck.h
@@ -20,9 +20,9 @@ class ModeCheck {
const gid_t myg;
const std::filesystem::path & root;
- bool ReadableBy(const struct stat &, uid_t u, gid_t g) const;
- bool WritableBy(const struct stat &, uid_t u, gid_t g) const;
- bool ExecutableBy(const struct stat &, uid_t u, gid_t g) const;
+ [[nodiscard]] bool ReadableBy(const struct stat &, uid_t u, gid_t g) const;
+ [[nodiscard]] bool WritableBy(const struct stat &, uid_t u, gid_t g) const;
+ [[nodiscard]] bool ExecutableBy(const struct stat &, uid_t u, gid_t g) const;
private:
static struct stat lstat(const std::filesystem::path &);
diff --git a/netfs/fuse/fuseApp.h b/netfs/fuse/fuseApp.h
index eec2932..b38c97c 100644
--- a/netfs/fuse/fuseApp.h
+++ b/netfs/fuse/fuseApp.h
@@ -13,6 +13,7 @@
#include "fuseConfig.h"
#include "cache.h"
#include <visibility.h>
+#include <c++11Helpers.h>
#include <boost/icl/interval_map.hpp>
namespace NetFS {
@@ -25,8 +26,8 @@ namespace NetFS {
DirectoryPrxPtr remote;
const std::string path;
};
- typedef std::shared_ptr<OpenDir> OpenDirPtr;
- typedef std::map<int, OpenDirPtr> OpenDirs;
+ using OpenDirPtr = std::shared_ptr<OpenDir>;
+ using OpenDirs = std::map<int, OpenDirPtr>;
class OpenFile {
public:
@@ -39,17 +40,18 @@ namespace NetFS {
const std::string path;
const int flags;
class WriteState;
- typedef boost::icl::interval_map<Ice::Long, std::shared_ptr<WriteState>> BGs;
+ using BGs = boost::icl::interval_map<Ice::Long, std::shared_ptr<WriteState>>;
static BGs::interval_type range(off_t, size_t);
BGs bg;
mutable std::shared_mutex _lock;
};
- typedef std::shared_ptr<OpenFile> OpenFilePtr;
- typedef std::map<int, OpenFilePtr> OpenFiles;
+ using OpenFilePtr = std::shared_ptr<OpenFile>;
+ using OpenFiles = std::map<int, OpenFilePtr>;
public:
- FuseApp(Ice::StringSeq &&);
- ~FuseApp();
+ explicit FuseApp(Ice::StringSeq &&);
+ SPECIAL_MEMBERS_DELETE(FuseApp);
+ ~FuseApp() override;
// lifecycle
void * init (struct fuse_conn_info * info, struct fuse_config * cfg) override;
@@ -73,6 +75,7 @@ namespace NetFS {
int rename(const char *, const char *, unsigned int) override;
int symlink(const char *, const char *) override;
int unlink(const char *) override;
+ // NOLINTNEXTLINE(hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
int utimens(const char *, const struct timespec tv[2], struct fuse_file_info *) override;
int mknod(const char *, mode_t, dev_t) override;
// dirs
@@ -93,7 +96,7 @@ namespace NetFS {
// fs
int statfs(const char *, struct statvfs *) override;
// stuff
- int onError(const std::exception & err) throw() override;
+ int onError(const std::exception & err) noexcept override;
void beforeOperation() override;
virtual struct fuse_context * fuse_get_context() = 0;
@@ -137,7 +140,7 @@ namespace NetFS {
EntCache<Group> groupLookup;
EntryTypeConverter converter;
- typedef AdHoc::Cache<struct stat, std::string> StatCache;
+ using StatCache = AdHoc::Cache<struct stat, std::string>;
StatCache statCache;
};
}
diff --git a/netfs/fuse/fuseAppBase.h b/netfs/fuse/fuseAppBase.h
index c73a476..2709671 100644
--- a/netfs/fuse/fuseAppBase.h
+++ b/netfs/fuse/fuseAppBase.h
@@ -4,17 +4,18 @@
#include <fuse.h>
#include <typeinfo>
#include <exception>
-#include <stdio.h>
-#include <errno.h>
+#include <cstdio>
+#include <cerrno>
#include <syslog.h>
#include <visibility.h>
-#include <buffer.h>
+#include <c++11Helpers.h>
#include <shared_mutex>
#include <lockHelpers.h>
class DLL_PUBLIC FuseAppBase {
public:
FuseAppBase();
+ SPECIAL_MEMBERS_DELETE(FuseAppBase);
virtual ~FuseAppBase();
virtual void * init (struct fuse_conn_info * info, struct fuse_config * cfg);
@@ -48,6 +49,7 @@ class DLL_PUBLIC FuseAppBase {
virtual int unlink(const char *);
virtual int write(const char *, const char *, size_t, off_t, struct fuse_file_info *);
virtual int lock(const char *, struct fuse_file_info *, int cmd, struct flock *);
+ // NOLINTNEXTLINE(hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
virtual int utimens(const char *, const struct timespec tv[2], struct fuse_file_info *);
virtual int bmap(const char *, size_t blocksize, uint64_t *idx);
virtual int ioctl(const char *, unsigned int cmd, void *arg, struct fuse_file_info *, unsigned int flags, void * data);
@@ -58,11 +60,11 @@ class DLL_PUBLIC FuseAppBase {
virtual int fallocate(const char *, int, off_t, off_t, struct fuse_file_info *);
virtual ssize_t copy_file_range(const char *, struct fuse_file_info *, off_t, const char *, struct fuse_file_info *, off_t, size_t, int);
virtual off_t lseek(const char *, off_t off, int whence, struct fuse_file_info *);
- virtual int onError(const std::exception & err) throw();
+ virtual int onError(const std::exception & err) noexcept;
virtual void beforeOperation();
- void log(int level, const char * message) const throw();
- void logf(int level, const char * fmt, ...) const throw() __attribute__ ((__format__ (__printf__, 3, 4)));
- virtual void vlogf(int level, const char * fmt, va_list) const throw() __attribute__ ((__format__ (__printf__, 3, 0))) = 0;
+ void log(int level, const char * message) const noexcept;
+ void logf(int level, const char * fmt, ...) const noexcept __attribute__ ((__format__ (__printf__, 3, 4)));
+ virtual void vlogf(int level, const char * fmt, va_list) const noexcept __attribute__ ((__format__ (__printf__, 3, 0))) = 0;
mutable std::shared_mutex _lock;
protected:
diff --git a/netfs/unittests/mockDaemon.h b/netfs/unittests/mockDaemon.h
index d7374c5..659d23c 100644
--- a/netfs/unittests/mockDaemon.h
+++ b/netfs/unittests/mockDaemon.h
@@ -14,7 +14,7 @@ class DLL_PUBLIC MockDaemon : public NetFSDaemon {
const std::string testEndpoint;
protected:
- virtual NetFS::Daemon::ConfigurationPtr ReadConfiguration(const std::filesystem::path &) const override;
+ NetFS::Daemon::ConfigurationPtr ReadConfiguration(const std::filesystem::path &) const override;
};
class DLL_PUBLIC MockDaemonHost {
diff --git a/netfs/unittests/mockFuse.cpp b/netfs/unittests/mockFuse.cpp
index 1b88027..8a85267 100644
--- a/netfs/unittests/mockFuse.cpp
+++ b/netfs/unittests/mockFuse.cpp
@@ -1,5 +1,6 @@
#include "mockFuse.h"
#include <boost/test/test_tools.hpp>
+#include <buffer.h>
FuseMock::FuseMock(std::string ep, Ice::StringSeq a) :
NetFS::FuseApp(std::move(a)),
diff --git a/netfs/unittests/testEdgeCases.cpp b/netfs/unittests/testEdgeCases.cpp
index 2c5aef6..b0d0098 100644
--- a/netfs/unittests/testEdgeCases.cpp
+++ b/netfs/unittests/testEdgeCases.cpp
@@ -113,7 +113,7 @@ BOOST_AUTO_TEST_CASE( manyThreads )
for (int x = 0; x < 20; x++) {
ths.emplace_back([&] {
struct statvfs s {};
- while(running) {
+ while(running && success < 1600) {
if (fuse.fuse->statfs("/", &s) == 0) {
success++;
}