Skip to content

Commit

Permalink
Address clang-tidy 18 warnings (s3fs-fuse#2428)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaul authored Mar 6, 2024
1 parent be54c34 commit c97f7a2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Checks: '
-performance-no-int-to-ptr,
portability-*,
readability-*,
-readability-avoid-nested-conditional-operator,
-readability-braces-around-statements,
-readability-else-after-return,
-readability-function-cognitive-complexity,
Expand Down
8 changes: 4 additions & 4 deletions src/curl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ size_t S3fsCurl::ReadCallback(void* ptr, size_t size, size_t nmemb, void* userp)
memcpy(ptr, pCurl->postdata, copysize);

pCurl->postdata_remaining = (pCurl->postdata_remaining > static_cast<off_t>(copysize) ? (pCurl->postdata_remaining - copysize) : 0);
pCurl->postdata += static_cast<size_t>(copysize);
pCurl->postdata += copysize;

return copysize;
}
Expand Down Expand Up @@ -963,7 +963,7 @@ bool S3fsCurl::GetSseKey(std::string& md5, std::string& ssekey)

bool S3fsCurl::GetSseKeyMd5(size_t pos, std::string& md5)
{
if(S3fsCurl::sseckeys.size() <= static_cast<size_t>(pos)){
if(S3fsCurl::sseckeys.size() <= pos){
return false;
}
size_t cnt = 0;
Expand Down Expand Up @@ -1526,7 +1526,7 @@ int S3fsCurl::ParallelMixMultipartUploadRequest(const char* tpath, headers_t& me
for(off_t i = 0, bytes = 0; i < iter->bytes; i += bytes){
std::unique_ptr<S3fsCurl> s3fscurl_para(new S3fsCurl(true));

bytes = std::min(static_cast<off_t>(GetMultipartCopySize()), iter->bytes - i);
bytes = std::min(GetMultipartCopySize(), iter->bytes - i);
/* every part should be larger than MIN_MULTIPART_SIZE and smaller than FIVE_GB */
off_t remain_bytes = iter->bytes - i - bytes;

Expand Down Expand Up @@ -3447,7 +3447,7 @@ int S3fsCurl::PutRequest(const char* tpath, headers_t& meta, int fd)
std::string strMD5;
if(-1 != fd){
strMD5 = s3fs_get_content_md5(fd);
if(0 == strMD5.length()){
if(strMD5.empty()){
S3FS_PRN_ERR("Failed to make MD5.");
return -EIO;
}
Expand Down
4 changes: 2 additions & 2 deletions src/fdcache_entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1180,10 +1180,10 @@ int FdEntity::NoCacheLoadAndPost(PseudoFdInfo* pseudo_obj, off_t start, off_t si
break;
}
// download each multipart size(default 10MB) in unit
for(off_t oneread = 0, totalread = (iter->offset < start ? start : 0); totalread < static_cast<off_t>(iter->bytes); totalread += oneread){
for(off_t oneread = 0, totalread = (iter->offset < start ? start : 0); totalread < iter->bytes; totalread += oneread){
int upload_fd = physical_fd;
off_t offset = iter->offset + totalread;
oneread = std::min(static_cast<off_t>(iter->bytes) - totalread, S3fsCurl::GetMultipartSize());
oneread = std::min(iter->bytes - totalread, S3fsCurl::GetMultipartSize());

// check rest size is over minimum part size
//
Expand Down
16 changes: 8 additions & 8 deletions src/s3fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#define ENOATTR ENODATA
#endif

enum class dirtype {
enum class dirtype : int8_t {
UNKNOWN = -1,
NEW = 0,
OLD = 1,
Expand Down Expand Up @@ -4040,7 +4040,7 @@ static int s3fs_getxattr(const char* path, const char* name, char* value, size_t
const char* pvalue = xiter->second.c_str();

if(0 < size){
if(static_cast<size_t>(size) < length){
if(size < length){
// over buffer size
return -ERANGE;
}
Expand Down Expand Up @@ -4296,12 +4296,12 @@ static void* s3fs_init(struct fuse_conn_info* conn)

// Investigate system capabilities
#ifndef __APPLE__
if((unsigned int)conn->capable & FUSE_CAP_ATOMIC_O_TRUNC){
if(conn->capable & FUSE_CAP_ATOMIC_O_TRUNC){
conn->want |= FUSE_CAP_ATOMIC_O_TRUNC;
}
#endif

if((unsigned int)conn->capable & FUSE_CAP_BIG_WRITES){
if(conn->capable & FUSE_CAP_BIG_WRITES){
conn->want |= FUSE_CAP_BIG_WRITES;
}

Expand Down Expand Up @@ -4725,7 +4725,7 @@ static fsblkcnt_t parse_bucket_size(char* max_size)
if(!isdigit(*ptr)){
return 0; // wrong number
}
n_bytes = static_cast<unsigned long long>(strtoull(max_size, nullptr, 10));
n_bytes = strtoull(max_size, nullptr, 10);
if((INT64_MAX / scale) < n_bytes){
return 0; // overflow
}
Expand Down Expand Up @@ -5199,23 +5199,23 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
return 0;
}
else if(is_prefix(arg, "multipart_size=")){
off_t size = static_cast<off_t>(cvt_strtoofft(strchr(arg, '=') + sizeof(char), /*base=*/ 10));
off_t size = cvt_strtoofft(strchr(arg, '=') + sizeof(char), /*base=*/ 10);
if(!S3fsCurl::SetMultipartSize(size)){
S3FS_PRN_EXIT("multipart_size option must be at least 5 MB.");
return -1;
}
return 0;
}
else if(is_prefix(arg, "multipart_copy_size=")){
off_t size = static_cast<off_t>(cvt_strtoofft(strchr(arg, '=') + sizeof(char), /*base=*/ 10));
off_t size = cvt_strtoofft(strchr(arg, '=') + sizeof(char), /*base=*/ 10);
if(!S3fsCurl::SetMultipartCopySize(size)){
S3FS_PRN_EXIT("multipart_copy_size option must be at least 5 MB.");
return -1;
}
return 0;
}
else if(is_prefix(arg, "max_dirty_data=")){
off_t size = static_cast<off_t>(cvt_strtoofft(strchr(arg, '=') + sizeof(char), /*base=*/ 10));
off_t size = cvt_strtoofft(strchr(arg, '=') + sizeof(char), /*base=*/ 10);
if(size >= 50){
size *= 1024 * 1024;
}else if(size != -1){
Expand Down
2 changes: 1 addition & 1 deletion src/s3objlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ bool S3ObjList::GetLastName(std::string& lastname) const
bool result = false;
lastname = "";
for(s3obj_t::const_iterator iter = objects.begin(); iter != objects.end(); ++iter){
if((*iter).second.orgname.length()){
if(!iter->second.orgname.empty()){
if(lastname.compare(iter->second.orgname) < 0){
lastname = (*iter).second.orgname;
result = true;
Expand Down

0 comments on commit c97f7a2

Please sign in to comment.