rocksdb/utilities/persistent_cache
Levi Tamasi 2cbb61eadb Make clang-analyzer happy (#5821)
Summary:
clang-analyzer has uncovered a bunch of places where the code is relying
on pointers being valid and one case (in VectorIterator) where a moved-from
object is being used:

In file included from db/range_tombstone_fragmenter.cc:17:
./util/vector_iterator.h:23:18: warning: Method called on moved-from object 'keys' of type 'std::vector'
        current_(keys.size()) {
                 ^~~~~~~~~~~
1 warning generated.
utilities/persistent_cache/block_cache_tier_file.cc:39:14: warning: Called C++ object pointer is null
  Status s = env->NewRandomAccessFile(filepath, file, opt);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
utilities/persistent_cache/block_cache_tier_file.cc:47:19: warning: Called C++ object pointer is null
  Status status = env_->GetFileSize(Path(), size);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
utilities/persistent_cache/block_cache_tier_file.cc:290:14: warning: Called C++ object pointer is null
  Status s = env_->FileExists(Path());
             ^~~~~~~~~~~~~~~~~~~~~~~~
utilities/persistent_cache/block_cache_tier_file.cc:363:35: warning: Called C++ object pointer is null
    CacheWriteBuffer* const buf = alloc_->Allocate();
                                  ^~~~~~~~~~~~~~~~~~
utilities/persistent_cache/block_cache_tier_file.cc:399:41: warning: Called C++ object pointer is null
  const uint64_t file_off = buf_doff_ * alloc_->BufferSize();
                                        ^~~~~~~~~~~~~~~~~~~~
utilities/persistent_cache/block_cache_tier_file.cc:463:33: warning: Called C++ object pointer is null
  size_t start_idx = lba.off_ / alloc_->BufferSize();
                                ^~~~~~~~~~~~~~~~~~~~
utilities/persistent_cache/block_cache_tier_file.cc:515:5: warning: Called C++ object pointer is null
    alloc_->Deallocate(bufs_[i]);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 warnings generated.
ar: creating librocksdb_debug.a
utilities/memory/memory_test.cc:68:25: warning: Called C++ object pointer is null
      cache_set->insert(db->GetDBOptions().row_cache.get());
                        ^~~~~~~~~~~~~~~~~~
1 warning generated.

The patch fixes these by adding assertions and explicitly passing in zero
when initializing VectorIterator::current_ (which preserves the existing
behavior).
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5821

Test Plan: Ran make check and make analyze to make sure the warnings have disappeared.

Differential Revision: D17455949

Pulled By: ltamasi

fbshipit-source-id: 363619618ea649a0674287f9f3b3393e390571ee
2019-09-18 15:25:48 -07:00
..
block_cache_tier_file_buffer.h Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
block_cache_tier_file.cc Make clang-analyzer happy (#5821) 2019-09-18 15:25:48 -07:00
block_cache_tier_file.h Divide file_reader_writer.h and .cc (#5803) 2019-09-16 10:33:51 -07:00
block_cache_tier_metadata.cc Fix unused var warnings in Release mode 2017-10-23 14:27:04 -07:00
block_cache_tier_metadata.h Change RocksDB License 2017-07-15 16:11:23 -07:00
block_cache_tier.cc Move some logging related files to logging/ (#5387) 2019-05-31 17:23:59 -07:00
block_cache_tier.h Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
hash_table_bench.cc Fix build for linux 2017-12-18 12:28:03 -08:00
hash_table_evictable.h Enable MSVC W4 with a few exceptions. Fix warnings and bugs 2017-10-19 10:57:12 -07:00
hash_table_test.cc Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
hash_table.h Change RocksDB License 2017-07-15 16:11:23 -07:00
lrulist.h Change RocksDB License 2017-07-15 16:11:23 -07:00
persistent_cache_bench.cc Organizing rocksdb/table directory by format 2019-05-30 14:51:11 -07:00
persistent_cache_test.cc Per-thread unique test db names (#4135) 2018-07-13 17:27:39 -07:00
persistent_cache_test.h Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
persistent_cache_tier.cc simplify include directive involving inttypes (#5402) 2019-06-06 13:56:07 -07:00
persistent_cache_tier.h fix compilation with g++ option -Wsuggest-override (#4272) 2018-08-14 15:13:10 -07:00
persistent_cache_util.h Fix MyRocks compile warnings-treated-as-errors on Fedora 30, gcc 9.1.1 (#5553) 2019-07-12 17:30:51 -07:00
volatile_tier_impl.cc Comment out unused variables 2018-03-05 13:13:41 -08:00
volatile_tier_impl.h Change RocksDB License 2017-07-15 16:11:23 -07:00