Address clang-tidy 18 warnings (#2428)

This commit is contained in:
Andrew Gaul 2024-03-07 01:04:22 +09:00 committed by GitHub
parent be54c34ecb
commit c97f7a2a13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 16 additions and 15 deletions

View File

@ -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,

View File

@ -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;
}
@ -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;
@ -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;
@ -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;
}

View File

@ -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
//

View File

@ -60,7 +60,7 @@
#define ENOATTR ENODATA
#endif
enum class dirtype {
enum class dirtype : int8_t {
UNKNOWN = -1,
NEW = 0,
OLD = 1,
@ -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;
}
@ -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;
}
@ -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
}
@ -5199,7 +5199,7 @@ 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;
@ -5207,7 +5207,7 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
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;
@ -5215,7 +5215,7 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
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){

View File

@ -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;