From e87e40b3b4b74936c72947b808553e17669ad356 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Mon, 4 Feb 2019 21:12:57 -0800 Subject: [PATCH] Address miscellaneous clang-tidy warnings Also add configuration with suppressions. --- .clang-tidy | 26 ++++++++++++++++++++++++++ src/fdcache.cpp | 6 +++--- src/s3fs.cpp | 15 ++++++++------- src/s3fs_util.cpp | 3 --- 4 files changed, 37 insertions(+), 13 deletions(-) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..20098a6 --- /dev/null +++ b/.clang-tidy @@ -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' diff --git a/src/fdcache.cpp b/src/fdcache.cpp index 380fac6..0c8cd94 100644 --- a/src/fdcache.cpp +++ b/src/fdcache.cpp @@ -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(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(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(result); diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 197781d..f95083d 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -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(buf.st_size), -1, false, true); } @@ -2564,8 +2564,9 @@ 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); @@ -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(); diff --git a/src/s3fs_util.cpp b/src/s3fs_util.cpp index 0c73f30..096732d 100644 --- a/src/s3fs_util.cpp +++ b/src/s3fs_util.cpp @@ -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: \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; } /*