summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorChris Mumford <cmumford@google.com>2019-04-12 18:34:19 -0700
committerChris Mumford <cmumford@google.com>2019-04-12 18:50:15 -0700
commit2f008ac19ec783e4d0ba2161320241c99e9897e1 (patch)
tree3f2b1962089d40a9c46a743ef80d85076bde60c7 /db
parentffabb1ae86cc4eb4516a7c0824c878c3b2d19e5d (diff)
downloadleveldb-2f008ac19ec783e4d0ba2161320241c99e9897e1.tar.gz
Initialize class members to default values in constructors.
There were a few members which were identified to have been left uninitialized in some constructors. These were very likely to have been set before being used, otherwise the ASan tests would have caught them, but still good practice to have them initialized. This addresses some items reported in issue #668. PiperOrigin-RevId: 243370145
Diffstat (limited to 'db')
-rw-r--r--db/db_bench.cc5
-rw-r--r--db/db_impl.cc7
2 files changed, 5 insertions, 7 deletions
diff --git a/db/db_bench.cc b/db/db_bench.cc
index f9403f4..41e903b 100644
--- a/db/db_bench.cc
+++ b/db/db_bench.cc
@@ -304,10 +304,7 @@ struct ThreadState {
Stats stats;
SharedState* shared;
- ThreadState(int index)
- : tid(index),
- rand(1000 + index) {
- }
+ ThreadState(int index) : tid(index), rand(1000 + index), shared(nullptr) {}
};
} // namespace
diff --git a/db/db_impl.cc b/db/db_impl.cc
index 3468862..caef2b1 100644
--- a/db/db_impl.cc
+++ b/db/db_impl.cc
@@ -48,7 +48,8 @@ struct DBImpl::Writer {
bool done;
port::CondVar cv;
- explicit Writer(port::Mutex* mu) : cv(mu) { }
+ explicit Writer(port::Mutex* mu)
+ : batch(nullptr), sync(false), done(false), cv(mu) {}
};
struct DBImpl::CompactionState {
@@ -78,10 +79,10 @@ struct DBImpl::CompactionState {
explicit CompactionState(Compaction* c)
: compaction(c),
+ smallest_snapshot(0),
outfile(nullptr),
builder(nullptr),
- total_bytes(0) {
- }
+ total_bytes(0) {}
};
// Fix user-supplied options to be reasonable