From 6c3ff01a0a9c6e18436a8af16091af1ebce994a0 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Mon, 10 Nov 2014 21:01:20 -0500 Subject: [PATCH] pass const strings by reference. closes #33 --- src/access.cpp | 2 +- src/category.cpp | 10 ++--- src/category.hpp | 14 +++---- src/chmod.cpp | 2 +- src/chown.cpp | 2 +- src/create.cpp | 2 +- src/fs.cpp | 92 +++++++++++++++++++++---------------------- src/fs.hpp | 84 +++++++++++++++++++-------------------- src/getattr.cpp | 2 +- src/getxattr.cpp | 4 +- src/ioctl.cpp | 4 +- src/link.cpp | 4 +- src/listxattr.cpp | 2 +- src/mergerfs.cpp | 1 - src/mkdir.cpp | 2 +- src/mknod.cpp | 2 +- src/open.cpp | 2 +- src/opendir.hpp | 4 +- src/option_parser.cpp | 2 +- src/policy.cpp | 2 +- src/policy.hpp | 14 +++---- src/readdir.cpp | 4 +- src/readdir.hpp | 6 +-- src/readlink.cpp | 4 +- src/releasedir.hpp | 4 +- src/removexattr.cpp | 2 +- src/rename.cpp | 4 +- src/rmdir.cpp | 2 +- src/rwlock.hpp | 10 +++-- src/setxattr.cpp | 34 ++++++++-------- src/str.cpp | 2 +- src/str.hpp | 12 +++--- src/symlink.cpp | 4 +- src/test.cpp | 55 -------------------------- src/test.hpp | 30 -------------- src/truncate.cpp | 2 +- src/unlink.cpp | 2 +- src/utimens.cpp | 8 ++-- 38 files changed, 181 insertions(+), 257 deletions(-) delete mode 100644 src/test.cpp delete mode 100644 src/test.hpp diff --git a/src/access.cpp b/src/access.cpp index 67033bec..3792801c 100644 --- a/src/access.cpp +++ b/src/access.cpp @@ -47,7 +47,7 @@ static int _access(const fs::SearchFunc searchFunc, const vector &srcmounts, - const string fusepath, + const string &fusepath, const int mask) { int rv; diff --git a/src/category.cpp b/src/category.cpp index dc8e1413..2c068345 100644 --- a/src/category.cpp +++ b/src/category.cpp @@ -38,16 +38,16 @@ namespace mergerfs (CATEGORY(action)) (CATEGORY(create)) (CATEGORY(search)); - + const Category * const Category::categories = &_categories_[1]; const Category &Category::invalid = Category::categories[Category::Enum::invalid]; const Category &Category::action = Category::categories[Category::Enum::action]; const Category &Category::create = Category::categories[Category::Enum::create]; - const Category &Category::search = Category::categories[Category::Enum::search]; - + const Category &Category::search = Category::categories[Category::Enum::search]; + const Category& - Category::find(const std::string str) + Category::find(const std::string &str) { for(int i = Enum::BEGIN; i != Enum::END; ++i) { @@ -66,5 +66,5 @@ namespace mergerfs return categories[i]; return invalid; - } + } } diff --git a/src/category.hpp b/src/category.hpp index a60a84a3..9b014e72 100644 --- a/src/category.hpp +++ b/src/category.hpp @@ -57,8 +57,8 @@ namespace mergerfs { } - Category(const Enum::Type enum_, - const std::string str_) + Category(const Enum::Type enum_, + const std::string &str_) : _enum(enum_), _str(str_) { @@ -66,15 +66,15 @@ namespace mergerfs public: operator const Enum::Type() const { return _enum; } - operator const std::string() const { return _str; } + operator const std::string&() const { return _str; } operator const Category*() const { return this; } - bool operator==(const std::string str_) const + bool operator==(const std::string &str_) const { return _str == str_; } bool operator==(const Enum::Type enum_) const - { return _enum == enum_; } - + { return _enum == enum_; } + bool operator!=(const Category &r) const { return _enum != r._enum; } @@ -82,7 +82,7 @@ namespace mergerfs { return _enum < r._enum; } public: - static const Category &find(const std::string); + static const Category &find(const std::string&); static const Category &find(const Enum::Type); public: diff --git a/src/chmod.cpp b/src/chmod.cpp index bd1f3466..c9fcd5fb 100644 --- a/src/chmod.cpp +++ b/src/chmod.cpp @@ -41,7 +41,7 @@ static int _chmod(const fs::SearchFunc searchFunc, const vector &srcmounts, - const string fusepath, + const string &fusepath, const mode_t mode) { int rv; diff --git a/src/chown.cpp b/src/chown.cpp index a05ad0c3..bb64f3e3 100644 --- a/src/chown.cpp +++ b/src/chown.cpp @@ -42,7 +42,7 @@ static int _chown(const fs::SearchFunc searchFunc, const vector &srcmounts, - const string fusepath, + const string &fusepath, const uid_t uid, const gid_t gid) { diff --git a/src/create.cpp b/src/create.cpp index 311389bd..978fa55b 100644 --- a/src/create.cpp +++ b/src/create.cpp @@ -48,7 +48,7 @@ int _create(const fs::SearchFunc searchFunc, const fs::SearchFunc createPathFunc, const vector &srcmounts, - const string fusepath, + const string &fusepath, const mode_t mode, const int flags, uint64_t &fh) diff --git a/src/fs.cpp b/src/fs.cpp index 17a81f17..d6619da6 100644 --- a/src/fs.cpp +++ b/src/fs.cpp @@ -65,7 +65,7 @@ random_element(Iter begin, namespace fs { string - dirname(const string path) + dirname(const string &path) { string parent = path; string::reverse_iterator i; @@ -88,13 +88,13 @@ namespace fs } string - basename(const string path) + basename(const string &path) { return path.substr(path.find_last_of('/')+1); } bool - dir_is_empty(const string path) + dir_is_empty(const string &path) { DIR *dir; struct dirent *de; @@ -123,8 +123,8 @@ namespace fs } string - make_path(const string base, - const string suffix) + make_path(const string &base, + const string &suffix) { if(suffix[0] == '/' || *base.rbegin() == '/') @@ -133,9 +133,9 @@ namespace fs } bool - path_exists(vector::const_iterator begin, - vector::const_iterator end, - const string fusepath) + path_exists(vector::const_iterator begin, + vector::const_iterator end, + const string &fusepath) { for(vector::const_iterator iter = begin; iter != end; ++iter) @@ -155,7 +155,7 @@ namespace fs bool path_exists(const vector &srcmounts, - const string fusepath) + const string &fusepath) { return path_exists(srcmounts.begin(), srcmounts.end(), @@ -163,7 +163,7 @@ namespace fs } int - listxattr(const string path, + listxattr(const string &path, vector &attrs) { #ifndef WITHOUT_XATTR @@ -187,7 +187,7 @@ namespace fs } int - listxattr(const string path, + listxattr(const string &path, vector &attrvector) { int rv; @@ -204,8 +204,8 @@ namespace fs } int - listxattr(const string path, - string &attrstr) + listxattr(const string &path, + string &attrstr) { int rv; vector attrs; @@ -218,8 +218,8 @@ namespace fs } int - getxattr(const string path, - const string attr, + getxattr(const string &path, + const string &attr, vector &value) { #ifndef WITHOUT_XATTR @@ -243,8 +243,8 @@ namespace fs } int - getxattr(const string path, - const string attr, + getxattr(const string &path, + const string &attr, string &value) { int rv; @@ -259,7 +259,7 @@ namespace fs int - getxattrs(const string path, + getxattrs(const string &path, map &attrs) { int rv; @@ -287,10 +287,10 @@ namespace fs } int - setxattr(const string path, - const string key, - const string value, - const int flags) + setxattr(const string &path, + const string &key, + const string &value, + const int flags) { #ifndef WITHOUT_XATTR return ::setxattr(path.c_str(), @@ -305,10 +305,10 @@ namespace fs } int - setxattr(const int fd, - const string key, - const string value, - const int flags) + setxattr(const int fd, + const string &key, + const string &value, + const int flags) { #ifndef WITHOUT_XATTR return ::fsetxattr(fd, @@ -323,7 +323,7 @@ namespace fs } int - setxattrs(const string path, + setxattrs(const string &path, const map &attrs) { int fd; @@ -342,8 +342,8 @@ namespace fs } int - copyxattrs(const string from, - const string to) + copyxattrs(const string &from, + const string &to) { int rv; map attrs; @@ -356,8 +356,8 @@ namespace fs } int - copyattr(const string from, - const string to) + copyattr(const string &from, + const string &to) { int fd; int rv; @@ -395,9 +395,9 @@ namespace fs } int - clonepath(const string fromsrc, - const string tosrc, - const string relative) + clonepath(const string &fromsrc, + const string &tosrc, + const string &relative) { int rv; struct stat st; @@ -492,7 +492,7 @@ namespace fs { int invalid(const vector &basepaths, - const string fusepath, + const string &fusepath, PathVector &paths) { return (errno = EINVAL,-1); @@ -500,7 +500,7 @@ namespace fs int ff(const vector &basepaths, - const string fusepath, + const string &fusepath, PathVector &paths) { errno = ENOENT; @@ -524,7 +524,7 @@ namespace fs int ffwp(const vector &basepaths, - const string fusepath, + const string &fusepath, PathVector &paths) { Path fallback; @@ -560,7 +560,7 @@ namespace fs int newest(const vector &basepaths, - const string fusepath, + const string &fusepath, PathVector &paths) { time_t newest; @@ -595,7 +595,7 @@ namespace fs int all(const vector &basepaths, - const string fusepath, + const string &fusepath, PathVector &paths) { errno = ENOENT; @@ -619,7 +619,7 @@ namespace fs int mfs(const vector &basepaths, - const string fusepath, + const string &fusepath, PathVector &paths) { fsblkcnt_t mfs; @@ -634,8 +634,8 @@ namespace fs ++iter) { int rv; - struct statvfs fsstats; - const string mountpoint = *iter; + struct statvfs fsstats; + const string &mountpoint = *iter; rv = ::statvfs(mountpoint.c_str(),&fsstats); if(rv == 0) @@ -663,7 +663,7 @@ namespace fs int epmfs(const vector &basepaths, - const string fusepath, + const string &fusepath, PathVector &paths) { fsblkcnt_t existingmfs = 0; @@ -680,8 +680,8 @@ namespace fs do { int rv; - struct statvfs fsstats; - const string mountpoint = *iter; + struct statvfs fsstats; + const string &mountpoint = *iter; rv = ::statvfs(mountpoint.c_str(),&fsstats); if(rv == 0) @@ -722,7 +722,7 @@ namespace fs int rand(const vector &basepaths, - const string fusepath, + const string &fusepath, PathVector &paths) { string randombasepath; diff --git a/src/fs.hpp b/src/fs.hpp index 113af2c2..d273bedc 100644 --- a/src/fs.hpp +++ b/src/fs.hpp @@ -38,8 +38,8 @@ namespace fs struct Path { Path() {} - Path(const string b, - const string f) + Path(const string &b, + const string &f) : base(b), full(f) {} @@ -49,60 +49,60 @@ namespace fs }; typedef vector PathVector; - typedef int (*SearchFunc)(const vector&,const string,PathVector&); + typedef int (*SearchFunc)(const vector&,const string&,PathVector&); - string dirname(const string path); - string basename(const string path); + string dirname(const string &path); + string basename(const string &path); - bool dir_is_empty(const string path); + bool dir_is_empty(const string &path); - string make_path(const string base, - const string suffix); + string make_path(const string &base, + const string &suffix); bool path_exists(vector::const_iterator begin, vector::const_iterator end, - const string fusepath); + const string &fusepath); bool path_exists(const vector &srcmounts, - const string fusepath); + const string &fusepath); - int clonepath(const string srcfrom, - const string srcto, - const string relative); + int clonepath(const string &srcfrom, + const string &srcto, + const string &relative); - int listxattr(const string path, + int listxattr(const string &path, vector &attrs); - int listxattr(const string path, + int listxattr(const string &path, string &attrs); - int listxattr(const string path, + int listxattr(const string &path, vector &attrs); - int getxattr(const string path, - const string attr, + int getxattr(const string &path, + const string &attr, vector &value); - int getxattr(const string path, - const string attr, + int getxattr(const string &path, + const string &attr, string &value); - int getxattrs(const string path, + int getxattrs(const string &path, map &attrs); - int setxattr(const string path, - const string key, - const string value, - const int flags); - int setxattr(const int fd, - const string key, - const string value, - const int flags); + int setxattr(const string &path, + const string &key, + const string &value, + const int flags); + int setxattr(const int fd, + const string &key, + const string &value, + const int flags); - int setxattrs(const string path, + int setxattrs(const string &path, const map &attrs); - int copyxattrs(const string from, - const string to); + int copyxattrs(const string &from, + const string &to); - int copyattr(const string from, - const string to); + int copyattr(const string &from, + const string &to); void glob(const vector &patterns, vector &strs); @@ -113,28 +113,28 @@ namespace fs namespace find { int invalid(const vector &basepaths, - const string fusepath, + const string &fusepath, PathVector &paths); int ff(const vector &basepaths, - const string fusepath, + const string &fusepath, PathVector &paths); int ffwp(const vector &paths, - const string fusepath, + const string &fusepath, PathVector &rv); int newest(const vector &paths, - const string fusepath, + const string &fusepath, PathVector &rv); int all(const vector &paths, - const string fusepath, + const string &fusepath, PathVector &rv); int mfs(const vector &paths, - const string fusepath, + const string &fusepath, PathVector &rv); int epmfs(const vector &paths, - const string fusepath, + const string &fusepath, PathVector &rv); int rand(const vector &paths, - const string fusepath, + const string &fusepath, PathVector &rv); } }; diff --git a/src/getattr.cpp b/src/getattr.cpp index 772f2884..93bc2e65 100644 --- a/src/getattr.cpp +++ b/src/getattr.cpp @@ -67,7 +67,7 @@ static int _getattr(const fs::SearchFunc searchFunc, const vector &srcmounts, - const string fusepath, + const string &fusepath, struct stat &buf) { int rv; diff --git a/src/getxattr.cpp b/src/getxattr.cpp index d58d83ef..f0ca8f23 100644 --- a/src/getxattr.cpp +++ b/src/getxattr.cpp @@ -45,7 +45,7 @@ using namespace mergerfs::config; static int _getxattr_controlfile(const Config &config, - const string attrname, + const string &attrname, char *buf, const size_t count) { @@ -100,7 +100,7 @@ static int _getxattr(const fs::SearchFunc searchFunc, const vector &srcmounts, - const string fusepath, + const string &fusepath, const char *attrname, char *buf, const size_t count) diff --git a/src/ioctl.cpp b/src/ioctl.cpp index b30b7c3f..6b289771 100644 --- a/src/ioctl.cpp +++ b/src/ioctl.cpp @@ -85,7 +85,7 @@ static int _ioctl_dir_base(const fs::SearchFunc searchFunc, const vector &srcmounts, - const string fusepath, + const string &fusepath, const int cmd, void *arg, const unsigned int flags, @@ -112,7 +112,7 @@ _ioctl_dir_base(const fs::SearchFunc searchFunc, static int -_ioctl_dir(const string fusepath, +_ioctl_dir(const string &fusepath, const int cmd, void *arg, const unsigned int flags, diff --git a/src/link.cpp b/src/link.cpp index 275b7a5f..13c0f893 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -43,8 +43,8 @@ static int _link(const fs::SearchFunc searchFunc, const vector &srcmounts, - const string from, - const string to) + const string &from, + const string &to) { int rv; int error; diff --git a/src/listxattr.cpp b/src/listxattr.cpp index ad25ccfd..b101d376 100644 --- a/src/listxattr.cpp +++ b/src/listxattr.cpp @@ -69,7 +69,7 @@ static int _listxattr(const fs::SearchFunc searchFunc, const vector &srcmounts, - const string fusepath, + const string &fusepath, char *list, const size_t size) { diff --git a/src/mergerfs.cpp b/src/mergerfs.cpp index 97abbddf..768e8ed7 100644 --- a/src/mergerfs.cpp +++ b/src/mergerfs.cpp @@ -32,7 +32,6 @@ #include "option_parser.hpp" #include "resources.hpp" #include "fs.hpp" -#include "test.hpp" #include "access.hpp" #include "chmod.hpp" diff --git a/src/mkdir.cpp b/src/mkdir.cpp index 34217737..a6b7dd13 100644 --- a/src/mkdir.cpp +++ b/src/mkdir.cpp @@ -45,7 +45,7 @@ int _mkdir(const fs::SearchFunc searchFunc, const fs::SearchFunc createPathFunc, const vector &srcmounts, - const string fusepath, + const string &fusepath, const mode_t mode) { int rv; diff --git a/src/mknod.cpp b/src/mknod.cpp index a6b16118..19f1f997 100644 --- a/src/mknod.cpp +++ b/src/mknod.cpp @@ -46,7 +46,7 @@ int _mknod(const fs::SearchFunc searchFunc, const fs::SearchFunc createPathFunc, const vector &srcmounts, - const string fusepath, + const string &fusepath, const mode_t mode, const dev_t dev) { diff --git a/src/open.cpp b/src/open.cpp index 5ac24581..2df409b9 100644 --- a/src/open.cpp +++ b/src/open.cpp @@ -45,7 +45,7 @@ static int _open(const fs::SearchFunc searchFunc, const vector &srcmounts, - const string fusepath, + const string &fusepath, const int flags, uint64_t &fh) { diff --git a/src/opendir.hpp b/src/opendir.hpp index 020e25f0..5110cc36 100644 --- a/src/opendir.hpp +++ b/src/opendir.hpp @@ -28,6 +28,8 @@ namespace mergerfs { namespace opendir { - int opendir(const char *fusepath, struct fuse_file_info *ffi); + int + opendir(const char *fusepath, + struct fuse_file_info *ffi); } } diff --git a/src/option_parser.cpp b/src/option_parser.cpp index 76d6865b..0b9bb938 100644 --- a/src/option_parser.cpp +++ b/src/option_parser.cpp @@ -44,7 +44,7 @@ using namespace mergerfs; static int process_opt(config::Config &config, - const std::string arg) + const std::string &arg) { int rv = 0; std::vector argvalue; diff --git a/src/policy.cpp b/src/policy.cpp index 233a5b48..0cf8915a 100644 --- a/src/policy.cpp +++ b/src/policy.cpp @@ -55,7 +55,7 @@ namespace mergerfs const Policy &Policy::rand = Policy::policies[Policy::Enum::rand]; const Policy& - Policy::find(const std::string str) + Policy::find(const std::string &str) { for(int i = Enum::BEGIN; i != Enum::END; ++i) { diff --git a/src/policy.hpp b/src/policy.hpp index 87054729..38f8da70 100644 --- a/src/policy.hpp +++ b/src/policy.hpp @@ -65,9 +65,9 @@ namespace mergerfs { } - Policy(const Enum::Type enum_, - const std::string str_, - const fs::SearchFunc func_) + Policy(const Enum::Type enum_, + const std::string &str_, + const fs::SearchFunc func_) : _enum(enum_), _str(str_), _func(func_) @@ -76,17 +76,17 @@ namespace mergerfs public: operator const Enum::Type() const { return _enum; } - operator const std::string() const { return _str; } + operator const std::string&() const { return _str; } operator const fs::SearchFunc() const { return _func; } operator const Policy*() const { return this; } bool operator==(const Enum::Type enum_) const { return _enum == enum_; } - bool operator==(const std::string str_) const + bool operator==(const std::string &str_) const { return _str == str_; } bool operator==(const fs::SearchFunc func_) const { return _func == func_; } - + bool operator!=(const Policy &r) const { return _enum != r._enum; } @@ -94,7 +94,7 @@ namespace mergerfs { return _enum < r._enum; } public: - static const Policy &find(const std::string); + static const Policy &find(const std::string&); static const Policy &find(const Enum::Type); public: diff --git a/src/readdir.cpp b/src/readdir.cpp index f84dc54a..a5dca940 100644 --- a/src/readdir.cpp +++ b/src/readdir.cpp @@ -48,7 +48,7 @@ using mergerfs::readdir::FileData; static int _readdir(const vector &srcmounts, - const string dirname, + const string &dirname, void *buf, const fuse_fill_dir_t filler) { @@ -107,7 +107,7 @@ namespace mergerfs { int readdir(const vector &srcmounts, - const string dirname, + const string &dirname, vector &stats) { return _readdir(srcmounts, diff --git a/src/readdir.hpp b/src/readdir.hpp index 26dc03f9..cf93969f 100644 --- a/src/readdir.hpp +++ b/src/readdir.hpp @@ -40,8 +40,8 @@ namespace mergerfs { struct FileData { - FileData(std::string filename_, - struct stat stats_) + FileData(const std::string &filename_, + const struct stat &stats_) : filename(filename_), stats(stats_) {} @@ -59,7 +59,7 @@ namespace mergerfs int readdir(const std::vector &srcmounts, - const std::string dirname, + const std::string &dirname, std::vector &stats); } } diff --git a/src/readlink.cpp b/src/readlink.cpp index 9a430bd8..5abe012c 100644 --- a/src/readlink.cpp +++ b/src/readlink.cpp @@ -42,8 +42,8 @@ using mergerfs::Policy; static int _readlink(const fs::SearchFunc searchFunc, - const vector& srcmounts, - const string fusepath, + const vector &srcmounts, + const string &fusepath, char *buf, const size_t size) { diff --git a/src/releasedir.hpp b/src/releasedir.hpp index 0e06653d..44a156d1 100644 --- a/src/releasedir.hpp +++ b/src/releasedir.hpp @@ -28,6 +28,8 @@ namespace mergerfs { namespace releasedir { - int releasedir(const char *fusepath, struct fuse_file_info *ffi); + int + releasedir(const char *fusepath, + struct fuse_file_info *ffi); } } diff --git a/src/removexattr.cpp b/src/removexattr.cpp index f62ac2c1..a0359d8e 100644 --- a/src/removexattr.cpp +++ b/src/removexattr.cpp @@ -43,7 +43,7 @@ static int _removexattr(const fs::SearchFunc searchFunc, const vector &srcmounts, - const string fusepath, + const string &fusepath, const char *attrname) { #ifndef WITHOUT_XATTR diff --git a/src/rename.cpp b/src/rename.cpp index 84339b5b..8849bae2 100644 --- a/src/rename.cpp +++ b/src/rename.cpp @@ -43,8 +43,8 @@ static int _rename(const fs::SearchFunc searchFunc, const vector &srcmounts, - const string from, - const string to) + const string &from, + const string &to) { int rv; string pathto; diff --git a/src/rmdir.cpp b/src/rmdir.cpp index 92834cbe..486fa2e2 100644 --- a/src/rmdir.cpp +++ b/src/rmdir.cpp @@ -42,7 +42,7 @@ static int _rmdir(const fs::SearchFunc searchFunc, const vector &srcmounts, - const string fusepath) + const string &fusepath) { int rv; int error; diff --git a/src/rwlock.hpp b/src/rwlock.hpp index 082d7d41..e34a2f1b 100644 --- a/src/rwlock.hpp +++ b/src/rwlock.hpp @@ -42,10 +42,11 @@ namespace mergerfs pthread_rwlock_unlock(_lock); } - pthread_rwlock_t *_lock; - private: ReadGuard(); + + private: + pthread_rwlock_t *_lock; }; class WriteGuard @@ -62,10 +63,11 @@ namespace mergerfs pthread_rwlock_unlock(_lock); } - pthread_rwlock_t *_lock; - private: WriteGuard(); + + private: + pthread_rwlock_t *_lock; }; } } diff --git a/src/setxattr.cpp b/src/setxattr.cpp index dc257779..c7bc5512 100644 --- a/src/setxattr.cpp +++ b/src/setxattr.cpp @@ -48,8 +48,8 @@ static int _add_srcmounts(vector &srcmounts, pthread_rwlock_t &srcmountslock, - const string destmount, - const string values, + const string &destmount, + const string &values, vector::iterator pos) { vector patterns; @@ -73,7 +73,7 @@ _add_srcmounts(vector &srcmounts, static int _erase_srcmounts(vector &srcmounts, - pthread_rwlock_t srcmountslock, + pthread_rwlock_t &srcmountslock, const string &values) { if(srcmounts.empty()) @@ -83,9 +83,11 @@ _erase_srcmounts(vector &srcmounts, str::split(patterns,values,':'); - const rwlock::WriteGuard wrg(&srcmountslock); + { + const rwlock::WriteGuard wrg(&srcmountslock); - fs::erase_fnmatches(patterns,srcmounts); + fs::erase_fnmatches(patterns,srcmounts); + } return 0; } @@ -93,9 +95,9 @@ _erase_srcmounts(vector &srcmounts, static int _replace_srcmounts(vector &srcmounts, - pthread_rwlock_t srcmountslock, - const string destmount, - const string values) + pthread_rwlock_t &srcmountslock, + const string &destmount, + const string &values) { vector patterns; vector newmounts; @@ -114,7 +116,7 @@ _replace_srcmounts(vector &srcmounts, static void -_split_attrval(const string attrval, +_split_attrval(const string &attrval, string &instruction, string &values) { @@ -130,8 +132,8 @@ static int _setxattr_srcmounts(vector &srcmounts, pthread_rwlock_t &srcmountslock, - const string destmount, - const string attrval, + const string &destmount, + const string &attrval, const int flags) { string instruction; @@ -165,8 +167,8 @@ _setxattr_srcmounts(vector &srcmounts, static int _setxattr_policy(const Policy *policies[], - const string attrname, - const string attrval, + const string &attrname, + const string &attrval, const int flags) { const Category *cat; @@ -191,8 +193,8 @@ _setxattr_policy(const Policy *policies[], static int _setxattr_controlfile(config::Config &config, - const string attrname, - const string attrval, + const string &attrname, + const string &attrval, const int flags) { vector nameparts; @@ -224,7 +226,7 @@ static int _setxattr(const fs::SearchFunc searchFunc, const vector &srcmounts, - const string fusepath, + const string &fusepath, const char *attrname, const char *attrval, const size_t attrvalsize, diff --git a/src/str.cpp b/src/str.cpp index be71882b..98329faa 100644 --- a/src/str.cpp +++ b/src/str.cpp @@ -34,7 +34,7 @@ namespace str { void split(vector &result, - const string str, + const string &str, const char delimiter) { string part; diff --git a/src/str.hpp b/src/str.hpp index aa02e2b0..36887af1 100644 --- a/src/str.hpp +++ b/src/str.hpp @@ -27,10 +27,12 @@ namespace str { - void split(std::vector &result, - const std::string str, - const char delimiter); + void + split(std::vector &result, + const std::string &str, + const char delimiter); - std::string join(const std::vector &vec, - const char sep); + std::string + join(const std::vector &vec, + const char sep); } diff --git a/src/symlink.cpp b/src/symlink.cpp index 56fdd40a..fd07c7f6 100644 --- a/src/symlink.cpp +++ b/src/symlink.cpp @@ -40,8 +40,8 @@ using std::vector; static int _symlink(const vector &srcmounts, - const string from, - const string to) + const string &from, + const string &to) { int rv; fs::PathVector paths; diff --git a/src/test.cpp b/src/test.cpp deleted file mode 100644 index d86fc677..00000000 --- a/src/test.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - The MIT License (MIT) - - Copyright (c) 2014 Antonio SJ Musumeci - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include - -#include "config.hpp" -#include "readdir.hpp" -#include "fs.hpp" - -using std::string; - -namespace mergerfs -{ - int - test(const struct fuse_args &args, - const mergerfs::config::Config &config) - { - - - return 0; - } -} diff --git a/src/test.hpp b/src/test.hpp deleted file mode 100644 index 094fb673..00000000 --- a/src/test.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - The MIT License (MIT) - - Copyright (c) 2014 Antonio SJ Musumeci - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -namespace mergerfs -{ - int - test(const struct fuse_args &args, - const mergerfs::config::Config &config); -} diff --git a/src/truncate.cpp b/src/truncate.cpp index 501b612c..fe8cdeac 100644 --- a/src/truncate.cpp +++ b/src/truncate.cpp @@ -43,7 +43,7 @@ static int _truncate(const fs::SearchFunc searchFunc, const vector &srcmounts, - const string fusepath, + const string &fusepath, const off_t size) { int rv; diff --git a/src/unlink.cpp b/src/unlink.cpp index f9900c4a..0ad3fa28 100644 --- a/src/unlink.cpp +++ b/src/unlink.cpp @@ -42,7 +42,7 @@ static int _unlink(const fs::SearchFunc searchFunc, const vector &srcmounts, - const string fusepath) + const string &fusepath) { int rv; int error; diff --git a/src/utimens.cpp b/src/utimens.cpp index 7a75ee92..12a71c8a 100644 --- a/src/utimens.cpp +++ b/src/utimens.cpp @@ -41,10 +41,10 @@ using std::vector; static int -_utimens(const fs::SearchFunc searchFunc, - const vector &srcmounts, - const string fusepath, - const struct timespec ts[2]) +_utimens(const fs::SearchFunc searchFunc, + const vector &srcmounts, + const string &fusepath, + const struct timespec ts[2]) { int rv; int error;