Merge pull request #1441 from gaul/coverity

Suppress false positive from Coverity
This commit is contained in:
Takeshi Nakatani 2020-10-04 23:44:51 +09:00 committed by GitHub
commit cf86fa51b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -751,13 +751,14 @@ bool PageList::Serialize(CacheFileStat& file, bool is_output, ino_t inode)
return true;
}
char* ptmp = new char[st.st_size + 1];
ptmp[st.st_size] = '\0';
int res;
// read from file
if(0 >= pread(file.GetFd(), ptmp, st.st_size, 0)){
if(0 >= (res = pread(file.GetFd(), ptmp, st.st_size, 0))){
S3FS_PRN_ERR("failed to read stats(%d)", errno);
delete[] ptmp;
return false;
}
ptmp[res] = '\0';
std::string oneline;
std::istringstream ssall(ptmp);