From a4ce9f1c97f802e499c3eb56a94916f8e2f9e8f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Me=C3=9Fmer?= Date: Sat, 17 Oct 2015 21:10:26 +0200 Subject: [PATCH] Fix warnings from -Weffc++ --- implementations/caching/cache/Cache.h | 2 +- implementations/encrypted/EncryptedBlock.h | 3 ++- implementations/ondisk/OnDiskBlock.cpp | 2 +- implementations/testfake/FakeBlockStore.cpp | 2 +- .../caching/cache/CacheTest_RaceCondition.cpp | 2 ++ test/implementations/caching/cache/testutils/CacheTest.h | 2 ++ .../encrypted/EncryptedBlockStoreTest_Specific.cpp | 3 +++ test/implementations/ondisk/OnDiskBlockStoreTest.cpp | 4 ++++ test/interface/helpers/BlockStoreWithRandomKeysTest.cpp | 7 +++++-- test/testutils/BlockStoreTest.h | 3 +++ test/testutils/BlockStoreWithRandomKeysTest.h | 3 +++ 11 files changed, 27 insertions(+), 6 deletions(-) diff --git a/implementations/caching/cache/Cache.h b/implementations/caching/cache/Cache.h index 1f0e3f0c..22408482 100644 --- a/implementations/caching/cache/Cache.h +++ b/implementations/caching/cache/Cache.h @@ -52,7 +52,7 @@ template constexpr double Cache constexpr double Cache::MAX_LIFETIME_SEC; template -Cache::Cache(): _cachedBlocks(), _timeoutFlusher(nullptr) { +Cache::Cache(): _mutex(), _currentlyFlushingEntries(), _cachedBlocks(), _timeoutFlusher(nullptr) { //Don't initialize timeoutFlusher in the initializer list, //because it then might already call Cache::popOldEntries() before Cache is done constructing. _timeoutFlusher = std::make_unique(std::bind(&Cache::_deleteOldEntriesParallel, this), PURGE_INTERVAL); diff --git a/implementations/encrypted/EncryptedBlock.h b/implementations/encrypted/EncryptedBlock.h index a678f9d8..7a465ea9 100644 --- a/implementations/encrypted/EncryptedBlock.h +++ b/implementations/encrypted/EncryptedBlock.h @@ -111,7 +111,8 @@ EncryptedBlock::EncryptedBlock(cpputils::unique_ref baseBlock, co _baseBlock(std::move(baseBlock)), _plaintextWithHeader(std::move(plaintextWithHeader)), _encKey(encKey), - _dataChanged(false) { + _dataChanged(false), + _mutex() { } template diff --git a/implementations/ondisk/OnDiskBlock.cpp b/implementations/ondisk/OnDiskBlock.cpp index ca357a28..58e37405 100644 --- a/implementations/ondisk/OnDiskBlock.cpp +++ b/implementations/ondisk/OnDiskBlock.cpp @@ -23,7 +23,7 @@ namespace blockstore { namespace ondisk { OnDiskBlock::OnDiskBlock(const Key &key, const bf::path &filepath, Data data) - : Block(key), _filepath(filepath), _data(std::move(data)), _dataChanged(false) { + : Block(key), _filepath(filepath), _data(std::move(data)), _dataChanged(false), _mutex() { } OnDiskBlock::~OnDiskBlock() { diff --git a/implementations/testfake/FakeBlockStore.cpp b/implementations/testfake/FakeBlockStore.cpp index 89604f96..838d43c5 100644 --- a/implementations/testfake/FakeBlockStore.cpp +++ b/implementations/testfake/FakeBlockStore.cpp @@ -16,7 +16,7 @@ namespace blockstore { namespace testfake { FakeBlockStore::FakeBlockStore() - : _blocks(), _used_dataregions_for_blocks() {} + : _blocks(), _used_dataregions_for_blocks(), _mutex() {} optional> FakeBlockStore::tryCreate(const Key &key, Data data) { std::unique_lock lock(_mutex); diff --git a/test/implementations/caching/cache/CacheTest_RaceCondition.cpp b/test/implementations/caching/cache/CacheTest_RaceCondition.cpp index 685e50f6..bf0d8807 100644 --- a/test/implementations/caching/cache/CacheTest_RaceCondition.cpp +++ b/test/implementations/caching/cache/CacheTest_RaceCondition.cpp @@ -30,6 +30,8 @@ public: private: ConditionBarrier *_onDestructorStarted; bool *_destructorFinished; + + DISALLOW_COPY_AND_ASSIGN(ObjectWithLongDestructor); }; class CacheTest_RaceCondition: public ::testing::Test { diff --git a/test/implementations/caching/cache/testutils/CacheTest.h b/test/implementations/caching/cache/testutils/CacheTest.h index 79520cb0..f9000b3f 100644 --- a/test/implementations/caching/cache/testutils/CacheTest.h +++ b/test/implementations/caching/cache/testutils/CacheTest.h @@ -13,6 +13,8 @@ // Furthermore, the class checks that there are no memory leaks left after destructing the QueueMap (by counting leftover instances of Keys/Values). class CacheTest: public ::testing::Test { public: + CacheTest(): _cache() {} + void push(int key, int value); boost::optional pop(int key); diff --git a/test/implementations/encrypted/EncryptedBlockStoreTest_Specific.cpp b/test/implementations/encrypted/EncryptedBlockStoreTest_Specific.cpp index b293d78c..3eeb25c0 100644 --- a/test/implementations/encrypted/EncryptedBlockStoreTest_Specific.cpp +++ b/test/implementations/encrypted/EncryptedBlockStoreTest_Specific.cpp @@ -49,6 +49,9 @@ public: auto source = baseBlockStore->load(key).value(); return blockstore::utils::copyToNewBlock(baseBlockStore, *source)->key(); } + +private: + DISALLOW_COPY_AND_ASSIGN(EncryptedBlockStoreTest); }; TEST_F(EncryptedBlockStoreTest, LoadingWithSameKeyWorks_WriteOnCreate) { diff --git a/test/implementations/ondisk/OnDiskBlockStoreTest.cpp b/test/implementations/ondisk/OnDiskBlockStoreTest.cpp index 69a89da9..fc59b57b 100644 --- a/test/implementations/ondisk/OnDiskBlockStoreTest.cpp +++ b/test/implementations/ondisk/OnDiskBlockStoreTest.cpp @@ -17,6 +17,8 @@ using cpputils::make_unique_ref; class OnDiskBlockStoreTestFixture: public BlockStoreTestFixture { public: + OnDiskBlockStoreTestFixture(): tempdir() {} + unique_ref createBlockStore() override { return make_unique_ref(tempdir.path()); } @@ -28,6 +30,8 @@ INSTANTIATE_TYPED_TEST_CASE_P(OnDisk, BlockStoreTest, OnDiskBlockStoreTestFixtur class OnDiskBlockStoreWithRandomKeysTestFixture: public BlockStoreWithRandomKeysTestFixture { public: + OnDiskBlockStoreWithRandomKeysTestFixture(): tempdir() {} + unique_ref createBlockStore() override { return make_unique_ref(tempdir.path()); } diff --git a/test/interface/helpers/BlockStoreWithRandomKeysTest.cpp b/test/interface/helpers/BlockStoreWithRandomKeysTest.cpp index c3e3b05e..b88a5add 100644 --- a/test/interface/helpers/BlockStoreWithRandomKeysTest.cpp +++ b/test/interface/helpers/BlockStoreWithRandomKeysTest.cpp @@ -44,9 +44,12 @@ public: class BlockStoreWithRandomKeysTest: public Test { public: + BlockStoreWithRandomKeysTest() :blockStoreMock(), blockStore(blockStoreMock), + key(Key::FromString("1491BB4932A389EE14BC7090AC772972")) {} + BlockStoreWithRandomKeysMock blockStoreMock; - BlockStore &blockStore = blockStoreMock; - const blockstore::Key key = Key::FromString("1491BB4932A389EE14BC7090AC772972"); + BlockStore &blockStore; + const blockstore::Key key; Data createDataWithSize(size_t size) { Data fixture(DataFixture::generate(size)); diff --git a/test/testutils/BlockStoreTest.h b/test/testutils/BlockStoreTest.h index baec056d..91980125 100644 --- a/test/testutils/BlockStoreTest.h +++ b/test/testutils/BlockStoreTest.h @@ -8,12 +8,15 @@ class BlockStoreTestFixture { public: + virtual ~BlockStoreTestFixture() {} virtual cpputils::unique_ref createBlockStore() = 0; }; template class BlockStoreTest: public ::testing::Test { public: + BlockStoreTest() :fixture() {} + BOOST_STATIC_ASSERT_MSG( (std::is_base_of::value), "Given test fixture for instantiating the (type parameterized) BlockStoreTest must inherit from BlockStoreTestFixture" diff --git a/test/testutils/BlockStoreWithRandomKeysTest.h b/test/testutils/BlockStoreWithRandomKeysTest.h index b2527af2..6dbcbf96 100644 --- a/test/testutils/BlockStoreWithRandomKeysTest.h +++ b/test/testutils/BlockStoreWithRandomKeysTest.h @@ -8,12 +8,15 @@ class BlockStoreWithRandomKeysTestFixture { public: + virtual ~BlockStoreWithRandomKeysTestFixture() {} virtual cpputils::unique_ref createBlockStore() = 0; }; template class BlockStoreWithRandomKeysTest: public ::testing::Test { public: + BlockStoreWithRandomKeysTest(): fixture() {} + BOOST_STATIC_ASSERT_MSG( (std::is_base_of::value), "Given test fixture for instantiating the (type parameterized) BlockStoreWithRandomKeysTest must inherit from BlockStoreWithRandomKeysTestFixture"