From 34cedaff66619769ac51ba79a6fd15536a7f6c5d Mon Sep 17 00:00:00 2001 From: Andres Noetzli Date: Fri, 11 Sep 2015 12:07:54 -0700 Subject: [PATCH] Initialize variable to avoid warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: RocksDB debug version failed to build under gcc-4.8.1 on sandcastle with the following error: ``` db/db_compaction_filter_test.cc:570:33: error: ‘snapshot’ may be used uninitialized in this function [-Werror=maybe-uninitialized] ``` Test Plan: make db_compaction_filter_test && ./db_compaction_filter_test Reviewers: rven, anthony, yhchiang, aekmekji, igor, sdong Reviewed By: igor, sdong Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D46725 --- db/db_compaction_filter_test.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/db_compaction_filter_test.cc b/db/db_compaction_filter_test.cc index 055c1bb76..a1587f283 100644 --- a/db/db_compaction_filter_test.cc +++ b/db/db_compaction_filter_test.cc @@ -548,7 +548,7 @@ TEST_F(DBTestCompactionFilter, CompactionFilterSnapshot) { DestroyAndReopen(options); // Put some data. - const Snapshot* snapshot; + const Snapshot* snapshot = nullptr; for (int table = 0; table < 4; ++table) { for (int i = 0; i < 10; ++i) { Put(ToString(table * 100 + i), "val"); @@ -559,6 +559,7 @@ TEST_F(DBTestCompactionFilter, CompactionFilterSnapshot) { snapshot = db_->GetSnapshot(); } } + assert(snapshot != nullptr); cfilter_count = 0; ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr));