Merge pull request #903 from gaul/clang-tidy/find_char

Prefer find(char) over find(const char *)
This commit is contained in:
Takeshi Nakatani 2019-01-20 14:05:06 +09:00 committed by GitHub
commit 6aa40b2747
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 11 deletions

View File

@ -2903,7 +2903,7 @@ static bool parse_xattr_keyval(const std::string& xattrpair, string& key, PXATTR
// parse key and value
size_t pos;
string tmpval;
if(string::npos == (pos = xattrpair.find_first_of(":"))){
if(string::npos == (pos = xattrpair.find_first_of(':'))){
S3FS_PRN_ERR("one of xattr pair(%s) is wrong format.", xattrpair.c_str());
return false;
}
@ -2934,8 +2934,8 @@ static size_t parse_xattrs(const std::string& strxattrs, xattrs_t& xattrs)
{
size_t startpos;
size_t endpos = string::npos;
if(string::npos != (startpos = jsonxattrs.find_first_of("{"))){
endpos = jsonxattrs.find_last_of("}");
if(string::npos != (startpos = jsonxattrs.find_first_of('{'))){
endpos = jsonxattrs.find_last_of('}');
}
if(startpos == string::npos || endpos == string::npos || endpos <= startpos){
S3FS_PRN_WARN("xattr header(%s) is not json format.", jsonxattrs.c_str());
@ -2945,7 +2945,7 @@ static size_t parse_xattrs(const std::string& strxattrs, xattrs_t& xattrs)
}
// parse each key:val
for(size_t pair_nextpos = restxattrs.find_first_of(","); 0 < restxattrs.length(); restxattrs = (pair_nextpos != string::npos ? restxattrs.substr(pair_nextpos + 1) : string("")), pair_nextpos = restxattrs.find_first_of(",")){
for(size_t pair_nextpos = restxattrs.find_first_of(','); 0 < restxattrs.length(); restxattrs = (pair_nextpos != string::npos ? restxattrs.substr(pair_nextpos + 1) : string("")), pair_nextpos = restxattrs.find_first_of(',')){
string pair = pair_nextpos != string::npos ? restxattrs.substr(0, pair_nextpos) : restxattrs;
string key = "";
PXATTRVAL pval = NULL;
@ -3869,7 +3869,7 @@ static int parse_passwd_file(bucketkvmap_t& resmap)
S3FS_PRN_EXIT("invalid line in passwd file, found whitespace character.");
return -1;
}
if(0 == line.find_first_of("[")){
if(0 == line.find_first_of('[')){
S3FS_PRN_EXIT("invalid line in passwd file, found a bracket \"[\" character.");
return -1;
}
@ -4960,7 +4960,7 @@ int main(int argc, char* argv[])
// get program name - emulate basename
program_name.assign(argv[0]);
size_t found = program_name.find_last_of("/");
size_t found = program_name.find_last_of('/');
if(found != string::npos){
program_name.replace(0, found+1, "");
}

View File

@ -283,7 +283,7 @@ bool S3ObjList::MakeHierarchizedList(s3obj_list_t& list, bool haveSlash)
h_map[strtmp] = true;
// check hierarchized directory
for(string::size_type pos = strtmp.find_last_of("/"); string::npos != pos; pos = strtmp.find_last_of("/")){
for(string::size_type pos = strtmp.find_last_of('/'); string::npos != pos; pos = strtmp.find_last_of('/')){
strtmp = strtmp.substr(0, pos);
if(0 == strtmp.length() || "/" == strtmp){
break;
@ -822,7 +822,7 @@ mode_t get_mode(headers_t& meta, const char* path, bool checkdir, bool forcedir)
if(meta.end() != (iter = meta.find("Content-Type"))){
string strConType = (*iter).second;
// Leave just the mime type, remove any optional parameters (eg charset)
string::size_type pos = strConType.find(";");
string::size_type pos = strConType.find(';');
if(string::npos != pos){
strConType = strConType.substr(0, pos);
}

View File

@ -210,15 +210,15 @@ bool takeout_str_dquart(string& str)
size_t pos;
// '"' for start
if(string::npos != (pos = str.find_first_of("\""))){
if(string::npos != (pos = str.find_first_of('\"'))){
str = str.substr(pos + 1);
// '"' for end
if(string::npos == (pos = str.find_last_of("\""))){
if(string::npos == (pos = str.find_last_of('\"'))){
return false;
}
str = str.substr(0, pos);
if(string::npos != str.find_first_of("\"")){
if(string::npos != str.find_first_of('\"')){
return false;
}
}