From 503a756e42bded0a665d28afb19b0cdecc482fd6 Mon Sep 17 00:00:00 2001 From: sdong Date: Mon, 30 Sep 2019 22:14:03 -0700 Subject: [PATCH] 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 --- tools/db_stress.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/db_stress.cc b/tools/db_stress.cc index da2a122d4..8c87338f7 100644 --- a/tools/db_stress.cc +++ b/tools/db_stress.cc @@ -3319,7 +3319,8 @@ class NonBatchedOpsStressTest : public StressTest { } // TODO(ljin): update "long" to uint64_t // Reseek when the prefix changes - if (i % (static_cast(1) << 8 * (8 - prefix_to_use)) == 0) { + if (prefix_to_use > 0 && + i % (static_cast(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(1) << ((8 - prefix_to_use) * 8))); + assert(prefix_to_use == 0 || + count <= (static_cast(1) << ((8 - prefix_to_use) * 8))); Status s = iter->status(); if (s.ok()) { thread->stats.AddPrefixes(1, count);