Avoid C-style casts (#2015)

Prefer more precise C++-style casts.
This commit is contained in:
Andrew Gaul 2022-07-30 22:35:27 +09:00 committed by GitHub
parent c491fbeabc
commit 3e242d0bad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 19 deletions

View File

@ -7,6 +7,7 @@ Checks: '
-bugprone-macro-parentheses,
-bugprone-narrowing-conversions,
-bugprone-unhandled-self-assignment,
cppcoreguidelines-pro-type-cstyle-cast,
google-*,
-google-build-using-namespace,
-google-readability-casting,

View File

@ -140,9 +140,9 @@ int S3fsMultiCurl::MultiPerform()
success = false;
S3FS_PRN_ERR("failed pthread_join - rc(%d) %s", rc, strerror(rc));
} else {
int int_retval = (int)(intptr_t)(retval);
long int_retval = reinterpret_cast<long>(retval);
if (int_retval && !(int_retval == -ENOENT && isMultiHead)) {
S3FS_PRN_WARN("thread terminated with non-zero return code: %d", int_retval);
S3FS_PRN_WARN("thread terminated with non-zero return code: %ld", int_retval);
}
}
}
@ -176,9 +176,9 @@ int S3fsMultiCurl::MultiPerform()
success = false;
S3FS_PRN_ERR("failed pthread_join - rc(%d)", rc);
} else {
int int_retval = (int)(intptr_t)(retval);
long int_retval = reinterpret_cast<long>(retval);
if (int_retval && !(int_retval == -ENOENT && isMultiHead)) {
S3FS_PRN_WARN("thread terminated with non-zero return code: %d", int_retval);
S3FS_PRN_WARN("thread terminated with non-zero return code: %ld", int_retval);
}
}
}

View File

@ -52,7 +52,7 @@ void* PseudoFdInfo::MultipartUploadThreadWorker(void* arg)
if(pthparam){
delete pthparam;
}
return (void*)(intptr_t)(-EIO);
return reinterpret_cast<void*>(-EIO);
}
S3FS_PRN_INFO3("Upload Part Thread [tpath=%s][start=%lld][size=%lld][part=%d]", pthparam->path.c_str(), static_cast<long long>(pthparam->start), static_cast<long long>(pthparam->size), pthparam->part_num);
@ -68,7 +68,7 @@ void* PseudoFdInfo::MultipartUploadThreadWorker(void* arg)
result = -EIO;
}
delete pthparam;
return (void*)(intptr_t)(result);
return reinterpret_cast<void*>(result);
}
}
@ -81,7 +81,7 @@ void* PseudoFdInfo::MultipartUploadThreadWorker(void* arg)
result = -EIO;
}
delete pthparam;
return (void*)(intptr_t)(result);
return reinterpret_cast<void*>(result);
}
// Send request and get result
@ -103,7 +103,7 @@ void* PseudoFdInfo::MultipartUploadThreadWorker(void* arg)
}
delete pthparam;
return (void*)(intptr_t)(result);
return reinterpret_cast<void*>(result);
}
//------------------------------------------------

View File

@ -153,7 +153,7 @@ static char* get_object_name(xmlDocPtr doc, xmlNodePtr node, const char* path)
// basepath(path) is as same as fullpath.
if(0 == strcmp(reinterpret_cast<char*>(fullpath), path)){
xmlFree(fullpath);
return (char*)c_strErrorObjectName;
return const_cast<char*>(c_strErrorObjectName);
}
// Make dir path and filename
@ -172,15 +172,15 @@ static char* get_object_name(xmlDocPtr doc, xmlNodePtr node, const char* path)
if(0 < strlen(dirpath)){
// case of "/"
if(0 == strcmp(mybname, "/") && 0 == strcmp(dirpath, "/")){
return (char*)c_strErrorObjectName;
return const_cast<char*>(c_strErrorObjectName);
}
// case of "."
if(0 == strcmp(mybname, ".") && 0 == strcmp(dirpath, ".")){
return (char*)c_strErrorObjectName;
return const_cast<char *>(c_strErrorObjectName);
}
// case of ".."
if(0 == strcmp(mybname, "..") && 0 == strcmp(dirpath, ".")){
return (char*)c_strErrorObjectName;
return const_cast<char *>(c_strErrorObjectName);
}
// case of "name"
if(0 == strcmp(dirpath, ".")){
@ -206,7 +206,7 @@ static char* get_object_name(xmlDocPtr doc, xmlNodePtr node, const char* path)
}
}
// case of something wrong
return (char*)c_strErrorObjectName;
return const_cast<char*>(c_strErrorObjectName);
}
static xmlChar* get_exp_value_xml(xmlDocPtr doc, xmlXPathContextPtr ctx, const char* exp_key)

View File

@ -71,7 +71,7 @@ void* ThreadPoolMan::Worker(void* arg)
if(!psingleton){
S3FS_PRN_ERR("The parameter for worker thread is invalid.");
return (void*)(intptr_t)(-EIO);
return reinterpret_cast<void*>(-EIO);
}
S3FS_PRN_INFO3("Start worker thread in ThreadPoolMan.");
@ -102,9 +102,8 @@ void* ThreadPoolMan::Worker(void* arg)
if(pparam){
void* retval = pparam->pfunc(pparam->args);
int int_retval = (int)(intptr_t)(retval);
if(0 != int_retval){
S3FS_PRN_WARN("The instruction function returned with somthign error code(%d).", int_retval);
if(NULL != retval){
S3FS_PRN_WARN("The instruction function returned with somthign error code(%ld).", reinterpret_cast<long>(retval));
}
if(pparam->psem){
pparam->psem->post();
@ -113,7 +112,7 @@ void* ThreadPoolMan::Worker(void* arg)
}
}
return (void*)(intptr_t)(0);
return NULL;
}
//------------------------------------------------
@ -210,7 +209,7 @@ bool ThreadPoolMan::StopThreads()
if(result){
S3FS_PRN_ERR("failed pthread_join - result(%d)", result);
}else{
S3FS_PRN_DBG("succeed pthread_join - return code(%d)", (int)(intptr_t)(retval));
S3FS_PRN_DBG("succeed pthread_join - return code(%ld)", reinterpret_cast<long>(retval));
}
}
thread_list.clear();