From 3189398c006e8968a87bb5ca068f8b74e949c4f7 Mon Sep 17 00:00:00 2001 From: Yanqin Jin Date: Fri, 12 Apr 2019 10:42:06 -0700 Subject: [PATCH] Fix bugs detected by clang analyzer (#5185) Summary: as titled. False positive included, fixed anyway to make the check pass. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5185 Differential Revision: D14909384 Pulled By: riversand963 fbshipit-source-id: dc5177e72b1929ccfd6175a60e2cd7bdb9bd80f3 --- db/db_basic_test.cc | 1 + table/full_filter_block.cc | 2 +- tools/db_bench_tool.cc | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/db/db_basic_test.cc b/db/db_basic_test.cc index 5d016f5f0..2c84d539a 100644 --- a/db/db_basic_test.cc +++ b/db/db_basic_test.cc @@ -1174,6 +1174,7 @@ TEST_F(DBBasicTest, MultiGetBatchedMultiLevel) { Flush(); num_keys = 0; } + ASSERT_EQ(0, num_keys); for (int i = 0; i < 128; i += 9) { ASSERT_OK(Put("key_" + std::to_string(i), "val_mem_" + std::to_string(i))); diff --git a/table/full_filter_block.cc b/table/full_filter_block.cc index 34012fd82..9015e96d2 100644 --- a/table/full_filter_block.cc +++ b/table/full_filter_block.cc @@ -196,7 +196,7 @@ void FullFilterBlockReader::MayMatch(MultiGetRange* range) { // declare both keys and may_match as arrays, which is also slightly less // expensive compared to autovector Slice* keys[MultiGetContext::MAX_BATCH_SIZE]; - bool may_match[MultiGetContext::MAX_BATCH_SIZE]; + bool may_match[MultiGetContext::MAX_BATCH_SIZE] = {false}; int num_keys = 0; for (auto iter = range->begin(); iter != range->end(); ++iter) { keys[num_keys++] = &iter->ukey; diff --git a/tools/db_bench_tool.cc b/tools/db_bench_tool.cc index 88222664b..77d54fcfa 100644 --- a/tools/db_bench_tool.cc +++ b/tools/db_bench_tool.cc @@ -4618,6 +4618,7 @@ void VerifyDBFromDB(std::string& truth_db_name) { std::vector > key_guards; std::vector values(entries_per_batch_); PinnableSlice* pin_values = new PinnableSlice[entries_per_batch_]; + std::unique_ptr pin_values_guard(pin_values); std::vector stat_list(entries_per_batch_); while (static_cast(keys.size()) < entries_per_batch_) { key_guards.push_back(std::unique_ptr());