diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-04-15 15:36:06 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-04-15 15:38:25 +0100 |
commit | 081f4a7fcb1a0701887b5e09c0ed5f0656c71fd3 (patch) | |
tree | de75b49c54c234a588b7e159c576a2790d7aeef0 /netfs/fuse | |
parent | Safe numeric conversions (diff) | |
download | netfs-081f4a7fcb1a0701887b5e09c0ed5f0656c71fd3.tar.bz2 netfs-081f4a7fcb1a0701887b5e09c0ed5f0656c71fd3.tar.xz netfs-081f4a7fcb1a0701887b5e09c0ed5f0656c71fd3.zip |
Enable and fixup all conversion/cast warnings
Diffstat (limited to 'netfs/fuse')
-rw-r--r-- | netfs/fuse/fuseApp.h | 15 | ||||
-rw-r--r-- | netfs/fuse/fuseDirs.cpp | 4 | ||||
-rw-r--r-- | netfs/fuse/fuseFiles.cpp | 8 | ||||
-rw-r--r-- | netfs/fuse/fuseMappersImpl.cpp | 9 |
4 files changed, 19 insertions, 17 deletions
diff --git a/netfs/fuse/fuseApp.h b/netfs/fuse/fuseApp.h index 187e2ba..5652a41 100644 --- a/netfs/fuse/fuseApp.h +++ b/netfs/fuse/fuseApp.h @@ -18,13 +18,14 @@ namespace NetFS { class DLL_PUBLIC FuseApp : public FuseAppBaseT<FuseApp> { private: + using FuseHandleTypeId = decltype(fuse_file_info::fh); class OpenDir; using OpenDirPtr = std::shared_ptr<OpenDir>; - using OpenDirs = std::map<int, OpenDirPtr>; + using OpenDirs = std::map<FuseHandleTypeId, OpenDirPtr>; class OpenFile; using OpenFilePtr = std::shared_ptr<OpenFile>; - using OpenFiles = std::map<int, OpenFilePtr>; + using OpenFiles = std::map<FuseHandleTypeId, OpenFilePtr>; public: explicit FuseApp(Ice::StringSeq &&); @@ -85,10 +86,10 @@ namespace NetFS { static NetFS::Client::ResourcePtr configureFromUri(const std::string &); protected: - template<typename Handle, typename... Params> void setProxy(uint64_t & fh, const Params &...); - template<typename Handle> Handle getProxy(uint64_t localID); - template<typename Handle> void clearProxy(uint64_t localID); - template<typename Handle> std::map<int, Handle> & getMap(); + template<typename Handle, typename... Params> void setProxy(FuseHandleTypeId & fh, const Params &...); + template<typename Handle> Handle getProxy(FuseHandleTypeId localID); + template<typename Handle> void clearProxy(FuseHandleTypeId localID); + template<typename Handle> std::map<FuseHandleTypeId, Handle> & getMap(); template<typename Rtn, typename F> static inline Rtn waitOnWriteRangeAndThen(size_t s, off_t o, const OpenFilePtr & of, const F & f); @@ -109,7 +110,7 @@ namespace NetFS { OpenDirs openDirs; OpenFiles openFiles; - int openHandleId {0}; + FuseHandleTypeId openHandleId {}; EntryTypeConverter converter; diff --git a/netfs/fuse/fuseDirs.cpp b/netfs/fuse/fuseDirs.cpp index bc13cd1..a4fa233 100644 --- a/netfs/fuse/fuseDirs.cpp +++ b/netfs/fuse/fuseDirs.cpp @@ -7,7 +7,7 @@ namespace NetFS { FuseApp::OpenDir::OpenDir(DirectoryPrxPtr r, std::string p) : remote(std::move(r)), path(std::move(p)) { } template<> - std::map<int, FuseApp::OpenDirPtr> & + std::map<FuseApp::FuseHandleTypeId, FuseApp::OpenDirPtr> & FuseApp::getMap<FuseApp::OpenDirPtr>() { return openDirs; @@ -62,7 +62,7 @@ namespace NetFS { else { // Standard read dir cannot know the local system cannot represent the inode for (const auto & e : od->remote->readdir()) { - filler(buf, e.c_str(), nullptr, 0, (fuse_fill_dir_flags)0); + filler(buf, e.c_str(), nullptr, 0, fuse_fill_dir_flags {}); } } return 0; diff --git a/netfs/fuse/fuseFiles.cpp b/netfs/fuse/fuseFiles.cpp index 3d23338..1ab568c 100644 --- a/netfs/fuse/fuseFiles.cpp +++ b/netfs/fuse/fuseFiles.cpp @@ -14,7 +14,7 @@ namespace NetFS { } template<> - std::map<int, FuseApp::OpenFilePtr> & + std::map<FuseApp::FuseHandleTypeId, FuseApp::OpenFilePtr> & FuseApp::getMap<FuseApp::OpenFilePtr>() { return openFiles; @@ -48,7 +48,7 @@ namespace NetFS { FuseApp::OpenFile::BGs::interval_type FuseApp::OpenFile::range(off_t o, size_t s) { - return OpenFile::BGs::interval_type::right_open(o, o + s); + return OpenFile::BGs::interval_type::right_open(safe {o}, safe {o} + s); } int @@ -125,7 +125,7 @@ namespace NetFS { } else { std::vector<std::shared_ptr<OpenFile::WriteState>> overlap; - overlap.reserve(std::distance(R.first, R.second)); + overlap.reserve(safe {std::distance(R.first, R.second)}); for (auto i = R.first; i != R.second; i++) { overlap.push_back(i->second); } @@ -175,7 +175,7 @@ namespace NetFS { waitOnWriteRangeAndThen<void>(s, o, of, [o, s, buf, &of, remote](const auto & key) { auto p = std::make_shared<OpenFile::WriteState>(); remote->writeAsync( - o, s, Buffer(buf, buf + s), + o, safe {s}, Buffer(buf, buf + s), [p, of, key]() { p->promise.set_value(); ScopeLock(of->_lock) { diff --git a/netfs/fuse/fuseMappersImpl.cpp b/netfs/fuse/fuseMappersImpl.cpp index c7fef9e..7e129f6 100644 --- a/netfs/fuse/fuseMappersImpl.cpp +++ b/netfs/fuse/fuseMappersImpl.cpp @@ -1,5 +1,6 @@ #include "fuseMappersImpl.h" #include <entCache.h> +#include <numeric.h> namespace NetFS::Client { constexpr int MASK_EVERYTHING = ~0; @@ -19,8 +20,8 @@ namespace NetFS::Client { Mapping::Transport HideUnknownMapperImpl::mapFileSystem(int uid, int gid) { - auto u = users->getEntry(uid); - auto g = groups->getEntry(gid); + auto u = users->getEntry(safe {uid}); + auto g = groups->getEntry(safe {gid}); if (!u || !g) { throw NetFS::SystemError(EPERM); } @@ -50,8 +51,8 @@ namespace NetFS::Client { Mapping::Transport MaskUnknownMapperImpl::mapFileSystem(int uid, int gid) { - auto u = users->getEntry(uid); - auto g = groups->getEntry(gid); + auto u = users->getEntry(safe {uid}); + auto g = groups->getEntry(safe {gid}); if (!u || !g) { throw NetFS::SystemError(EPERM); } |