Make clang analyze happy with options_test (#6398)

Summary:
clang analysis shows following warning:

options/options_test.cc:1554:24: warning: The left operand of '-' is a garbage value
            (file_size - 1) / readahead_size + 1);
             ~~~~~~~~~ ^

Explicitly initialize file_size and add an assertion to make clang analysis happy.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6398

Test Plan: Run "make analysis" and see the warning goes away.

Differential Revision: D19819662

fbshipit-source-id: 1589ea91c0c8f78242538f01448e4ad0e5fbc219
main
sdong 5 years ago committed by Facebook Github Bot
parent b2bc1da561
commit 594e815e32
  1. 5
      options/options_test.cc

@ -1541,9 +1541,10 @@ TEST_F(OptionsParserTest, Readahead) {
ASSERT_OK(PersistRocksDBOptions(base_db_opt, cf_names, base_cf_opts, ASSERT_OK(PersistRocksDBOptions(base_db_opt, cf_names, base_cf_opts,
kOptionsFileName, fs_.get())); kOptionsFileName, fs_.get()));
uint64_t file_size; uint64_t file_size = 0;
ASSERT_OK(env_->GetFileSize(kOptionsFileName, &file_size)); ASSERT_OK(env_->GetFileSize(kOptionsFileName, &file_size));
assert(file_size > 0);
RocksDBOptionsParser parser; RocksDBOptionsParser parser;
env_->num_seq_file_read_ = 0; env_->num_seq_file_read_ = 0;

Loading…
Cancel
Save