Enable readability-implicit-bool-conversion (#2530)

This fixes one real error, one misreported EPERM, and some false
positives.  References #2529.
This commit is contained in:
Andrew Gaul 2024-09-28 15:28:50 +09:00 committed by GitHub
parent 52c10cd45d
commit df5364d758
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 8 deletions

View File

@ -71,7 +71,6 @@ Checks: '
-readability-function-cognitive-complexity, -readability-function-cognitive-complexity,
-readability-function-size, -readability-function-size,
-readability-identifier-length, -readability-identifier-length,
-readability-implicit-bool-conversion,
-readability-inconsistent-declaration-parameter-name, -readability-inconsistent-declaration-parameter-name,
-readability-isolate-declaration, -readability-isolate-declaration,
-readability-magic-numbers, -readability-magic-numbers,
@ -81,3 +80,6 @@ Checks: '
-readability-redundant-declaration, -readability-redundant-declaration,
-readability-simplify-boolean-expr, -readability-simplify-boolean-expr,
-readability-suspicious-call-argument' -readability-suspicious-call-argument'
CheckOptions:
readability-implicit-bool-conversion.AllowIntegerConditions: 'true'
readability-implicit-bool-conversion.AllowPointerConditions: 'true'

View File

@ -3122,7 +3122,7 @@ int S3fsCurl::GetIAMv2ApiToken(const char* token_url, int token_ttl, const char*
return -EIO; return -EIO;
} }
if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_INFILESIZE, 0)){ if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_INFILESIZE, 0)){
return false; return -EIO;
} }
if(!S3fsCurl::AddUserAgent(hCurl)){ // put User-Agent if(!S3fsCurl::AddUserAgent(hCurl)){ // put User-Agent
return -EIO; return -EIO;
@ -4280,8 +4280,9 @@ int S3fsCurl::UploadMultipartPostRequest(const char* tpath, int part_num, const
// request // request
if(0 == (result = RequestPerform())){ if(0 == (result = RequestPerform())){
// UploadMultipartPostComplete returns true on success -> convert to 0 if(!UploadMultipartPostComplete()){
result = !UploadMultipartPostComplete(); result = -EIO;
}
} }
// closing // closing

View File

@ -279,7 +279,7 @@ static bool IS_RMTYPEDIR(dirtype type)
static bool IS_CREATE_MP_STAT(const char* path) static bool IS_CREATE_MP_STAT(const char* path)
{ {
// [NOTE] has_mp_stat is set in get_object_attribute() // [NOTE] has_mp_stat is set in get_object_attribute()
return (path && 0 == strcmp(path, "/") && !has_mp_stat); return (path != nullptr && 0 == strcmp(path, "/") && !has_mp_stat);
} }
static bool is_special_name_folder_object(const char* path) static bool is_special_name_folder_object(const char* path)

View File

@ -241,9 +241,9 @@ bool S3fsCred::SetAccessKey(const char* AccessKeyId, const char* SecretAccessKey
bool S3fsCred::SetAccessKeyWithSessionToken(const char* AccessKeyId, const char* SecretAccessKey, const char * SessionToken) bool S3fsCred::SetAccessKeyWithSessionToken(const char* AccessKeyId, const char* SecretAccessKey, const char * SessionToken)
{ {
bool access_key_is_empty = !AccessKeyId || '\0' == AccessKeyId[0]; bool access_key_is_empty = AccessKeyId == nullptr || '\0' == AccessKeyId[0];
bool secret_access_key_is_empty = !SecretAccessKey || '\0' == SecretAccessKey[0]; bool secret_access_key_is_empty = SecretAccessKey == nullptr || '\0' == SecretAccessKey[0];
bool session_token_is_empty = !SessionToken || '\0' == SessionToken[0]; bool session_token_is_empty = SessionToken == nullptr || '\0' == SessionToken[0];
if((!is_ibm_iam_auth && access_key_is_empty) || secret_access_key_is_empty || session_token_is_empty){ if((!is_ibm_iam_auth && access_key_is_empty) || secret_access_key_is_empty || session_token_is_empty){
return false; return false;