From a44670e71b4d80bbe7acfdeddf6877e018358a70 Mon Sep 17 00:00:00 2001 From: Levi Tamasi Date: Fri, 1 Nov 2019 11:44:59 -0700 Subject: [PATCH] Use aggregate initialization for FlushJobInfo/CompactionJobInfo (#5997) Summary: FlushJobInfo and CompactionJobInfo are aggregates; we should use the aggregate initialization syntax to ensure members (specifically those of built-in types) are value-initialized. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5997 Test Plan: make check Differential Revision: D18273398 Pulled By: ltamasi fbshipit-source-id: 35b1a63ad9ca01605d288329858af72fffd7f392 --- db/compact_files_test.cc | 2 +- db/db_impl/db_impl_compaction_flush.cc | 6 +++--- db/flush_job.cc | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/db/compact_files_test.cc b/db/compact_files_test.cc index 92975da87..4152cb379 100644 --- a/db/compact_files_test.cc +++ b/db/compact_files_test.cc @@ -387,7 +387,7 @@ TEST_F(CompactFilesTest, GetCompactionJobInfo) { auto l0_files_1 = collector->GetFlushedFiles(); CompactionOptions co; co.compression = CompressionType::kLZ4Compression; - CompactionJobInfo compaction_job_info; + CompactionJobInfo compaction_job_info{}; ASSERT_OK( db->CompactFiles(co, l0_files_1, 0, -1, nullptr, &compaction_job_info)); ASSERT_EQ(compaction_job_info.base_input_level, 0); diff --git a/db/db_impl/db_impl_compaction_flush.cc b/db/db_impl/db_impl_compaction_flush.cc index 0497e859a..f74232244 100644 --- a/db/db_impl/db_impl_compaction_flush.cc +++ b/db/db_impl/db_impl_compaction_flush.cc @@ -570,7 +570,7 @@ void DBImpl::NotifyOnFlushBegin(ColumnFamilyData* cfd, FileMetaData* file_meta, // release lock while notifying events mutex_.Unlock(); { - FlushJobInfo info; + FlushJobInfo info{}; info.cf_id = cfd->GetID(); info.cf_name = cfd->GetName(); // TODO(yhchiang): make db_paths dynamic in case flush does not @@ -1107,7 +1107,7 @@ void DBImpl::NotifyOnCompactionBegin(ColumnFamilyData* cfd, Compaction* c, mutex_.Unlock(); TEST_SYNC_POINT("DBImpl::NotifyOnCompactionBegin::UnlockMutex"); { - CompactionJobInfo info; + CompactionJobInfo info{}; info.cf_name = cfd->GetName(); info.status = st; info.thread_id = env_->GetThreadID(); @@ -1181,7 +1181,7 @@ void DBImpl::NotifyOnCompactionCompleted( mutex_.Unlock(); TEST_SYNC_POINT("DBImpl::NotifyOnCompactionCompleted::UnlockMutex"); { - CompactionJobInfo info; + CompactionJobInfo info{}; BuildCompactionJobInfo(cfd, c, st, compaction_job_stats, job_id, current, &info); for (auto listener : immutable_db_options_.listeners) { diff --git a/db/flush_job.cc b/db/flush_job.cc index 83ce7e74f..fc14b5b92 100644 --- a/db/flush_job.cc +++ b/db/flush_job.cc @@ -431,7 +431,7 @@ Status FlushJob::WriteLevel0Table() { #ifndef ROCKSDB_LITE std::unique_ptr FlushJob::GetFlushJobInfo() const { db_mutex_->AssertHeld(); - std::unique_ptr info(new FlushJobInfo); + std::unique_ptr info(new FlushJobInfo{}); info->cf_id = cfd_->GetID(); info->cf_name = cfd_->GetName();