Address miscellaneous clang-tidy warnings

Also add configuration with suppressions.
This commit is contained in:
Andrew Gaul 2019-02-04 21:12:57 -08:00
parent bd66b57ad3
commit e87e40b3b4
4 changed files with 37 additions and 13 deletions

26
.clang-tidy Normal file
View File

@ -0,0 +1,26 @@
Checks: '
-*,
bugprone-*,
google-*,
-google-build-using-namespace,
-google-readability-casting,
-google-readability-todo,
-google-runtime-int,
-google-runtime-references,
misc-*,
-misc-misplaced-const,
-misc-redundant-expression,
-misc-unused-parameters,
modernize-*,
-modernize-deprecated-headers,
-modernize-loop-convert,
-modernize-use-auto,
-modernize-use-nullptr,
-modernize-use-using,
performance-*,
portability-*,
readability-*,
-readability-else-after-return,
-readability-implicit-bool-conversion,
-readability-named-parameter,
-readability-simplify-boolean-expr'

View File

@ -1471,7 +1471,7 @@ int FdEntity::RowFlush(const char* tpath, bool force_sync)
// enough disk space
// Load all uninitialized area
result = Load();
FdManager::get()->FreeReservedDiskSpace(restsize);
FdManager::FreeReservedDiskSpace(restsize);
if(0 != result){
S3FS_PRN_ERR("failed to upload all area(errno=%d)", result);
return static_cast<ssize_t>(result);
@ -1646,7 +1646,7 @@ ssize_t FdEntity::Read(char* bytes, off_t start, size_t size, bool force_load)
result = Load(start, load_size);
}
FdManager::get()->FreeReservedDiskSpace(load_size);
FdManager::FreeReservedDiskSpace(load_size);
if(0 != result){
S3FS_PRN_ERR("could not download. start(%jd), size(%zu), errno(%d)", (intmax_t)start, size, result);
@ -1698,7 +1698,7 @@ ssize_t FdEntity::Write(const char* bytes, off_t start, size_t size)
if(0 < start){
result = Load(0, static_cast<size_t>(start));
}
FdManager::get()->FreeReservedDiskSpace(restsize);
FdManager::FreeReservedDiskSpace(restsize);
if(0 != result){
S3FS_PRN_ERR("failed to load uninitialized area before writing(errno=%d)", result);
return static_cast<ssize_t>(result);

View File

@ -822,9 +822,9 @@ static int put_headers(const char* path, headers_t& meta, bool is_copy)
}
FdEntity* ent = NULL;
if(NULL == (ent = FdManager::get()->ExistOpen(path, -1, !(FdManager::get()->IsCacheDir())))){
if(NULL == (ent = FdManager::get()->ExistOpen(path, -1, !FdManager::IsCacheDir()))){
// no opened fd
if(FdManager::get()->IsCacheDir()){
if(FdManager::IsCacheDir()){
// create cache file if be needed
ent = FdManager::get()->Open(path, &meta, static_cast<ssize_t>(buf.st_size), -1, false, true);
}
@ -2564,9 +2564,10 @@ static int list_bucket(const char* path, S3ObjList& head, const char* delimiter,
// reset(initialize) curl object
s3fscurl.DestroyCurlHandle();
if (check_content_only)
if(check_content_only){
break;
}
}
S3FS_MALLOCTRIM(0);
return 0;
@ -4341,7 +4342,7 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
}
// the second NONOPT option is the mountpoint(not utility mode)
if(mountpoint.empty() && 0 == utility_mode){
if(mountpoint.empty() && !utility_mode){
// save the mountpoint and do some basic error checking
mountpoint = arg;
struct stat stbuf;
@ -4379,7 +4380,7 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
}
// Unknown option
if(0 == utility_mode){
if(!utility_mode){
S3FS_PRN_EXIT("specified unknown third option(%s).", arg);
}else{
S3FS_PRN_EXIT("specified unknown second option(%s). you don't need to specify second option(mountpoint) for utility mode(-u).", arg);
@ -4988,7 +4989,7 @@ int main(int argc, char* argv[])
case 's':
break;
case 'u':
utility_mode = 1;
utility_mode = true;
break;
default:
exit(EXIT_FAILURE);
@ -5080,7 +5081,7 @@ int main(int argc, char* argv[])
// if the option was given, we all ready checked for a
// readable, non-empty directory, this checks determines
// if the mountpoint option was ever supplied
if(utility_mode == 0){
if(!utility_mode){
if(mountpoint.empty()){
S3FS_PRN_EXIT("missing MOUNTPOINT argument.");
show_usage();

View File

@ -419,7 +419,6 @@ void free_mvnodes(MVNODE *head)
free(my_head->new_path);
free(my_head);
}
return;
}
//-------------------------------------------------------------------
@ -1362,7 +1361,6 @@ void show_help ()
"\n"
"s3fs home page: <https://github.com/s3fs-fuse/s3fs-fuse>\n"
);
return;
}
void show_version()
@ -1374,7 +1372,6 @@ void show_version()
"This is free software: you are free to change and redistribute it.\n"
"There is NO WARRANTY, to the extent permitted by law.\n",
VERSION, COMMIT_HASH_VAL, s3fs_crypt_lib_name());
return;
}
/*