From ac16663bd6f83b31200991941fd0d8a20931dae3 Mon Sep 17 00:00:00 2001 From: Nathan Bronson Date: Wed, 30 Dec 2015 05:49:06 -0800 Subject: [PATCH] use -Werror=missing-field-initializers, to closer match MyRocks build Summary: myrocks seems to build rocksdb using -Wmissing-field-initializers (and treats warnings as errors). This diff adds that flag to the rocksdb build, and fixes the compilation failures that result. I have not checked for any other differences in the build flags for rocksdb build as part of myrocks. Test Plan: make check Reviewers: sdong, rven Reviewed By: rven Subscribers: dhruba Differential Revision: https://reviews.facebook.net/D52443 --- Makefile | 2 +- db/column_family_test.cc | 4 ++-- db/db_impl.cc | 2 +- db/db_test.cc | 2 +- db/write_thread.cc | 6 +++--- db/write_thread.h | 2 ++ table/table_test.cc | 2 +- 7 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 396b8e201..a6d3cae4d 100644 --- a/Makefile +++ b/Makefile @@ -192,7 +192,7 @@ ifndef DISABLE_WARNING_AS_ERROR endif CFLAGS += $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CCFLAGS) $(OPT) -CXXFLAGS += $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT) -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers +CXXFLAGS += $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT) -Woverloaded-virtual -Wnon-virtual-dtor -Werror=missing-field-initializers LDFLAGS += $(PLATFORM_LDFLAGS) diff --git a/db/column_family_test.cc b/db/column_family_test.cc index ba048e64e..70035a939 100644 --- a/db/column_family_test.cc +++ b/db/column_family_test.cc @@ -1990,10 +1990,10 @@ TEST_F(ColumnFamilyTest, FlushAndDropRaceCondition) { Reopen({options, options}); rocksdb::SyncPoint::GetInstance()->LoadDependency( - {{"VersionSet::LogAndApply::ColumnFamilyDrop:1" + {{"VersionSet::LogAndApply::ColumnFamilyDrop:1", "FlushJob::InstallResults"}, {"FlushJob::InstallResults", - "VersionSet::LogAndApply::ColumnFamilyDrop:2", }}); + "VersionSet::LogAndApply::ColumnFamilyDrop:2"}}); rocksdb::SyncPoint::GetInstance()->EnableProcessing(); test::SleepingBackgroundTask sleeping_task; diff --git a/db/db_impl.cc b/db/db_impl.cc index dd6519fba..661e3b48a 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -4383,7 +4383,7 @@ Status DBImpl::WriteImpl(const WriteOptions& write_options, &flush_scheduler_, write_options.ignore_missing_column_families, 0 /*log_number*/, this, false /*dont_filter_deletes*/); } else { - WriteThread::ParallelGroup pg{}; + WriteThread::ParallelGroup pg; pg.leader = &w; pg.last_writer = last_writer; pg.early_exit_allowed = !need_log_sync; diff --git a/db/db_test.cc b/db/db_test.cc index 8d37d1c44..ff983c36c 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -5653,7 +5653,7 @@ TEST_F(DBTest, GroupCommitTest) { ASSERT_TRUE(!itr->Valid()); delete itr; - HistogramData hist_data = {0}; + HistogramData hist_data = {0, 0, 0, 0, 0}; options.statistics->histogramData(DB_WRITE, &hist_data); ASSERT_GT(hist_data.average, 0.0); } while (ChangeOptions(kSkipNoSeekToLast)); diff --git a/db/write_thread.cc b/db/write_thread.cc index 5e43937ee..e153f319b 100644 --- a/db/write_thread.cc +++ b/db/write_thread.cc @@ -213,7 +213,7 @@ void WriteThread::CreateMissingNewerLinks(Writer* head) { } void WriteThread::JoinBatchGroup(Writer* w) { - static AdaptationContext ctx{"JoinBatchGroup"}; + static AdaptationContext ctx("JoinBatchGroup"); assert(w->batch != nullptr); bool linked_as_leader; @@ -323,7 +323,7 @@ void WriteThread::LaunchParallelFollowers(ParallelGroup* pg, } bool WriteThread::CompleteParallelWorker(Writer* w) { - static AdaptationContext ctx{"CompleteParallelWorker"}; + static AdaptationContext ctx("CompleteParallelWorker"); auto* pg = w->parallel_group; if (!w->status.ok()) { @@ -419,7 +419,7 @@ void WriteThread::ExitAsBatchGroupLeader(Writer* leader, Writer* last_writer, } void WriteThread::EnterUnbatched(Writer* w, InstrumentedMutex* mu) { - static AdaptationContext ctx{"EnterUnbatched"}; + static AdaptationContext ctx("EnterUnbatched"); assert(w->batch == nullptr); bool linked_as_leader; diff --git a/db/write_thread.h b/db/write_thread.h index 2fdd4a02f..e31904ed1 100644 --- a/db/write_thread.h +++ b/db/write_thread.h @@ -207,6 +207,8 @@ class WriteThread { struct AdaptationContext { const char* name; std::atomic value; + + explicit AdaptationContext(const char* name0) : name(name0), value(0) {} }; private: diff --git a/table/table_test.cc b/table/table_test.cc index cf58a2477..eb2b52ef9 100644 --- a/table/table_test.cc +++ b/table/table_test.cc @@ -1998,7 +1998,7 @@ TEST_F(HarnessTest, Randomized) { #ifndef ROCKSDB_LITE TEST_F(HarnessTest, RandomizedLongDB) { Random rnd(test::RandomSeed()); - TestArgs args = { DB_TEST, false, 16, kNoCompression, 0 }; + TestArgs args = {DB_TEST, false, 16, kNoCompression, 0, false}; Init(args); int num_entries = 100000; for (int e = 0; e < num_entries; e++) {