Fix issues discovered by Coverity (#2535)

This commit is contained in:
Andrew Gaul 2024-10-08 08:07:13 +09:00 committed by GitHub
parent 4605cc2035
commit 743c86e506
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 5 deletions

View File

@ -1858,7 +1858,9 @@ bool S3fsCurl::AddUserAgent(const CurlUniquePtr& hCurl)
return false;
}
if(S3fsCurl::IsUserAgentFlag()){
curl_easy_setopt(hCurl, CURLOPT_USERAGENT, S3fsCurl::userAgent.c_str());
if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_USERAGENT, S3fsCurl::userAgent.c_str())){
return false;
}
}
return true;
}

View File

@ -115,7 +115,7 @@ bool S3fsMultiCurl::SetS3fsCurlObject(std::unique_ptr<S3fsCurl> s3fscurl)
int S3fsMultiCurl::MultiPerform()
{
std::map<std::thread::id, std::pair<std::thread, std::future<int>>> threads;
bool success = true;
int result = 0;
bool isMultiHead = false;
Semaphore sem(GetMaxParallelism());
@ -164,12 +164,13 @@ int S3fsMultiCurl::MultiPerform()
long int int_retval = it->second.second.get();
if (int_retval && !(int_retval == -ENOENT && isMultiHead)) {
S3FS_PRN_WARN("thread terminated with non-zero return code: %ld", int_retval);
result = int_retval;
}
threads.erase(it);
}
completed_tids.clear();
return success ? 0 : -EIO;
return result;
}
int S3fsMultiCurl::MultiRead()

View File

@ -1203,13 +1203,13 @@ int FdEntity::NoCacheLoadAndPost(PseudoFdInfo* pseudo_obj, off_t start, off_t si
fdpage page(iter->offset, start - iter->offset, iter->loaded, false);
iter->bytes -= (start - iter->offset);
iter->offset = start;
pagelist.pages.insert(iter, page);
iter = pagelist.pages.insert(iter, page);
}
if(0 != size && start + size < iter->next()){
fdpage page(iter->offset, start + size - iter->offset, true, false);
iter->bytes -= (start + size - iter->offset);
iter->offset = start + size;
pagelist.pages.insert(iter, page);
iter = pagelist.pages.insert(iter, page);
}else{
iter->loaded = true;
iter->modified = false;

View File

@ -73,6 +73,9 @@ static std::unique_ptr<unsigned char[]> create_random_data(off_t size)
readcnt = 0;
}
}
close(fd);
return pbuff;
}