Fixed codes for cppcheck 2.4.1

This commit is contained in:
Takeshi Nakatani 2021-04-12 22:36:09 +00:00 committed by Andrew Gaul
parent 01a26a9011
commit 2908878988
2 changed files with 17 additions and 14 deletions

View File

@ -77,10 +77,10 @@ bool AdditionalHeader::Load(const char* file)
std::string line; std::string line;
ADDHEAD *paddhead; ADDHEAD *paddhead;
while(getline(AH, line)){ while(getline(AH, line)){
if('#' == line[0]){ if(line.empty()){
continue; continue;
} }
if(line.empty()){ if('#' == line[0]){
continue; continue;
} }
// load a line // load a line

View File

@ -414,10 +414,10 @@ bool S3fsCurl::InitMimeType(const std::string& strFile)
S3fsCurl::mimeTypes.clear(); S3fsCurl::mimeTypes.clear();
while(getline(MT, line)){ while(getline(MT, line)){
if(line[0]=='#'){ if(line.empty()){
continue; continue;
} }
if(line.empty()){ if(line[0]=='#'){
continue; continue;
} }
@ -3302,7 +3302,7 @@ int S3fsCurl::PreGetObjectRequest(const char* tpath, int fd, off_t start, off_t
requestHeaders = NULL; requestHeaders = NULL;
responseHeaders.clear(); responseHeaders.clear();
if(-1 != start && 0 < size){ if(0 < size){
std::string range = "bytes="; std::string range = "bytes=";
range += str(start); range += str(start);
range += "-"; range += "-";
@ -3563,28 +3563,30 @@ int S3fsCurl::CompleteMultipartPostRequest(const char* tpath, const std::string&
} }
// make contents // make contents
std::string postContent; std::string* pPostContent = new std::string();
postContent += "<CompleteMultipartUpload>\n"; (*pPostContent) += "<CompleteMultipartUpload>\n";
int cnt = 0; int cnt = 0;
for(etaglist_t::iterator it = parts.begin(); it != parts.end(); ++it, ++cnt){ for(etaglist_t::iterator it = parts.begin(); it != parts.end(); ++it, ++cnt){
if(it->empty()){ if(it->empty()){
S3FS_PRN_ERR("%d file part is not finished uploading.", cnt + 1); S3FS_PRN_ERR("%d file part is not finished uploading.", cnt + 1);
delete pPostContent;
return -EIO; return -EIO;
} }
postContent += "<Part>\n"; (*pPostContent) += "<Part>\n";
postContent += " <PartNumber>" + str(cnt + 1) + "</PartNumber>\n"; (*pPostContent) += " <PartNumber>" + str(cnt + 1) + "</PartNumber>\n";
postContent += " <ETag>" + *it + "</ETag>\n"; (*pPostContent) += " <ETag>" + *it + "</ETag>\n";
postContent += "</Part>\n"; (*pPostContent) += "</Part>\n";
} }
postContent += "</CompleteMultipartUpload>\n"; (*pPostContent) += "</CompleteMultipartUpload>\n";
// set postdata // set postdata
postdata = reinterpret_cast<const unsigned char*>(postContent.c_str()); postdata = reinterpret_cast<const unsigned char*>(pPostContent->c_str());
b_postdata = postdata; b_postdata = postdata;
postdata_remaining = postContent.size(); // without null postdata_remaining = pPostContent->size(); // without null
b_postdata_remaining = postdata_remaining; b_postdata_remaining = postdata_remaining;
if(!CreateCurlHandle()){ if(!CreateCurlHandle()){
delete pPostContent;
return -EIO; return -EIO;
} }
std::string resource; std::string resource;
@ -3623,6 +3625,7 @@ int S3fsCurl::CompleteMultipartPostRequest(const char* tpath, const std::string&
int result = RequestPerform(); int result = RequestPerform();
bodydata.Clear(); bodydata.Clear();
postdata = NULL; postdata = NULL;
delete pPostContent;
return result; return result;
} }