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:
Robert Osfield
2011-04-27 16:35:34 +00:00
parent 91430e9c54
commit 718fa5b679
2 changed files with 14 additions and 13 deletions

View File

@@ -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();