Fix clang analyze warning in db_stress (#5870)

Summary:
Recent changes trigger clang analyze warning. Fix it.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5870

Test Plan: "USE_CLANG=1 TEST_TMPDIR=/dev/shm/rocksdb OPT=-g make -j60 analyze" and make sure it passes.

Differential Revision: D17682533

fbshipit-source-id: 02716f2a24572550a22db4bbe9b54d4872dfae32
This commit is contained in:
sdong 2019-09-30 22:14:03 -07:00 committed by Facebook Github Bot
parent 51413e0a85
commit 503a756e42

View File

@ -3319,7 +3319,8 @@ class NonBatchedOpsStressTest : public StressTest {
}
// TODO(ljin): update "long" to uint64_t
// Reseek when the prefix changes
if (i % (static_cast<int64_t>(1) << 8 * (8 - prefix_to_use)) == 0) {
if (prefix_to_use > 0 &&
i % (static_cast<int64_t>(1) << 8 * (8 - prefix_to_use)) == 0) {
iter->Seek(Key(i));
}
std::string from_db;
@ -4330,7 +4331,8 @@ class CfConsistencyStressTest : public StressTest {
iter->Next()) {
++count;
}
assert(count <= (static_cast<long>(1) << ((8 - prefix_to_use) * 8)));
assert(prefix_to_use == 0 ||
count <= (static_cast<long>(1) << ((8 - prefix_to_use) * 8)));
Status s = iter->status();
if (s.ok()) {
thread->stats.AddPrefixes(1, count);