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
main
Yanqin Jin 6 years ago committed by Facebook Github Bot
parent f49e12b892
commit 3189398c00
  1. 1
      db/db_basic_test.cc
  2. 2
      table/full_filter_block.cc
  3. 1
      tools/db_bench_tool.cc

@ -1174,6 +1174,7 @@ TEST_F(DBBasicTest, MultiGetBatchedMultiLevel) {
Flush(); Flush();
num_keys = 0; num_keys = 0;
} }
ASSERT_EQ(0, num_keys);
for (int i = 0; i < 128; i += 9) { for (int i = 0; i < 128; i += 9) {
ASSERT_OK(Put("key_" + std::to_string(i), "val_mem_" + std::to_string(i))); ASSERT_OK(Put("key_" + std::to_string(i), "val_mem_" + std::to_string(i)));

@ -196,7 +196,7 @@ void FullFilterBlockReader::MayMatch(MultiGetRange* range) {
// declare both keys and may_match as arrays, which is also slightly less // declare both keys and may_match as arrays, which is also slightly less
// expensive compared to autovector // expensive compared to autovector
Slice* keys[MultiGetContext::MAX_BATCH_SIZE]; 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; int num_keys = 0;
for (auto iter = range->begin(); iter != range->end(); ++iter) { for (auto iter = range->begin(); iter != range->end(); ++iter) {
keys[num_keys++] = &iter->ukey; keys[num_keys++] = &iter->ukey;

@ -4618,6 +4618,7 @@ void VerifyDBFromDB(std::string& truth_db_name) {
std::vector<std::unique_ptr<const char[]> > key_guards; std::vector<std::unique_ptr<const char[]> > key_guards;
std::vector<std::string> values(entries_per_batch_); std::vector<std::string> values(entries_per_batch_);
PinnableSlice* pin_values = new PinnableSlice[entries_per_batch_]; PinnableSlice* pin_values = new PinnableSlice[entries_per_batch_];
std::unique_ptr<PinnableSlice[]> pin_values_guard(pin_values);
std::vector<Status> stat_list(entries_per_batch_); std::vector<Status> stat_list(entries_per_batch_);
while (static_cast<int64_t>(keys.size()) < entries_per_batch_) { while (static_cast<int64_t>(keys.size()) < entries_per_batch_) {
key_guards.push_back(std::unique_ptr<const char[]>()); key_guards.push_back(std::unique_ptr<const char[]>());

Loading…
Cancel
Save