Use C++11 nullptr instead of 0 or NULL (#2234)

This improves type-safety.
This commit is contained in:
Andrew Gaul
2023-07-27 21:56:58 +09:00
committed by GitHub
parent 0ece204393
commit a4a2841c05
46 changed files with 537 additions and 538 deletions

View File

@ -30,7 +30,7 @@
//------------------------------------------------
// ThreadPoolMan class variables
//------------------------------------------------
ThreadPoolMan* ThreadPoolMan::singleton = NULL;
ThreadPoolMan* ThreadPoolMan::singleton = nullptr;
//------------------------------------------------
// ThreadPoolMan class methods
@ -49,7 +49,7 @@ void ThreadPoolMan::Destroy()
{
if(ThreadPoolMan::singleton){
delete ThreadPoolMan::singleton;
ThreadPoolMan::singleton = NULL;
ThreadPoolMan::singleton = nullptr;
}
}
@ -96,13 +96,13 @@ void* ThreadPoolMan::Worker(void* arg)
}
}else{
S3FS_PRN_WARN("Got a semaphore, but there is no instruction.");
pparam = NULL;
pparam = nullptr;
}
}
if(pparam){
void* retval = pparam->pfunc(pparam->args);
if(NULL != retval){
if(nullptr != retval){
S3FS_PRN_WARN("The instruction function returned with somthign error code(%ld).", reinterpret_cast<long>(retval));
}
if(pparam->psem){
@ -112,7 +112,7 @@ void* ThreadPoolMan::Worker(void* arg)
}
}
return NULL;
return nullptr;
}
//------------------------------------------------
@ -204,7 +204,7 @@ bool ThreadPoolMan::StopThreads()
// wait for threads exiting
for(thread_list_t::const_iterator iter = thread_list.begin(); iter != thread_list.end(); ++iter){
void* retval = NULL;
void* retval = nullptr;
int result = pthread_join(*iter, &retval);
if(result){
S3FS_PRN_ERR("failed pthread_join - result(%d)", result);
@ -249,7 +249,7 @@ bool ThreadPoolMan::StartThreads(int count)
// run thread
pthread_t thread;
int result;
if(0 != (result = pthread_create(&thread, NULL, ThreadPoolMan::Worker, static_cast<void*>(this)))){
if(0 != (result = pthread_create(&thread, nullptr, ThreadPoolMan::Worker, static_cast<void*>(this)))){
S3FS_PRN_ERR("failed pthread_create with return code(%d)", result);
StopThreads(); // if possible, stop all threads
return false;
@ -262,7 +262,7 @@ bool ThreadPoolMan::StartThreads(int count)
bool ThreadPoolMan::SetInstruction(thpoolman_param* pparam)
{
if(!pparam){
S3FS_PRN_ERR("The parameter value is NULL.");
S3FS_PRN_ERR("The parameter value is nullptr.");
return false;
}