From 7b57510a17a5afb30e9e7f426c55cfc4b3140e24 Mon Sep 17 00:00:00 2001
From: Prashant D <pdhange@redhat.com>
Date: Tue, 28 Nov 2017 12:17:11 -0800
Subject: [PATCH] utilities: Fix coverity issues in blob_db and col_buf_decoder

Summary:
utilities/blob_db/blob_db_impl.cc
265                    : bdb_options_.blob_dir;
   	3. uninit_member: Non-static class member env_ is not initialized in this constructor nor in any functions that it calls.
   	5. uninit_member: Non-static class member ttl_extractor_ is not initialized in this constructor nor in any functions that it calls.
   	7. uninit_member: Non-static class member open_p1_done_ is not initialized in this constructor nor in any functions that it calls.

CID 1418245 (#1 of 1): Uninitialized pointer field (UNINIT_CTOR)
9. uninit_member: Non-static class member debug_level_ is not initialized in this constructor nor in any functions that it calls.
266}

   	4. past_the_end: Function end creates an iterator.

CID 1418258 (#1 of 1): Using invalid iterator (INVALIDATE_ITERATOR)
5. deref_iterator: Dereferencing iterator file_nums.end() though it is already past the end of its container.

utilities/col_buf_decoder.h:
     nullable_(nullable),
   	2. uninit_member: Non-static class member remain_runs_ is not initialized in this constructor nor in any functions that it calls.
   	4. uninit_member: Non-static class member run_val_ is not initialized in this constructor nor in any functions that it calls.

CID 1396134 (#1 of 1): Uninitialized scalar field (UNINIT_CTOR)
6. uninit_member: Non-static class member last_val_ is not initialized in this constructor nor in any functions that it calls.
 46        big_endian_(big_endian) {}
Closes https://github.com/facebook/rocksdb/pull/3134

Differential Revision: D6340607

Pulled By: sagar0

fbshipit-source-id: 25c52566e2ff979fe6c7abb0f40c27fc16597054
---
 utilities/blob_db/blob_db_impl.cc | 4 ++++
 utilities/col_buf_decoder.h       | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/utilities/blob_db/blob_db_impl.cc b/utilities/blob_db/blob_db_impl.cc
index fc8110d22..0a51acdc7 100644
--- a/utilities/blob_db/blob_db_impl.cc
+++ b/utilities/blob_db/blob_db_impl.cc
@@ -159,6 +159,8 @@ BlobDBOptions BlobDBImpl::GetBlobDBOptions() const { return bdb_options_; }
 BlobDBImpl::BlobDBImpl(DB* db, const BlobDBOptions& blob_db_options)
     : BlobDB(db),
       db_impl_(static_cast_with_check<DBImpl, DB>(db)),
+      env_(nullptr),
+      ttl_extractor_(nullptr),
       bdb_options_(blob_db_options),
       db_options_(db->GetOptions()),
       env_options_(db_->GetOptions()),
@@ -170,6 +172,8 @@ BlobDBImpl::BlobDBImpl(DB* db, const BlobDBOptions& blob_db_options)
       current_epoch_(0),
       open_file_count_(0),
       total_blob_space_(0),
+      open_p1_done_(false),
+      debug_level_(0),
       oldest_file_evicted_(false) {
   if (!bdb_options_.blob_dir.empty())
     blob_dir_ = (bdb_options_.path_relative)
diff --git a/utilities/col_buf_decoder.h b/utilities/col_buf_decoder.h
index e795e4ecd..0311a4100 100644
--- a/utilities/col_buf_decoder.h
+++ b/utilities/col_buf_decoder.h
@@ -43,7 +43,10 @@ class FixedLengthColBufDecoder : public ColBufDecoder {
       : size_(size),
         col_compression_type_(col_compression_type),
         nullable_(nullable),
-        big_endian_(big_endian) {}
+        big_endian_(big_endian),
+        remain_runs_(0),
+        run_val_(0),
+        last_val_(0) {}
 
   size_t Init(const char* src) override;
   size_t Decode(const char* src, char** dest) override;