Enable clang-analyzer (#2588)

Also fix a few smaller issues.
This commit is contained in:
Andrew Gaul 2024-11-04 23:58:43 +09:00 committed by GitHub
parent 9b888fa9b3
commit 9a155c81a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 7 deletions

View File

@ -16,7 +16,8 @@ Checks: '
-cert-env33-c, -cert-env33-c,
-cert-err33-c, -cert-err33-c,
-cert-err58-cpp, -cert-err58-cpp,
-clang-analyzer-*, -clang-analyzer-security.insecureAPI.strcpy,
-clang-analyzer-unix.BlockInCriticalSection,
-concurrency-mt-unsafe, -concurrency-mt-unsafe,
-cppcoreguidelines-avoid-c-arrays, -cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-do-while, -cppcoreguidelines-avoid-do-while,

View File

@ -620,7 +620,7 @@ size_t S3fsCurl::UploadReadCallback(void* ptr, size_t size, size_t nmemb, void*
ssize_t readbytes; ssize_t readbytes;
ssize_t totalread; ssize_t totalread;
// read and set // read and set
for(totalread = 0, readbytes = 0; totalread < copysize; totalread += readbytes){ for(totalread = 0; totalread < copysize; totalread += readbytes){
readbytes = pread(pCurl->partdata.fd, &(static_cast<char*>(ptr))[totalread], (copysize - totalread), pCurl->partdata.startpos + totalread); readbytes = pread(pCurl->partdata.fd, &(static_cast<char*>(ptr))[totalread], (copysize - totalread), pCurl->partdata.startpos + totalread);
if(0 == readbytes){ if(0 == readbytes){
// eof // eof
@ -659,7 +659,7 @@ size_t S3fsCurl::DownloadWriteCallback(void* ptr, size_t size, size_t nmemb, voi
ssize_t totalwrite; ssize_t totalwrite;
// write // write
for(totalwrite = 0, writebytes = 0; totalwrite < copysize; totalwrite += writebytes){ for(totalwrite = 0; totalwrite < copysize; totalwrite += writebytes){
writebytes = pwrite(pCurl->partdata.fd, &(static_cast<char*>(ptr))[totalwrite], (copysize - totalwrite), pCurl->partdata.startpos + totalwrite); writebytes = pwrite(pCurl->partdata.fd, &(static_cast<char*>(ptr))[totalwrite], (copysize - totalwrite), pCurl->partdata.startpos + totalwrite);
if(0 == writebytes){ if(0 == writebytes){
// eof? // eof?
@ -4445,7 +4445,7 @@ int S3fsCurl::MultipartHeadRequest(const char* tpath, off_t size, headers_t& met
curlmulti.SetSuccessCallback(S3fsCurl::CopyMultipartPostCallback); curlmulti.SetSuccessCallback(S3fsCurl::CopyMultipartPostCallback);
curlmulti.SetRetryCallback(S3fsCurl::CopyMultipartPostRetryCallback); curlmulti.SetRetryCallback(S3fsCurl::CopyMultipartPostRetryCallback);
for(bytes_remaining = size, chunk = 0; 0 < bytes_remaining; bytes_remaining -= chunk){ for(bytes_remaining = size; 0 < bytes_remaining; bytes_remaining -= chunk){
chunk = bytes_remaining > GetMultipartCopySize() ? GetMultipartCopySize() : bytes_remaining; chunk = bytes_remaining > GetMultipartCopySize() ? GetMultipartCopySize() : bytes_remaining;
std::ostringstream strrange; std::ostringstream strrange;
@ -4540,7 +4540,7 @@ int S3fsCurl::MultipartRenameRequest(const char* from, const char* to, headers_t
curlmulti.SetSuccessCallback(S3fsCurl::CopyMultipartPostCallback); curlmulti.SetSuccessCallback(S3fsCurl::CopyMultipartPostCallback);
curlmulti.SetRetryCallback(S3fsCurl::CopyMultipartPostRetryCallback); curlmulti.SetRetryCallback(S3fsCurl::CopyMultipartPostRetryCallback);
for(bytes_remaining = size, chunk = 0; 0 < bytes_remaining; bytes_remaining -= chunk){ for(bytes_remaining = size; 0 < bytes_remaining; bytes_remaining -= chunk){
chunk = bytes_remaining > GetMultipartCopySize() ? GetMultipartCopySize() : bytes_remaining; chunk = bytes_remaining > GetMultipartCopySize() ? GetMultipartCopySize() : bytes_remaining;
std::ostringstream strrange; std::ostringstream strrange;

View File

@ -535,8 +535,10 @@ int FdEntity::Open(const headers_t* pmeta, off_t size, const struct timespec& ts
// make file pointer(for being same tmpfile) // make file pointer(for being same tmpfile)
if(nullptr == (pfile = {fdopen(physical_fd, "wb"), &s3fs_fclose})){ if(nullptr == (pfile = {fdopen(physical_fd, "wb"), &s3fs_fclose})){
int saved_errno = errno;
S3FS_PRN_ERR("failed to get fileno(%s). errno(%d)", cachepath.c_str(), errno); S3FS_PRN_ERR("failed to get fileno(%s). errno(%d)", cachepath.c_str(), errno);
close(physical_fd); close(physical_fd);
errno = saved_errno;
physical_fd = -1; physical_fd = -1;
inode = 0; inode = 0;
return (0 == errno ? -EIO : -errno); return (0 == errno ? -EIO : -errno);

View File

@ -4388,10 +4388,9 @@ static int s3fs_check_service()
} }
S3fsCurl s3fscurl; S3fsCurl s3fscurl;
int res;
bool force_no_sse = false; bool force_no_sse = false;
while(0 > (res = s3fscurl.CheckBucket(get_realpath("/").c_str(), support_compat_dir, force_no_sse))){ while(0 > s3fscurl.CheckBucket(get_realpath("/").c_str(), support_compat_dir, force_no_sse)){
// get response code // get response code
bool do_retry = false; bool do_retry = false;
long responseCode = s3fscurl.GetLastResponseCode(); long responseCode = s3fscurl.GetLastResponseCode();