提交 3189398c 编写于 作者: Y Yanqin Jin 提交者: Facebook Github Bot

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
上级 f49e12b8
...@@ -1174,6 +1174,7 @@ TEST_F(DBBasicTest, MultiGetBatchedMultiLevel) { ...@@ -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) { ...@@ -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) { ...@@ -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[]>());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册