Prefer std::string::clear where possible (#2467)

This is somewhat more clear and is declared noexcept.
This commit is contained in:
Andrew Gaul 2024-06-10 23:36:49 +09:00 committed by GitHub
parent ba7b2ef9f0
commit ebae5a302f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 23 additions and 23 deletions

View File

@ -885,17 +885,17 @@ bool S3fsCurl::FinalCheckSse()
{
switch(S3fsCurl::ssetype){
case sse_type_t::SSE_DISABLE:
S3fsCurl::ssekmsid.erase();
S3fsCurl::ssekmsid.clear();
return true;
case sse_type_t::SSE_S3:
S3fsCurl::ssekmsid.erase();
S3fsCurl::ssekmsid.clear();
return true;
case sse_type_t::SSE_C:
if(S3fsCurl::sseckeys.empty()){
S3FS_PRN_ERR("sse type is SSE-C, but there is no custom key.");
return false;
}
S3fsCurl::ssekmsid.erase();
S3fsCurl::ssekmsid.clear();
return true;
case sse_type_t::SSE_KMS:
if(S3fsCurl::ssekmsid.empty()){
@ -3091,7 +3091,7 @@ int S3fsCurl::GetIAMv2ApiToken(const char* token_url, int token_ttl, const char*
S3FS_PRN_ERR("IAMv2 token url(%s) or ttl_hdr(%s) parameter are wrong.", token_url ? token_url : "null", token_ttl_hdr ? token_ttl_hdr : "null");
return -EIO;
}
response.erase();
response.clear();
url = token_url;
if(!CreateCurlHandle()){
return -EIO;
@ -3154,7 +3154,7 @@ bool S3fsCurl::GetIAMCredentials(const char* cred_url, const char* iam_v2_token,
return false;
}
url = cred_url;
response.erase();
response.clear();
// at first set type for handle
type = REQTYPE::IAMCRED;
@ -3240,7 +3240,7 @@ bool S3fsCurl::GetIAMRoleFromMetaData(const char* cred_url, const char* iam_v2_t
return false;
}
url = cred_url;
token.erase();
token.clear();
S3FS_PRN_INFO3("Get IAM Role name");

View File

@ -105,7 +105,7 @@ bool FdManager::SetCacheDir(const char* dir)
bool FdManager::SetCacheCheckOutput(const char* path)
{
if(!path || '\0' == path[0]){
check_cache_output.erase();
check_cache_output.clear();
}else{
check_cache_output = path;
}

View File

@ -180,7 +180,7 @@ void FdEntity::Clear()
if(-1 == unlink(mirrorpath.c_str())){
S3FS_PRN_WARN("failed to remove mirror cache file(%s) by errno(%d).", mirrorpath.c_str(), errno);
}
mirrorpath.erase();
mirrorpath.clear();
}
}
pagelist.Init(0, false, false);
@ -250,7 +250,7 @@ void FdEntity::Close(int fd)
if(-1 == unlink(mirrorpath.c_str())){
S3FS_PRN_WARN("failed to remove mirror cache file(%s) by errno(%d).", mirrorpath.c_str(), errno);
}
mirrorpath.erase();
mirrorpath.clear();
}
}
}
@ -764,7 +764,7 @@ bool FdEntity::RenamePath(const std::string& newpath, std::string& fentmapkey)
}else{
// does not have cache path
fentmapkey.erase();
fentmapkey.clear();
FdManager::MakeRandomTempPath(newpath.c_str(), fentmapkey);
}
// set new path
@ -1156,8 +1156,8 @@ int FdEntity::NoCacheLoadAndPost(PseudoFdInfo* pseudo_obj, off_t start, off_t si
// remove cache files(and cache stat file)
FdManager::DeleteCacheFile(path.c_str());
// cache file path does not use no more.
cachepath.erase();
mirrorpath.erase();
cachepath.clear();
mirrorpath.clear();
}
// Change entity key in manager mapping

View File

@ -251,7 +251,7 @@ bool PseudoFdInfo::ResetUploadInfo(AutoLock::Type type)
{
AutoLock auto_lock(&upload_list_lock, type);
upload_id.erase();
upload_id.clear();
upload_list.clear();
instruct_count = 0;
completed_count = 0;

View File

@ -902,7 +902,7 @@ bool get_object_sse_type(const char* path, sse_type_t& ssetype, std::string& sse
}
ssetype = sse_type_t::SSE_DISABLE;
ssevalue.erase();
ssevalue.clear();
for(headers_t::iterator iter = meta.begin(); iter != meta.end(); ++iter){
std::string key = (*iter).first;
if(0 == strcasecmp(key.c_str(), "x-amz-server-side-encryption") && 0 == strcasecmp((*iter).second.c_str(), "AES256")){
@ -3601,7 +3601,7 @@ static bool get_meta_xattr_value(const char* path, std::string& rawvalue)
}
S3FS_PRN_DBG("[path=%s]", path);
rawvalue.erase();
rawvalue.clear();
headers_t meta;
if(0 != get_object_attribute(path, nullptr, &meta)){
@ -3634,7 +3634,7 @@ static bool get_parent_meta_xattr_value(const char* path, std::string& rawvalue)
static bool get_xattr_posix_key_value(const char* path, std::string& xattrvalue, bool default_key)
{
xattrvalue.erase();
xattrvalue.clear();
std::string rawvalue;
if(!get_meta_xattr_value(path, rawvalue)){
@ -3673,7 +3673,7 @@ static bool build_inherited_xattr_value(const char* path, std::string& xattrvalu
{
S3FS_PRN_DBG("[path=%s]", path);
xattrvalue.erase();
xattrvalue.clear();
if(0 == strcmp(path, "/") || 0 == strcmp(path, ".")){
// path is mount point, thus does not have parent.

View File

@ -1175,7 +1175,7 @@ bool S3fsCred::CheckIAMCredentialUpdate(std::string* access_key_id, std::string*
if(IsIBMIAMAuth() || IsSetExtCredLib() || is_ecs || is_use_session_token || IsSetIAMRole(AutoLock::ALREADY_LOCKED)){
*access_token = AWSAccessToken;
}else{
access_token->erase();
access_token->clear();
}
}

View File

@ -80,7 +80,7 @@ bool S3ObjList::insert(const char* name, const char* etag, bool is_dir)
// Add object
if(objects.end() != (iter = objects.find(newname))){
// Found same object --> update information.
(*iter).second.normalname.erase();
(*iter).second.normalname.clear();
(*iter).second.orgname = orgname;
(*iter).second.is_dir = is_dir;
if(etag){
@ -113,8 +113,8 @@ bool S3ObjList::insert_normalized(const char* name, const char* normalized, bool
s3obj_t::iterator iter;
if(objects.end() != (iter = objects.find(name))){
// found name --> over write
iter->second.orgname.erase();
iter->second.etag.erase();
iter->second.orgname.clear();
iter->second.etag.clear();
iter->second.normalname = normalized;
iter->second.is_dir = is_dir;
}else{

View File

@ -149,7 +149,7 @@ struct etagpair
void clear()
{
etag.erase();
etag.clear();
part_num = -1;
}
};

View File

@ -109,7 +109,7 @@ static bool parse_string(const char* pstr, char delim, strlist_t& strlist)
strAll = strAll.substr(pos + 1);
}else{
strlist.push_back(strAll);
strAll.erase();
strAll.clear();
}
}
return true;