From c32b72e8c5108cbf30147c9d0bd5bf2af9fba13b Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 27 Apr 2011 16:37:25 +0000 Subject: [PATCH] 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. --- src/OpenThreads/win32/Win32BarrierPrivateData.h | 4 +++- src/OpenThreads/win32/Win32ThreadBarrier.cpp | 5 +---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/OpenThreads/win32/Win32BarrierPrivateData.h b/src/OpenThreads/win32/Win32BarrierPrivateData.h index 7452d9b71..72c738cf8 100644 --- a/src/OpenThreads/win32/Win32BarrierPrivateData.h +++ b/src/OpenThreads/win32/Win32BarrierPrivateData.h @@ -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 diff --git a/src/OpenThreads/win32/Win32ThreadBarrier.cpp b/src/OpenThreads/win32/Win32ThreadBarrier.cpp index a7a980373..ba9977bb6 100644 --- a/src/OpenThreads/win32/Win32ThreadBarrier.cpp +++ b/src/OpenThreads/win32/Win32ThreadBarrier.cpp @@ -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(pd); }