Skip to content

Commit

Permalink
Address clang-tidy 19 warnings (s3fs-fuse#2474)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaul authored Jun 23, 2024
1 parent 86e6bda commit 254d717
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Checks: '
-misc-redundant-expression,
-misc-unused-parameters,
-misc-use-anonymous-namespace,
-misc-use-internal-linkage,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-loop-convert,
Expand Down Expand Up @@ -75,6 +76,7 @@ Checks: '
-readability-inconsistent-declaration-parameter-name,
-readability-isolate-declaration,
-readability-magic-numbers,
-readability-math-missing-parentheses,
-readability-named-parameter,
-readability-redundant-access-specifiers,
-readability-redundant-declaration,
Expand Down
8 changes: 4 additions & 4 deletions src/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@
//-------------------------------------------------------------------
// Utility
//-------------------------------------------------------------------
inline void SetStatCacheTime(struct timespec& ts)
static inline void SetStatCacheTime(struct timespec& ts)
{
if(-1 == clock_gettime(static_cast<clockid_t>(CLOCK_MONOTONIC_COARSE), &ts)){
S3FS_PRN_CRIT("clock_gettime failed: %d", errno);
abort();
}
}

inline void InitStatCacheTime(struct timespec& ts)
static inline void InitStatCacheTime(struct timespec& ts)
{
ts.tv_sec = 0;
ts.tv_nsec = 0;
}

inline int CompareStatCacheTime(const struct timespec& ts1, const struct timespec& ts2)
static inline int CompareStatCacheTime(const struct timespec& ts1, const struct timespec& ts2)
{
// return -1: ts1 < ts2
// 0: ts1 == ts2
Expand All @@ -67,7 +67,7 @@ inline int CompareStatCacheTime(const struct timespec& ts1, const struct timespe
return 0;
}

inline bool IsExpireStatCacheTime(const struct timespec& ts, const time_t& expire)
static inline bool IsExpireStatCacheTime(const struct timespec& ts, const time_t& expire)
{
struct timespec nowts;
SetStatCacheTime(nowts);
Expand Down
4 changes: 1 addition & 3 deletions src/curl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,7 @@ bool S3fsCurl::InitS3fsCurl()
// [NOTE]
// sCurlPoolSize must be over parallel(or multireq) count.
//
if(sCurlPoolSize < std::max(GetMaxParallelCount(), GetMaxMultiRequest())){
sCurlPoolSize = std::max(GetMaxParallelCount(), GetMaxMultiRequest());
}
sCurlPoolSize = std::max({sCurlPoolSize, GetMaxParallelCount(), GetMaxMultiRequest()});
sCurlPool = new CurlHandlerPool(sCurlPoolSize);
if (!sCurlPool->Init()) {
return false;
Expand Down
4 changes: 1 addition & 3 deletions src/fdcache_entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,7 @@ int FdEntity::Open(const headers_t* pmeta, off_t size, const struct timespec& ts
orgmeta = *pmeta;
size_orgmeta = get_size(orgmeta);
}
if(new_size < size_orgmeta){
size_orgmeta = new_size;
}
size_orgmeta = std::min(new_size, size_orgmeta);

}else{
//
Expand Down
2 changes: 1 addition & 1 deletion src/fdcache_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static constexpr int CHECK_CACHEFILE_PART_SIZE = 1024 * 16; // Buffer size in
// fdpage_list_t utility
//------------------------------------------------
// Inline function for repeated processing
inline void raw_add_compress_fdpage_list(fdpage_list_t& pagelist, const fdpage& orgpage, bool ignore_load, bool ignore_modify, bool default_load, bool default_modify)
static inline void raw_add_compress_fdpage_list(fdpage_list_t& pagelist, const fdpage& orgpage, bool ignore_load, bool ignore_modify, bool default_load, bool default_modify)
{
if(0 < orgpage.bytes){
// [NOTE]
Expand Down
14 changes: 6 additions & 8 deletions src/s3fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2720,9 +2720,7 @@ static int s3fs_truncate(const char* _path, off_t size)

FUSE_CTX_INFO("[path=%s][size=%lld]", path, static_cast<long long>(size));

if(size < 0){
size = 0;
}
size = std::max<off_t>(size, 0);

if(0 != (result = check_parent_object_access(path, X_OK))){
return result;
Expand Down Expand Up @@ -3186,7 +3184,7 @@ static bool multi_head_callback(S3fsCurl* s3fscurl, void* param)
}

// Add stat cache
std::string saved_path = s3fscurl->GetSpecialSavedPath();
const std::string& saved_path = s3fscurl->GetSpecialSavedPath();
if(!StatCache::getStatCacheData()->AddStat(saved_path, *(s3fscurl->GetResponseHeaders()))){
S3FS_PRN_ERR("failed adding stat cache [path=%s]", saved_path.c_str());
return false;
Expand Down Expand Up @@ -3261,9 +3259,9 @@ static std::unique_ptr<S3fsCurl> multi_head_retry_callback(S3fsCurl* s3fscurl)
}

std::unique_ptr<S3fsCurl> newcurl(new S3fsCurl(s3fscurl->IsUseAhbe()));
std::string path = s3fscurl->GetBasePath();
std::string base_path = s3fscurl->GetBasePath();
std::string saved_path = s3fscurl->GetSpecialSavedPath();
const std::string& path = s3fscurl->GetBasePath();
const std::string& base_path = s3fscurl->GetBasePath();
const std::string& saved_path = s3fscurl->GetSpecialSavedPath();

if(!newcurl->PreHeadRequest(path, base_path, saved_path, ssec_key_pos)){
S3FS_PRN_ERR("Could not duplicate curl object(%s).", saved_path.c_str());
Expand Down Expand Up @@ -3381,7 +3379,7 @@ static int readdir_multi_head(const char* path, const S3ObjList& head, void* buf

for(s3obj_list_t::iterator reiter = notfound_param.notfound_list.begin(); reiter != notfound_param.notfound_list.end(); ++reiter){
int dir_result;
std::string dirpath = *reiter;
const std::string& dirpath = *reiter;
if(-ENOTEMPTY == (dir_result = directory_empty(dirpath.c_str()))){
// Found objects under the path, so the path is directory.

Expand Down
2 changes: 2 additions & 0 deletions src/s3fs_global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include <string>

#include "common.h"

//-------------------------------------------------------------------
// Global variables
//-------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/string_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ std::string s3fs_base64(const unsigned char* input, size_t length)
return result;
}

inline unsigned char char_decode64(const char ch)
static inline unsigned char char_decode64(const char ch)
{
unsigned char by;
if('A' <= ch && ch <= 'Z'){ // A - Z
Expand Down

0 comments on commit 254d717

Please sign in to comment.