Просмотр исходного кода

Initialize class members to default values in constructors.

There were a few members which were identified to have been left
uninitialized in some constructors. These were very likely to
have been set before being used, otherwise the ASan tests would
have caught them, but still good practice to have them
initialized. This addresses some items reported in issue #668.

PiperOrigin-RevId: 243370145
main
Chris Mumford 5 лет назад
Родитель
Сommit
2f008ac19e
3 измененных файлов: 6 добавлений и 9 удалений
  1. +1
    -4
      db/db_bench.cc
  2. +4
    -3
      db/db_impl.cc
  3. +1
    -2
      util/cache.cc

+ 1
- 4
db/db_bench.cc Просмотреть файл

@ -304,10 +304,7 @@ struct ThreadState {
Stats stats; Stats stats;
SharedState* shared; SharedState* shared;
ThreadState(int index)
: tid(index),
rand(1000 + index) {
}
ThreadState(int index) : tid(index), rand(1000 + index), shared(nullptr) {}
}; };
} // namespace } // namespace

+ 4
- 3
db/db_impl.cc Просмотреть файл

@ -48,7 +48,8 @@ struct DBImpl::Writer {
bool done; bool done;
port::CondVar cv; port::CondVar cv;
explicit Writer(port::Mutex* mu) : cv(mu) { }
explicit Writer(port::Mutex* mu)
: batch(nullptr), sync(false), done(false), cv(mu) {}
}; };
struct DBImpl::CompactionState { struct DBImpl::CompactionState {
@ -78,10 +79,10 @@ struct DBImpl::CompactionState {
explicit CompactionState(Compaction* c) explicit CompactionState(Compaction* c)
: compaction(c), : compaction(c),
smallest_snapshot(0),
outfile(nullptr), outfile(nullptr),
builder(nullptr), builder(nullptr),
total_bytes(0) {
}
total_bytes(0) {}
}; };
// Fix user-supplied options to be reasonable // Fix user-supplied options to be reasonable

+ 1
- 2
util/cache.cc Просмотреть файл

@ -196,8 +196,7 @@ class LRUCache {
HandleTable table_ GUARDED_BY(mutex_); HandleTable table_ GUARDED_BY(mutex_);
}; };
LRUCache::LRUCache()
: usage_(0) {
LRUCache::LRUCache() : capacity_(0), usage_(0) {
// Make empty circular linked lists. // Make empty circular linked lists.
lru_.next = &lru_; lru_.next = &lru_;
lru_.prev = &lru_; lru_.prev = &lru_;

Загрузка…
Отмена
Сохранить