Skip to content

Commit c7432cc

Browse files
pdillingerfacebook-github-bot
authored andcommitted
Fix more defects reported by Coverity Scan (facebook#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: facebook#6935 Test Plan: make check Reviewed By: siying Differential Revision: D21885484 Pulled By: pdillinger fbshipit-source-id: e2e7cb0a0cf196f2b55edd16f0634e81f6cc8e08
1 parent a8170d7 commit c7432cc

File tree

7 files changed

+10
-9
lines changed

7 files changed

+10
-9
lines changed

include/rocksdb/perf_context.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ struct PerfContextByLevel {
3030

3131
// total number of user key returned (only include keys that are found, does
3232
// not include keys that are deleted or merged without a final put
33-
uint64_t user_key_return_count;
33+
uint64_t user_key_return_count = 0;
3434

3535
// total nanos spent on reading data from SST files
36-
uint64_t get_from_table_nanos;
36+
uint64_t get_from_table_nanos = 0;
3737

3838
uint64_t block_cache_hit_count = 0; // total number of block cache hits
3939
uint64_t block_cache_miss_count = 0; // total number of block cache misses

memtable/memtablerep_bench.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,8 @@ class Benchmark {
452452
MemTableRep* table_;
453453
KeyGenerator* key_gen_;
454454
uint64_t* sequence_;
455-
uint64_t num_write_ops_per_thread_;
456-
uint64_t num_read_ops_per_thread_;
455+
uint64_t num_write_ops_per_thread_ = 0;
456+
uint64_t num_read_ops_per_thread_ = 0;
457457
const uint32_t num_threads_;
458458
};
459459

port/port_posix.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class Mutex {
124124
friend class CondVar;
125125
pthread_mutex_t mu_;
126126
#ifndef NDEBUG
127-
bool locked_;
127+
bool locked_ = false;
128128
#endif
129129
};
130130

table/table_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,11 +1189,11 @@ class FileChecksumTestHelper {
11891189
public:
11901190
FileChecksumTestHelper(bool convert_to_internal_key = false)
11911191
: convert_to_internal_key_(convert_to_internal_key) {
1192-
sink_ = new test::StringSink();
11931192
}
11941193
~FileChecksumTestHelper() {}
11951194

11961195
void CreateWriteableFile() {
1196+
sink_ = new test::StringSink();
11971197
file_writer_.reset(test::GetWritableFileWriter(sink_, "" /* don't care */));
11981198
}
11991199

@@ -1291,7 +1291,7 @@ class FileChecksumTestHelper {
12911291
std::unique_ptr<RandomAccessFileReader> file_reader_;
12921292
std::unique_ptr<TableBuilder> table_builder_;
12931293
stl_wrappers::KVMap kv_map_;
1294-
test::StringSink* sink_;
1294+
test::StringSink* sink_ = nullptr;
12951295

12961296
static uint64_t checksum_uniq_id_;
12971297
};

tools/db_bench_tool.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,7 @@ class CombinedStats;
18511851
class Stats {
18521852
private:
18531853
int id_;
1854-
uint64_t start_;
1854+
uint64_t start_ = 0;
18551855
uint64_t sine_interval_;
18561856
uint64_t finish_;
18571857
double seconds_;

trace_replay/block_cache_tracer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ class BlockCacheHumanReadableTraceWriter {
220220
class BlockCacheTraceReader {
221221
public:
222222
BlockCacheTraceReader(std::unique_ptr<TraceReader>&& reader);
223-
~BlockCacheTraceReader() = default;
223+
virtual ~BlockCacheTraceReader() = default;
224224
// No copy and move.
225225
BlockCacheTraceReader(const BlockCacheTraceReader&) = delete;
226226
BlockCacheTraceReader& operator=(const BlockCacheTraceReader&) = delete;

utilities/backupable/backupable_db.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ Status BackupEngine::Open(const BackupableDBOptions& options, Env* env,
538538
BackupEngineImpl::BackupEngineImpl(const BackupableDBOptions& options,
539539
Env* db_env, bool read_only)
540540
: initialized_(false),
541+
threads_cpu_priority_(),
541542
latest_backup_id_(0),
542543
latest_valid_backup_id_(0),
543544
stop_backup_(false),

0 commit comments

Comments
 (0)