From 97b1aae251a48af7b85eafd76e5284458d42f181 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 27 Oct 2019 12:01:06 +0000 Subject: Fixes for tidy --- src/repo.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 16 deletions(-) (limited to 'src/repo.cpp') diff --git a/src/repo.cpp b/src/repo.cpp index 634fe07..51f5fd1 100644 --- a/src/repo.cpp +++ b/src/repo.cpp @@ -48,17 +48,21 @@ GitFS::Repo::disconnect(const ::Ice::Current& current) NetFS::DirectoryPrxPtr GitFS::Repo::opendir(ReqEnv, ::std::string path, const ::Ice::Current& ice) { - if (path.empty()) throw NetFS::SystemError(EINVAL); + if (path.empty()) { + throw NetFS::SystemError(EINVAL); + } return Ice::uncheckedCast(ice.adapter->addWithUUID( - std::make_shared(this, path))); + std::make_shared(this, std::move(path)))); } NetFS::VFS GitFS::Repo::statfs(ReqEnv, ::std::string path, const ::Ice::Current&) { - if (path.empty()) throw NetFS::SystemError(EINVAL); + if (path.empty()) { + throw NetFS::SystemError(EINVAL); + } return {}; } @@ -67,19 +71,33 @@ GitFS::Repo::statfs(ReqEnv, ::std::string path, const ::Ice::Current&) int GitFS::Repo::access(ReqEnv, ::std::string path, int mode, const ::Ice::Current&) { - if (mode & W_OK) return EACCES; - if (path.empty()) return EINVAL; - if (path == "/") return 0; + if (mode & W_OK) { + return EACCES; + } + if (path.empty()) { + return EINVAL; + } + if (path == "/") { + return 0; + } try { update(); auto e = Git::TreeEntryByPath(tree, path); const auto emode = git_tree_entry_filemode(e.get()); - if (S_ISDIR(emode)) return 0; - if (S_ISLNK(emode)) return 0; - if (mode & R_OK && !(S_IRUSR & emode)) return EACCES; - if (mode & X_OK && !(S_IXUSR & emode)) return EACCES; + if (S_ISDIR(emode)) { + return 0; + } + if (S_ISLNK(emode)) { + return 0; + } + if (mode & R_OK && !(S_IRUSR & emode)) { + return EACCES; + } + if (mode & X_OK && !(S_IXUSR & emode)) { + return EACCES; + } return 0; } @@ -92,7 +110,9 @@ GitFS::Repo::access(ReqEnv, ::std::string path, int mode, const ::Ice::Current&) NetFS::Attr GitFS::Repo::getattr(ReqEnv, ::std::string path, const ::Ice::Current&) { - if (path.empty()) throw NetFS::SystemError(EINVAL); + if (path.empty()) { + throw NetFS::SystemError(EINVAL); + } NetFS::Attr a {}; if (path == "/") { @@ -117,11 +137,15 @@ GitFS::Repo::getattr(ReqEnv, ::std::string path, const ::Ice::Current&) ::std::string GitFS::Repo::readlink(ReqEnv, ::std::string path, const ::Ice::Current&) { - if (path.empty() || path == "/") throw NetFS::SystemError(EINVAL); + if (path.empty() || path == "/") { + throw NetFS::SystemError(EINVAL); + } update(); auto e = Git::TreeEntryByPath(tree, path); - if (!S_ISLNK(git_tree_entry_filemode(e.get()))) throw NetFS::SystemError(EINVAL); + if (!S_ISLNK(git_tree_entry_filemode(e.get()))) { + throw NetFS::SystemError(EINVAL); + } auto blob = Git::BlobLookup(repo, *git_tree_entry_id(e.get())); auto n = static_cast(git_blob_rawcontent(blob.get())); return { n, n + git_blob_rawsize(blob.get()) }; @@ -131,12 +155,16 @@ GitFS::Repo::readlink(ReqEnv, ::std::string path, const ::Ice::Current&) NetFS::FilePrxPtr GitFS::Repo::open(ReqEnv, ::std::string path, int, const ::Ice::Current& ice) { - if (path.empty()) throw NetFS::SystemError(EINVAL); - if (path == "/") throw NetFS::SystemError(EISDIR); + if (path.empty()) { + throw NetFS::SystemError(EINVAL); + } + if (path == "/") { + throw NetFS::SystemError(EISDIR); + } update(); return Ice::uncheckedCast(ice.adapter->addWithUUID( - std::make_shared(this, path))); + std::make_shared(this, std::move(path)))); } -- cgit v1.2.3