summaryrefslogtreecommitdiff
path: root/netfs/fuse
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2019-03-31 19:11:31 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2019-03-31 19:11:31 +0100
commite0e9036430febb247a88afb5f567092421595a77 (patch)
tree0a58f60ce9d7c0c342cb1e97907f82da51654516 /netfs/fuse
parentExplicitly disable checker for generated code (diff)
downloadnetfs-e0e9036430febb247a88afb5f567092421595a77.tar.bz2
netfs-e0e9036430febb247a88afb5f567092421595a77.tar.xz
netfs-e0e9036430febb247a88afb5f567092421595a77.zip
First round of clang tidy changes
Diffstat (limited to 'netfs/fuse')
-rw-r--r--netfs/fuse/fuseApp.cpp18
-rw-r--r--netfs/fuse/fuseApp.h6
-rw-r--r--netfs/fuse/fuseAppBase.cpp29
-rw-r--r--netfs/fuse/fuseAppBase.h3
-rw-r--r--netfs/fuse/fuseDirs.cpp14
-rw-r--r--netfs/fuse/fuseFiles.cpp8
-rw-r--r--netfs/fuse/fuseMisc.cpp3
-rw-r--r--netfs/fuse/netfs.cpp5
8 files changed, 40 insertions, 46 deletions
diff --git a/netfs/fuse/fuseApp.cpp b/netfs/fuse/fuseApp.cpp
index 79fa0dd..ef1ca7f 100644
--- a/netfs/fuse/fuseApp.cpp
+++ b/netfs/fuse/fuseApp.cpp
@@ -1,5 +1,5 @@
#include <Glacier2/Router.h>
-#include <string.h>
+#include <cstring>
#include "fuseApp.h"
#include "lockHelpers.h"
#include "cache.impl.h"
@@ -14,8 +14,8 @@ namespace AdHoc {
template class CallCacheable<struct stat, std::string>;
}
-NetFS::FuseApp::FuseApp(const Ice::StringSeq & a) :
- iceArgs(a),
+NetFS::FuseApp::FuseApp(Ice::StringSeq a) :
+ iceArgs(std::move(a)),
sessionOpened(false),
openHandleId(0),
converter(userLookup, groupLookup)
@@ -77,7 +77,7 @@ NetFS::FuseApp::init(struct fuse_conn_info *)
{
ic = Ice::initialize(iceArgs);
fcr = configurator();
- return NULL;
+ return nullptr;
}
NetFS::Client::ResourcePtr
@@ -204,7 +204,7 @@ NetFS::FuseApp::verifyConnection()
session->ice_ping();
}
catch (const Ice::Exception &) {
- session = NULL;
+ session = nullptr;
sessionOpened = false;
}
}
@@ -213,7 +213,7 @@ NetFS::FuseApp::verifyConnection()
service->ice_ping();
}
catch (const Ice::Exception &) {
- service = NULL;
+ service = nullptr;
}
}
if (volume) {
@@ -221,13 +221,13 @@ NetFS::FuseApp::verifyConnection()
volume->ice_ping();
}
catch (const Ice::Exception &) {
- volume = NULL;
+ volume = nullptr;
}
}
}
int
-NetFS::FuseApp::onError(const std::exception & e) throw()
+NetFS::FuseApp::onError(const std::exception & e) noexcept
{
if (dynamic_cast<const Ice::SocketException *>(&e) || dynamic_cast<const Ice::TimeoutException *>(&e)) {
log(LOG_ERR, e.what());
@@ -245,7 +245,7 @@ NetFS::FuseApp::onError(const std::exception & e) throw()
}
if (dynamic_cast<const Ice::RequestFailedException *>(&e)) {
try {
- volume = NULL;
+ volume = nullptr;
connectToVolume();
connectHandles();
return 0;
diff --git a/netfs/fuse/fuseApp.h b/netfs/fuse/fuseApp.h
index 23738b3..df342b6 100644
--- a/netfs/fuse/fuseApp.h
+++ b/netfs/fuse/fuseApp.h
@@ -20,7 +20,7 @@ namespace NetFS {
private:
class OpenDir {
public:
- OpenDir(DirectoryPrxPtr remote, const std::string & path);
+ OpenDir(DirectoryPrxPtr remote, std::string path);
DirectoryPrxPtr remote;
DirectoryV2PrxPtr remoteV2;
@@ -31,7 +31,7 @@ namespace NetFS {
class OpenFile {
public:
- OpenFile(FilePrxPtr remote, const std::string & path, int flags);
+ OpenFile(FilePrxPtr remote, std::string path, int flags);
void flush();
void wait() const;
@@ -49,7 +49,7 @@ namespace NetFS {
typedef std::map<int, OpenFilePtr> OpenFiles;
public:
- FuseApp(const Ice::StringSeq &);
+ FuseApp(Ice::StringSeq);
~FuseApp();
private:
diff --git a/netfs/fuse/fuseAppBase.cpp b/netfs/fuse/fuseAppBase.cpp
index 3eadd8f..4485aec 100644
--- a/netfs/fuse/fuseAppBase.cpp
+++ b/netfs/fuse/fuseAppBase.cpp
@@ -1,19 +1,13 @@
#include "fuseAppBase.h"
-#include <errno.h>
-#include <assert.h>
-#include <stdio.h>
+#include <cerrno>
+#include <cassert>
+#include <cstdio>
#include <unistd.h>
-#include <stdlib.h>
+#include <cstdlib>
#include <typeinfo>
FuseAppBase * FuseAppBase::fuseApp;
-FuseAppBase::FuseAppBase()
-{
-}
-FuseAppBase::~FuseAppBase()
-{
-}
// LCOV_EXCL_START
// These are all excluded from coverage because it is impossible
// to call them in a realistic manner. They exist only as the default
@@ -21,7 +15,7 @@ FuseAppBase::~FuseAppBase()
// unless it is overridden.
void * FuseAppBase::init(fuse_conn_info*)
{
- return NULL;
+ return nullptr;
}
int FuseAppBase::opt_parse(void*, const char *, int, fuse_args*)
{
@@ -155,6 +149,7 @@ int FuseAppBase::lock(const char *, struct fuse_file_info *, int, struct flock *
{
return -ENOSYS;
}
+// NOLINTNEXTLINE(modernize-avoid-c-arrays)
int FuseAppBase::utimens(const char *, const struct timespec[2])
{
return -ENOSYS;
@@ -188,11 +183,11 @@ int FuseAppBase::fallocate(const char *, int, off_t, off_t, struct fuse_file_inf
return -ENOSYS;
}
// LCOV_EXCL_STOP
-void FuseAppBase::log(int level, const char * message) const throw()
+void FuseAppBase::log(int level, const char * message) const noexcept
{
logf(level, "%s", message);
}
-void FuseAppBase::logf(int level, const char * fmt, ...) const throw()
+void FuseAppBase::logf(int level, const char * fmt, ...) const noexcept
{
va_list args;
va_start(args, fmt);
@@ -200,7 +195,7 @@ void FuseAppBase::logf(int level, const char * fmt, ...) const throw()
va_end(args);
}
-int FuseAppBase::onError(const std::exception & e) throw()
+int FuseAppBase::onError(const std::exception & e) noexcept
{
logf(LOG_ERR, "Unknown exception (what: %s)", e.what());
return -ENOSYS;
@@ -222,12 +217,10 @@ void FuseAppBase::fuseDestroy(void *)
struct fuse_args
FuseAppBase::runint(int argc, char ** argv)
{
- struct fuse_opt fuse_opts[] = {
- { NULL, 0, 0 }
- };
+ std::array<fuse_opt, 1> fuse_opts {};
fuseApp = this;
struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
- if (fuse_opt_parse(&args, fuseApp, fuse_opts,
+ if (fuse_opt_parse(&args, fuseApp, fuse_opts.data(),
&internalHelper<decltype(&FuseAppBase::opt_parse), &FuseAppBase::opt_parse>) == -1) {
exit(1);
}
diff --git a/netfs/fuse/fuseAppBase.h b/netfs/fuse/fuseAppBase.h
index f0866bb..2775c00 100644
--- a/netfs/fuse/fuseAppBase.h
+++ b/netfs/fuse/fuseAppBase.h
@@ -15,8 +15,7 @@
class DLL_PUBLIC FuseAppBase {
public:
- FuseAppBase();
- virtual ~FuseAppBase() = 0;
+ virtual ~FuseAppBase() = default;
virtual void * init (struct fuse_conn_info * info);
virtual int opt_parse(void *, const char * arg, int key, struct fuse_args *);
virtual int access(const char *, int);
diff --git a/netfs/fuse/fuseDirs.cpp b/netfs/fuse/fuseDirs.cpp
index 3d77101..58dab8e 100644
--- a/netfs/fuse/fuseDirs.cpp
+++ b/netfs/fuse/fuseDirs.cpp
@@ -3,10 +3,10 @@
#include <entCache.h>
namespace NetFS {
-FuseApp::OpenDir::OpenDir(DirectoryPrxPtr r, const std::string & p) :
- remote(r),
- remoteV2(r->ice_getFacet() >= "v02" ? Ice::uncheckedCast<DirectoryV2Prx>(r) : nullptr),
- path(p)
+FuseApp::OpenDir::OpenDir(DirectoryPrxPtr r, std::string p) :
+ remote(std::move(r)),
+ remoteV2(remote->ice_getFacet() >= "v02" ? Ice::uncheckedCast<DirectoryV2Prx>(r) : nullptr),
+ path(std::move(p))
{
}
@@ -52,16 +52,16 @@ FuseApp::readdir(const char * p, void * buf, fuse_fill_dir_t filler, off_t, stru
auto od = getProxy<OpenDirPtr>(fi->fh);
std::string path(p);
path += "/";
- auto expiry = time(NULL) + 2;
+ auto expiry = time(nullptr) + 2;
if (fcr->ListDir && od->remoteV2) {
for (const auto & e : od->remoteV2->listdir()) {
- filler(buf, e.first.c_str(), NULL, 0);
+ filler(buf, e.first.c_str(), nullptr, 0);
statCache.add(path + e.first, converter.convert(e.second), expiry);
}
}
else {
for (const auto & e : od->remote->readdir()) {
- filler(buf, e.c_str(), NULL, 0);
+ filler(buf, e.c_str(), nullptr, 0);
}
}
return 0;
diff --git a/netfs/fuse/fuseFiles.cpp b/netfs/fuse/fuseFiles.cpp
index bbb7548..4ea7f47 100644
--- a/netfs/fuse/fuseFiles.cpp
+++ b/netfs/fuse/fuseFiles.cpp
@@ -1,4 +1,4 @@
-#include <string.h>
+#include <cstring>
#include "fuseApp.impl.h"
#include "fuseFiles.h"
#include "lockHelpers.h"
@@ -11,9 +11,9 @@ FuseApp::OpenFile::WriteState::WriteState() :
{
}
-FuseApp::OpenFile::OpenFile(FilePrxPtr r, const std::string & p, int f) :
- remote(r),
- path(p),
+FuseApp::OpenFile::OpenFile(FilePrxPtr r, std::string p, int f) :
+ remote(std::move(r)),
+ path(std::move(p)),
flags(f)
{
}
diff --git a/netfs/fuse/fuseMisc.cpp b/netfs/fuse/fuseMisc.cpp
index 5ece9a1..3d72f5c 100644
--- a/netfs/fuse/fuseMisc.cpp
+++ b/netfs/fuse/fuseMisc.cpp
@@ -1,5 +1,5 @@
#include "fuseApp.h"
-#include <string.h>
+#include <cstring>
#include <entCache.h>
int
@@ -113,6 +113,7 @@ NetFS::FuseApp::rename(const char * p1, const char * p2)
}
int
+// NOLINTNEXTLINE(modernize-avoid-c-arrays)
NetFS::FuseApp::utimens(const char * path, const struct timespec times[2])
{
try {
diff --git a/netfs/fuse/netfs.cpp b/netfs/fuse/netfs.cpp
index 2039eed..731327f 100644
--- a/netfs/fuse/netfs.cpp
+++ b/netfs/fuse/netfs.cpp
@@ -9,7 +9,7 @@ class FuseImpl : public NetFS::FuseApp {
openlog("netfs", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER);
}
- ~FuseImpl()
+ ~FuseImpl() override
{
closelog();
}
@@ -19,6 +19,7 @@ class FuseImpl : public NetFS::FuseApp {
return ::fuse_get_context();
}
+ // NOLINTNEXTLINE(modernize-avoid-c-arrays)
int fuse_opt_parse(struct fuse_args * args, void * data, const struct fuse_opt opts[], fuse_opt_proc_t proc) override
{
return ::fuse_opt_parse(args, data, opts, proc);
@@ -29,7 +30,7 @@ class FuseImpl : public NetFS::FuseApp {
return ::fuse_main(argc, argv, ops, this);
}
- void vlogf(int priority, const char * fmt, va_list args) const throw() override
+ void vlogf(int priority, const char * fmt, va_list args) const noexcept override
{
vsyslog(priority, fmt, args);
}