Fixed 2 Coverity reported issues. Both issues are benign, but I've addressed then as with the changes the
code is clean and more mantainable. CID 11676: Uninitialized scalar field (UNINIT_CTOR) Non-static class member cancelMode is not initialized in this constructor nor in any functions that it calls. Non-static class member cpunum is not initialized in this constructor nor in any functions that it calls. Non-static class member detached is not initialized in this constructor nor in any functions that it calls. Non-static class member isRunning is not initialized in this constructor nor in any functions that it calls. Non-static class member stackSize is not initialized in this constructor nor in any functions that it calls. Non-static class member threadPolicy is not initialized in this constructor nor in any functions that it calls. Non-static class member threadPriority is not initialized in this constructor nor in any functions that it calls. Non-static class member uniqueId is not initialized in this constructor nor in any functions that it calls. CID 11564: Unsigned compared against 0 (NO_EFFECT) This less-than-zero comparison of an unsigned value is never true. "cpunum < 0U".
This commit is contained in:
@@ -231,6 +231,19 @@ int Thread::GetConcurrency() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Win32ThreadPrivateData::Win32ThreadPrivateData()
|
||||
{
|
||||
stackSize = 0;
|
||||
isRunning = false;
|
||||
cancelMode = 0;
|
||||
uniqueId = 0;
|
||||
threadPriority = Thread::THREAD_PRIORITY_DEFAULT;
|
||||
threadPolicy = Thread::THREAD_SCHEDULE_DEFAULT;
|
||||
detached = false;
|
||||
cancelEvent.set(CreateEvent(NULL,TRUE,FALSE,NULL));
|
||||
cpunum = -1;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Description: Constructor
|
||||
@@ -244,16 +257,6 @@ Thread::Thread() {
|
||||
|
||||
Win32ThreadPrivateData *pd = new Win32ThreadPrivateData();
|
||||
|
||||
pd->stackSize = 0;
|
||||
pd->isRunning = false;
|
||||
pd->cancelMode = 0;
|
||||
pd->uniqueId = 0;
|
||||
pd->threadPriority = Thread::THREAD_PRIORITY_DEFAULT;
|
||||
pd->threadPolicy = Thread::THREAD_SCHEDULE_DEFAULT;
|
||||
pd->detached = false;
|
||||
pd->cancelEvent.set(CreateEvent(NULL,TRUE,FALSE,NULL));
|
||||
pd->cpunum = -1;
|
||||
|
||||
_prvData = static_cast<void *>(pd);
|
||||
}
|
||||
|
||||
@@ -678,8 +681,6 @@ int OpenThreads::GetNumberOfProcessors()
|
||||
|
||||
int OpenThreads::SetProcessorAffinityOfCurrentThread(unsigned int cpunum)
|
||||
{
|
||||
if (cpunum<0) return -1;
|
||||
|
||||
Thread::Init();
|
||||
|
||||
Thread* thread = Thread::CurrentThread();
|
||||
|
||||
Reference in New Issue
Block a user