Fixed Coverity reported issue. Issue is benign as all the member variables are initialized in after construction,

but I've moved this initialization into the constructor to make the code more managable.

CID 11686: Uninitialized scalar field (UNINIT_CTOR)
Non-static class member cnt is not initialized in this constructor nor in any functions that it calls.
Non-static class member maxcnt is not initialized in this constructor nor in any functions that it calls.
Non-static class member phase is not initialized in this constructor nor in any functions that it calls.
This commit is contained in:
Robert Osfield 2011-04-27 16:37:25 +00:00
parent 718fa5b679
commit c32b72e8c5
2 changed files with 4 additions and 5 deletions

View File

@ -28,7 +28,9 @@ class Barrier;
class Win32BarrierPrivateData {
friend class Barrier;
private:
Win32BarrierPrivateData() {};
Win32BarrierPrivateData(int mc, int c, int p):
maxcnt(mc), cnt(c), phase(p) {}
~Win32BarrierPrivateData();
Condition cond; // cv for waiters at barrier

View File

@ -34,10 +34,7 @@ Win32BarrierPrivateData::~Win32BarrierPrivateData()
// Use: public.
//
Barrier::Barrier(int numThreads) {
Win32BarrierPrivateData *pd = new Win32BarrierPrivateData();
pd->cnt = 0;
pd->phase = 0;
pd->maxcnt = numThreads;
Win32BarrierPrivateData *pd = new Win32BarrierPrivateData(numThreads, 0, 0);
_valid = true;
_prvData = static_cast<void *>(pd);
}