2cbb61eadb
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 |
||
---|---|---|
.. | ||
aligned_buffer.h | ||
autovector_test.cc | ||
autovector.h | ||
bloom_impl.h | ||
bloom_test.cc | ||
bloom.cc | ||
build_version.cc.in | ||
build_version.h | ||
cast_util.h | ||
channel.h | ||
coding_test.cc | ||
coding.cc | ||
coding.h | ||
compaction_job_stats_impl.cc | ||
comparator.cc | ||
compression_context_cache.cc | ||
compression_context_cache.h | ||
compression.h | ||
concurrent_task_limiter_impl.cc | ||
concurrent_task_limiter_impl.h | ||
core_local.h | ||
crc32c_arm64.cc | ||
crc32c_arm64.h | ||
crc32c_ppc_asm.S | ||
crc32c_ppc_constants.h | ||
crc32c_ppc.c | ||
crc32c_ppc.h | ||
crc32c_test.cc | ||
crc32c.cc | ||
crc32c.h | ||
duplicate_detector.h | ||
dynamic_bloom_test.cc | ||
dynamic_bloom.cc | ||
dynamic_bloom.h | ||
file_reader_writer_test.cc | ||
filelock_test.cc | ||
filter_policy.cc | ||
gflags_compat.h | ||
hash_map.h | ||
hash_test.cc | ||
hash.cc | ||
hash.h | ||
heap_test.cc | ||
heap.h | ||
kv_map.h | ||
log_write_bench.cc | ||
murmurhash.cc | ||
murmurhash.h | ||
mutexlock.h | ||
ppc-opcode.h | ||
random.cc | ||
random.h | ||
rate_limiter_test.cc | ||
rate_limiter.cc | ||
rate_limiter.h | ||
repeatable_thread_test.cc | ||
repeatable_thread.h | ||
set_comparator.h | ||
slice_transform_test.cc | ||
slice.cc | ||
status.cc | ||
stderr_logger.h | ||
stop_watch.h | ||
string_util.cc | ||
string_util.h | ||
thread_list_test.cc | ||
thread_local_test.cc | ||
thread_local.cc | ||
thread_local.h | ||
thread_operation.h | ||
threadpool_imp.cc | ||
threadpool_imp.h | ||
timer_queue_test.cc | ||
timer_queue.h | ||
user_comparator_wrapper.h | ||
util.h | ||
vector_iterator.h | ||
xxhash.cc | ||
xxhash.h |