mirror of https://github.com/facebook/rocksdb.git
Fix more defects reported by Coverity Scan (#6935)
Summary: Mostly uninitialized values: some probably written before use, but some seem like bugs. Also, destructor needs to be virtual, and possible use-after-free in test Pull Request resolved: https://github.com/facebook/rocksdb/pull/6935 Test Plan: make check Reviewed By: siying Differential Revision: D21885484 Pulled By: pdillinger fbshipit-source-id: e2e7cb0a0cf196f2b55edd16f0634e81f6cc8e08
This commit is contained in:
parent
a8170d774c
commit
c7432cc3c0
|
@ -30,10 +30,10 @@ struct PerfContextByLevel {
|
||||||
|
|
||||||
// total number of user key returned (only include keys that are found, does
|
// total number of user key returned (only include keys that are found, does
|
||||||
// not include keys that are deleted or merged without a final put
|
// not include keys that are deleted or merged without a final put
|
||||||
uint64_t user_key_return_count;
|
uint64_t user_key_return_count = 0;
|
||||||
|
|
||||||
// total nanos spent on reading data from SST files
|
// total nanos spent on reading data from SST files
|
||||||
uint64_t get_from_table_nanos;
|
uint64_t get_from_table_nanos = 0;
|
||||||
|
|
||||||
uint64_t block_cache_hit_count = 0; // total number of block cache hits
|
uint64_t block_cache_hit_count = 0; // total number of block cache hits
|
||||||
uint64_t block_cache_miss_count = 0; // total number of block cache misses
|
uint64_t block_cache_miss_count = 0; // total number of block cache misses
|
||||||
|
|
|
@ -452,8 +452,8 @@ class Benchmark {
|
||||||
MemTableRep* table_;
|
MemTableRep* table_;
|
||||||
KeyGenerator* key_gen_;
|
KeyGenerator* key_gen_;
|
||||||
uint64_t* sequence_;
|
uint64_t* sequence_;
|
||||||
uint64_t num_write_ops_per_thread_;
|
uint64_t num_write_ops_per_thread_ = 0;
|
||||||
uint64_t num_read_ops_per_thread_;
|
uint64_t num_read_ops_per_thread_ = 0;
|
||||||
const uint32_t num_threads_;
|
const uint32_t num_threads_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ class Mutex {
|
||||||
friend class CondVar;
|
friend class CondVar;
|
||||||
pthread_mutex_t mu_;
|
pthread_mutex_t mu_;
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
bool locked_;
|
bool locked_ = false;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1189,11 +1189,11 @@ class FileChecksumTestHelper {
|
||||||
public:
|
public:
|
||||||
FileChecksumTestHelper(bool convert_to_internal_key = false)
|
FileChecksumTestHelper(bool convert_to_internal_key = false)
|
||||||
: convert_to_internal_key_(convert_to_internal_key) {
|
: convert_to_internal_key_(convert_to_internal_key) {
|
||||||
sink_ = new test::StringSink();
|
|
||||||
}
|
}
|
||||||
~FileChecksumTestHelper() {}
|
~FileChecksumTestHelper() {}
|
||||||
|
|
||||||
void CreateWriteableFile() {
|
void CreateWriteableFile() {
|
||||||
|
sink_ = new test::StringSink();
|
||||||
file_writer_.reset(test::GetWritableFileWriter(sink_, "" /* don't care */));
|
file_writer_.reset(test::GetWritableFileWriter(sink_, "" /* don't care */));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1291,7 +1291,7 @@ class FileChecksumTestHelper {
|
||||||
std::unique_ptr<RandomAccessFileReader> file_reader_;
|
std::unique_ptr<RandomAccessFileReader> file_reader_;
|
||||||
std::unique_ptr<TableBuilder> table_builder_;
|
std::unique_ptr<TableBuilder> table_builder_;
|
||||||
stl_wrappers::KVMap kv_map_;
|
stl_wrappers::KVMap kv_map_;
|
||||||
test::StringSink* sink_;
|
test::StringSink* sink_ = nullptr;
|
||||||
|
|
||||||
static uint64_t checksum_uniq_id_;
|
static uint64_t checksum_uniq_id_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1851,7 +1851,7 @@ class CombinedStats;
|
||||||
class Stats {
|
class Stats {
|
||||||
private:
|
private:
|
||||||
int id_;
|
int id_;
|
||||||
uint64_t start_;
|
uint64_t start_ = 0;
|
||||||
uint64_t sine_interval_;
|
uint64_t sine_interval_;
|
||||||
uint64_t finish_;
|
uint64_t finish_;
|
||||||
double seconds_;
|
double seconds_;
|
||||||
|
|
|
@ -220,7 +220,7 @@ class BlockCacheHumanReadableTraceWriter {
|
||||||
class BlockCacheTraceReader {
|
class BlockCacheTraceReader {
|
||||||
public:
|
public:
|
||||||
BlockCacheTraceReader(std::unique_ptr<TraceReader>&& reader);
|
BlockCacheTraceReader(std::unique_ptr<TraceReader>&& reader);
|
||||||
~BlockCacheTraceReader() = default;
|
virtual ~BlockCacheTraceReader() = default;
|
||||||
// No copy and move.
|
// No copy and move.
|
||||||
BlockCacheTraceReader(const BlockCacheTraceReader&) = delete;
|
BlockCacheTraceReader(const BlockCacheTraceReader&) = delete;
|
||||||
BlockCacheTraceReader& operator=(const BlockCacheTraceReader&) = delete;
|
BlockCacheTraceReader& operator=(const BlockCacheTraceReader&) = delete;
|
||||||
|
|
|
@ -538,6 +538,7 @@ Status BackupEngine::Open(const BackupableDBOptions& options, Env* env,
|
||||||
BackupEngineImpl::BackupEngineImpl(const BackupableDBOptions& options,
|
BackupEngineImpl::BackupEngineImpl(const BackupableDBOptions& options,
|
||||||
Env* db_env, bool read_only)
|
Env* db_env, bool read_only)
|
||||||
: initialized_(false),
|
: initialized_(false),
|
||||||
|
threads_cpu_priority_(),
|
||||||
latest_backup_id_(0),
|
latest_backup_id_(0),
|
||||||
latest_valid_backup_id_(0),
|
latest_valid_backup_id_(0),
|
||||||
stop_backup_(false),
|
stop_backup_(false),
|
||||||
|
|
Loading…
Reference in New Issue