Skip to content

Commit

Permalink
cleanup function signatures and definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
trapexit committed Aug 18, 2020
1 parent 6cc6524 commit ec15872
Show file tree
Hide file tree
Showing 112 changed files with 743 additions and 820 deletions.
12 changes: 6 additions & 6 deletions src/branch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ parse(const string &str_,
else
branch.mode = Branch::RW;

fs::glob(str,globbed);
fs::realpathize(globbed);
fs::glob(str,&globbed);
fs::realpathize(&globbed);
for(size_t i = 0; i < globbed.size(); i++)
{
branch.path = globbed[i];
Expand All @@ -109,7 +109,7 @@ set(Branches &branches_,

branches_.clear();

str::split(paths,str_,':');
str::split(str_,':',&paths);

for(size_t i = 0; i < paths.size(); i++)
{
Expand All @@ -130,7 +130,7 @@ add_begin(Branches &branches_,
{
vector<string> paths;

str::split(paths,str_,':');
str::split(str_,':',&paths);

for(size_t i = 0; i < paths.size(); i++)
{
Expand All @@ -151,7 +151,7 @@ add_end(Branches &branches_,
{
vector<string> paths;

str::split(paths,str_,':');
str::split(str_,':',&paths);

for(size_t i = 0; i < paths.size(); i++)
{
Expand Down Expand Up @@ -186,7 +186,7 @@ erase_fnmatch(Branches &branches_,
{
vector<string> patterns;

str::split(patterns,str_,':');
str::split(str_,':',&patterns);

for(Branches::iterator i = branches_.begin();
i != branches_.end();)
Expand Down
12 changes: 6 additions & 6 deletions src/buildmap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ template<typename K,typename V>
class buildmap
{
public:
buildmap(const K &key,
const V &val)
buildmap(const K &key_,
const V &val_)
{
_map.insert(std::make_pair(key,val));
_map.insert(std::make_pair(key_,val_));
}

buildmap<K,V> &operator()(const K &key,
const V &val)
buildmap<K,V> &operator()(const K &key_,
const V &val_)
{
_map.insert(std::make_pair(key,val));
_map.insert(std::make_pair(key_,val_));
return *this;
}

Expand Down
8 changes: 4 additions & 4 deletions src/buildvector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ template<typename V, bool SORT = false>
class buildvector
{
public:
buildvector(const V &val)
buildvector(const V &val_)
{
_vector.push_back(val);
_vector.push_back(val_);
}

buildvector<V,SORT> &operator()(const V &val)
buildvector<V,SORT> &operator()(const V &val_)
{
_vector.push_back(val);
_vector.push_back(val_);
return *this;
}

Expand Down
1 change: 1 addition & 0 deletions src/config_statfsignore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ enum class StatFSIgnoreEnum
RO,
NC
};

typedef Enum<StatFSIgnoreEnum> StatFSIgnore;
54 changes: 10 additions & 44 deletions src/fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ using std::vector;
namespace fs
{
void
findallfiles(const vector<string> &basepaths,
const char *fusepath,
vector<string> &paths)
findallfiles(const vector<string> &basepaths_,
const char *fusepath_,
vector<string> *paths_)
{
string fullpath;

for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
for(size_t i = 0, ei = basepaths_.size(); i != ei; i++)
{
fullpath = fs::path::make(basepaths[i],fusepath);
fullpath = fs::path::make(basepaths_[i],fusepath_);

if(!fs::exists(fullpath))
continue;

paths.push_back(fullpath);
paths_->push_back(fullpath);
}
}

Expand Down Expand Up @@ -91,17 +91,17 @@ namespace fs
}

void
realpathize(vector<string> &strs)
realpathize(vector<string> *strs_)
{
char *rv;

for(size_t i = 0; i < strs.size(); i++)
for(size_t i = 0; i < strs_->size(); i++)
{
rv = fs::realpath(strs[i]);
rv = fs::realpath((*strs_)[i]);
if(rv == NULL)
continue;

strs[i] = rv;
(*strs_)[i] = rv;

::free(rv);
}
Expand All @@ -119,38 +119,4 @@ namespace fs
{
return ::fcntl(fd,F_SETFL,mode);
}

int
mfs(const vector<string> &basepaths,
const uint64_t minfreespace,
string &path)
{
int rv;
uint64_t mfs;
uint64_t spaceavail;
const string *mfsbasepath;

mfs = 0;
mfsbasepath = NULL;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
rv = fs::statvfs_cache_spaceavail(basepaths[i],&spaceavail);
if(rv == -1)
continue;
if(spaceavail < minfreespace)
continue;
if(spaceavail <= mfs)
continue;

mfs = spaceavail;
mfsbasepath = &basepaths[i];
}

if(mfsbasepath == NULL)
return (errno=ENOENT,-1);

path = *mfsbasepath;

return 0;
}
};
21 changes: 7 additions & 14 deletions src/fs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,13 @@

namespace fs
{
using std::string;
using std::vector;
void findallfiles(const std::vector<std::string> &basepaths,
const char *fusepath,
std::vector<std::string> *paths);

void findallfiles(const vector<string> &basepaths_,
const char *fusepath_,
vector<string> &paths_);
void realpathize(std::vector<std::string> *strs);

void realpathize(vector<string> &strs_);

int getfl(const int fd_);
int setfl(const int fd_,
const mode_t mode_);

int mfs(const vector<string> &srcs_,
const uint64_t minfreespace_,
string &path_);
int getfl(const int fd);
int setfl(const int fd,
const mode_t mode);
}
2 changes: 1 addition & 1 deletion src/fs_acl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ namespace fs
namespace acl
{
bool
dir_has_defaults(const std::string &fullpath_);
dir_has_defaults(const std::string &fullpath);
}
}
8 changes: 4 additions & 4 deletions src/fs_attr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ namespace fs
{
namespace attr
{
int copy(const int fdin_,
const int fdout_);
int copy(const std::string &from_,
const std::string &to_);
int copy(const int fdin,
const int fdout);
int copy(const std::string &from,
const std::string &to);
}
}
18 changes: 9 additions & 9 deletions src/fs_base_fadvise.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
namespace fs
{
int
fadvise_dontneed(const int fd_,
const off_t offset_ = 0,
const off_t len_ = 0);
fadvise_dontneed(const int fd,
const off_t offset = 0,
const off_t len = 0);

int
fadvise_willneed(const int fd_,
const off_t offset_ = 0,
const off_t len_ = 0);
fadvise_willneed(const int fd,
const off_t offset = 0,
const off_t len = 0);

int
fadvise_sequential(const int fd_,
const off_t offset_ = 0,
const off_t len_ = 0);
fadvise_sequential(const int fd,
const off_t offset = 0,
const off_t len = 0);
}
8 changes: 4 additions & 4 deletions src/fs_base_fallocate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
namespace fs
{
int
fallocate(const int fd_,
const int mode_,
const off_t offset_,
const off_t len_);
fallocate(const int fd,
const int mode,
const off_t offset,
const off_t len);
}
28 changes: 14 additions & 14 deletions src/fs_base_fstatat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,27 @@ namespace fs
static
inline
int
fstatat(const int dirfd,
const char *pathname,
struct stat *statbuf,
const int flags)
fstatat(const int dirfd_,
const char *pathname_,
struct stat *statbuf_,
const int flags_)
{
return ::fstatat(dirfd,
pathname,
statbuf,
flags);
return ::fstatat(dirfd_,
pathname_,
statbuf_,
flags_);
}

static
inline
int
fstatat_nofollow(const int dirfd,
const char *pathname,
struct stat *statbuf)
fstatat_nofollow(const int dirfd_,
const char *pathname_,
struct stat *statbuf_)
{
return fs::fstatat(dirfd,
pathname,
statbuf,
return fs::fstatat(dirfd_,
pathname_,
statbuf_,
AT_SYMLINK_NOFOLLOW);
}
}
6 changes: 3 additions & 3 deletions src/fs_base_futimesat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
namespace fs
{
int
futimesat(const int dirfd_,
const char *pathname_,
const struct timeval times_[2]);
futimesat(const int dirfd,
const char *pathname,
const struct timeval times[2]);
}
6 changes: 3 additions & 3 deletions src/fs_base_getdents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
namespace fs
{
int
getdents(unsigned int fd_,
void *dirp_,
unsigned int count_)
getdents64(unsigned int fd_,
void *dirp_,
unsigned int count_)
{
#if defined SYS_getdents64
return ::syscall(SYS_getdents64,fd_,dirp_,count_);
Expand Down
6 changes: 3 additions & 3 deletions src/fs_base_getdents.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
namespace fs
{
int
getdents(unsigned int fd,
void *dirp,
unsigned int count);
getdents64(unsigned int fd,
void *dirp,
unsigned int count);
}
10 changes: 5 additions & 5 deletions src/fs_base_utime_utimensat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ namespace fs
static
inline
int
utime(const int dirfd,
const std::string &path,
const struct timespec times[2],
const int flags)
utime(const int dirfd_,
const std::string &path_,
const struct timespec times_[2],
const int flags_)
{
return ::utimensat(dirfd,path.c_str(),times,flags);
return ::utimensat(dirfd_,path_.c_str(),times_,flags_);
}

static
Expand Down
18 changes: 9 additions & 9 deletions src/fs_base_write.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ namespace fs
static
inline
ssize_t
write(const int fd,
const void *buf,
const size_t count)
write(const int fd_,
const void *buf_,
const size_t count_)
{
return ::write(fd,buf,count);
return ::write(fd_,buf_,count_);
}

static
inline
ssize_t
pwrite(const int fd,
const void *buf,
const size_t count,
const off_t offset)
pwrite(const int fd_,
const void *buf_,
const size_t count_,
const off_t offset_)
{
return ::pwrite(fd,buf,count,offset);
return ::pwrite(fd_,buf_,count_,offset_);
}
}

0 comments on commit ec15872

Please sign in to comment.