Make "make analyze" happy

Summary:
"make analyze" is reporting some errors. It's complicated to look but it seems to me that they are all false positive. Anyway, I think cleaning them up is a good idea. Some of the changes are hacky but I don't know a better way.
Closes https://github.com/facebook/rocksdb/pull/2508

Differential Revision: D5341710

Pulled By: siying

fbshipit-source-id: 6070e430e0e41a080ef441e05e8ec827d45efab6
This commit is contained in:
Siying Dong 2017-06-28 15:36:11 -07:00 committed by Facebook Github Bot
parent 01534db24c
commit 18c63af6ef
5 changed files with 8 additions and 13 deletions

View file

@ -142,7 +142,7 @@ Status DBImpl::WriteImpl(const WriteOptions& write_options,
WriteContext write_context; WriteContext write_context;
WriteThread::WriteGroup write_group; WriteThread::WriteGroup write_group;
bool in_parallel_group = false; bool in_parallel_group = false;
uint64_t last_sequence; uint64_t last_sequence = kMaxSequenceNumber;
if (!concurrent_prepare_) { if (!concurrent_prepare_) {
last_sequence = versions_->LastSequence(); last_sequence = versions_->LastSequence();
} }
@ -247,6 +247,7 @@ Status DBImpl::WriteImpl(const WriteOptions& write_options,
last_sequence = versions_->FetchAddLastToBeWrittenSequence(total_count); last_sequence = versions_->FetchAddLastToBeWrittenSequence(total_count);
} }
} }
assert(last_sequence != kMaxSequenceNumber);
const SequenceNumber current_sequence = last_sequence + 1; const SequenceNumber current_sequence = last_sequence + 1;
last_sequence += total_count; last_sequence += total_count;

View file

@ -644,6 +644,7 @@ void DBIter::ReverseToBackward() {
while (iter_->Valid() && while (iter_->Valid() &&
user_comparator_->Compare(ikey.user_key, saved_key_.GetUserKey()) > user_comparator_->Compare(ikey.user_key, saved_key_.GetUserKey()) >
0) { 0) {
assert(ikey.sequence != kMaxSequenceNumber);
if (ikey.sequence > sequence_) { if (ikey.sequence > sequence_) {
PERF_COUNTER_ADD(internal_recent_skipped_count, 1); PERF_COUNTER_ADD(internal_recent_skipped_count, 1);
} else { } else {
@ -956,6 +957,7 @@ void DBIter::FindPrevUserKey() {
++num_skipped; ++num_skipped;
} }
} }
assert(ikey.sequence != kMaxSequenceNumber);
if (ikey.sequence > sequence_) { if (ikey.sequence > sequence_) {
PERF_COUNTER_ADD(internal_recent_skipped_count, 1); PERF_COUNTER_ADD(internal_recent_skipped_count, 1);
} else { } else {

View file

@ -80,7 +80,9 @@ struct ParsedInternalKey {
SequenceNumber sequence; SequenceNumber sequence;
ValueType type; ValueType type;
ParsedInternalKey() { } // Intentionally left uninitialized (for speed) ParsedInternalKey()
: sequence(kMaxSequenceNumber) // Make code analyzer happy
{} // Intentionally left uninitialized (for speed)
ParsedInternalKey(const Slice& u, const SequenceNumber& seq, ValueType t) ParsedInternalKey(const Slice& u, const SequenceNumber& seq, ValueType t)
: user_key(u), sequence(seq), type(t) { } : user_key(u), sequence(seq), type(t) { }
std::string DebugString(bool hex = false) const; std::string DebugString(bool hex = false) const;

View file

@ -1230,7 +1230,7 @@ Status BlobDBImpl::CommonGet(const ColumnFamilyData* cfd, const Slice& key,
} }
// 0 - size // 0 - size
if (!handle.size()) { if (!handle.size() && value != nullptr) {
value->clear(); value->clear();
return Status::OK(); return Status::OK();
} }

View file

@ -35,17 +35,7 @@ class BlobDBTest : public testing::Test {
void Open(BlobDBOptionsImpl bdb_options = BlobDBOptionsImpl(), void Open(BlobDBOptionsImpl bdb_options = BlobDBOptionsImpl(),
Options options = Options()) { Options options = Options()) {
options.create_if_missing = true; options.create_if_missing = true;
Reopen(bdb_options, options);
}
void Reopen(BlobDBOptionsImpl bdb_options = BlobDBOptionsImpl(),
Options options = Options()) {
if (blob_db_) {
delete blob_db_;
blob_db_ = nullptr;
}
ASSERT_OK(BlobDB::Open(options, bdb_options, dbname_, &blob_db_)); ASSERT_OK(BlobDB::Open(options, bdb_options, dbname_, &blob_db_));
ASSERT_TRUE(blob_db_);
} }
void Destroy() { void Destroy() {