Fix some defects reported by Coverity Scan (#6933)

Summary:
Confusing checks for null that are never null
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6933

Test Plan: make check

Reviewed By: cheng-chang

Differential Revision: D21885466

Pulled By: pdillinger

fbshipit-source-id: 4b48e03c2a33727f2702b0d12292f9fda5a3c475
main
Peter Dillinger 5 years ago committed by Facebook GitHub Bot
parent c7432cc3c0
commit aaece2a98d
  1. 14
      db/memtable_list.cc
  2. 2
      db/memtable_list.h
  3. 6
      utilities/transactions/transaction_base.cc
  4. 3
      utilities/transactions/write_prepared_txn_db.cc

@ -43,24 +43,22 @@ void MemTableListVersion::UnrefMemTable(autovector<MemTable*>* to_delete,
}
MemTableListVersion::MemTableListVersion(
size_t* parent_memtable_list_memory_usage, MemTableListVersion* old)
size_t* parent_memtable_list_memory_usage, const MemTableListVersion& old)
: max_write_buffer_number_to_maintain_(
old->max_write_buffer_number_to_maintain_),
old.max_write_buffer_number_to_maintain_),
max_write_buffer_size_to_maintain_(
old->max_write_buffer_size_to_maintain_),
old.max_write_buffer_size_to_maintain_),
parent_memtable_list_memory_usage_(parent_memtable_list_memory_usage) {
if (old != nullptr) {
memlist_ = old->memlist_;
memlist_ = old.memlist_;
for (auto& m : memlist_) {
m->Ref();
}
memlist_history_ = old->memlist_history_;
memlist_history_ = old.memlist_history_;
for (auto& m : memlist_history_) {
m->Ref();
}
}
}
MemTableListVersion::MemTableListVersion(
size_t* parent_memtable_list_memory_usage,
@ -604,7 +602,7 @@ void MemTableList::InstallNewVersion() {
} else {
// somebody else holds the current version, we need to create new one
MemTableListVersion* version = current_;
current_ = new MemTableListVersion(&current_memory_usage_, current_);
current_ = new MemTableListVersion(&current_memory_usage_, *version);
current_->Ref();
version->Unref();
}

@ -44,7 +44,7 @@ struct FlushJobInfo;
class MemTableListVersion {
public:
explicit MemTableListVersion(size_t* parent_memtable_list_memory_usage,
MemTableListVersion* old = nullptr);
const MemTableListVersion& old);
explicit MemTableListVersion(size_t* parent_memtable_list_memory_usage,
int max_write_buffer_number_to_maintain,
int64_t max_write_buffer_size_to_maintain);

@ -312,8 +312,7 @@ std::vector<Status> TransactionBaseImpl::MultiGet(
std::vector<Status> stat_list(num_keys);
for (size_t i = 0; i < num_keys; ++i) {
std::string* value = values ? &(*values)[i] : nullptr;
stat_list[i] = Get(read_options, column_family[i], keys[i], value);
stat_list[i] = Get(read_options, column_family[i], keys[i], &(*values)[i]);
}
return stat_list;
@ -350,8 +349,7 @@ std::vector<Status> TransactionBaseImpl::MultiGetForUpdate(
// TODO(agiardullo): optimize multiget?
std::vector<Status> stat_list(num_keys);
for (size_t i = 0; i < num_keys; ++i) {
std::string* value = values ? &(*values)[i] : nullptr;
stat_list[i] = Get(read_options, column_family[i], keys[i], value);
stat_list[i] = Get(read_options, column_family[i], keys[i], &(*values)[i]);
}
return stat_list;

@ -294,8 +294,7 @@ std::vector<Status> WritePreparedTxnDB::MultiGet(
std::vector<Status> stat_list(num_keys);
for (size_t i = 0; i < num_keys; ++i) {
std::string* value = values ? &(*values)[i] : nullptr;
stat_list[i] = this->Get(options, column_family[i], keys[i], value);
stat_list[i] = this->Get(options, column_family[i], keys[i], &(*values)[i]);
}
return stat_list;
}

Loading…
Cancel
Save