[Fix coverity warning]: Initialize all members of RangeIteratorLL 25/78425/2
authorManu Dhundi <manu@couchbase.com>
Mon, 22 May 2017 19:05:18 +0000 (12:05 -0700)
committerDave Rigby <daver@couchbase.com>
Tue, 23 May 2017 10:58:01 +0000 (10:58 +0000)
We must always initialize all the non static members of the RangeIteratorLL
class in the constructor.

Below is the warning reported by coverity:
*** CID 169606:  Uninitialized members  (UNINIT_CTOR)
/ep-engine/src/linked_list.cc: 430 in BasicLinkedList::RangeIteratorLL::RangeIteratorLL(BasicLinkedList&)()
424         std::lock_guard<std::mutex> listWriteLg(list.getListWriteLock());
425         std::lock_guard<SpinLock> lh(list.rangeLock);
426         if (list.highSeqno < 1) {
427             /* No need of holding a lock for the snapshot as there are no items;
428                Also iterator range is at default (0, 0) */
429             readLockHolder.unlock();
   CID 169606:  Uninitialized members  (UNINIT_CTOR)
   Non-static class member "earlySnapShotEndSeqno" is not initialized in this constructor nor in any functions that it calls.
430             return;
431         }
432
433         /* Iterator to the beginning of linked list */
434         currIt = list.seqList.begin();

Change-Id: Ie3e26d685159e24054ad94d8f04bc455c8e3c4f2
Reviewed-on: http://review.couchbase.org/78425
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
src/linked_list.cc

index 95402fe..78ad68e 100644 (file)
@@ -420,7 +420,8 @@ BasicLinkedList::RangeIteratorLL::RangeIteratorLL(BasicLinkedList& ll)
     : list(ll),
       readLockHolder(list.rangeReadLock),
       itrRange(0, 0),
-      numRemaining(0) {
+      numRemaining(0),
+      earlySnapShotEndSeqno(0) {
     std::lock_guard<std::mutex> listWriteLg(list.getListWriteLock());
     std::lock_guard<SpinLock> lh(list.rangeLock);
     if (list.highSeqno < 1) {