Fix warnings from -Weffc++

This commit is contained in:
Sebastian Meßmer 2015-10-17 21:10:26 +02:00
parent 457d5e032b
commit a4ce9f1c97
11 changed files with 27 additions and 6 deletions

View File

@ -52,7 +52,7 @@ template<class Key, class Value, uint32_t MAX_ENTRIES> constexpr double Cache<Ke
template<class Key, class Value, uint32_t MAX_ENTRIES> constexpr double Cache<Key, Value, MAX_ENTRIES>::MAX_LIFETIME_SEC;
template<class Key, class Value, uint32_t MAX_ENTRIES>
Cache<Key, Value, MAX_ENTRIES>::Cache(): _cachedBlocks(), _timeoutFlusher(nullptr) {
Cache<Key, Value, MAX_ENTRIES>::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<PeriodicTask>(std::bind(&Cache::_deleteOldEntriesParallel, this), PURGE_INTERVAL);

View File

@ -111,7 +111,8 @@ EncryptedBlock<Cipher>::EncryptedBlock(cpputils::unique_ref<Block> baseBlock, co
_baseBlock(std::move(baseBlock)),
_plaintextWithHeader(std::move(plaintextWithHeader)),
_encKey(encKey),
_dataChanged(false) {
_dataChanged(false),
_mutex() {
}
template<class Cipher>

View File

@ -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() {

View File

@ -16,7 +16,7 @@ namespace blockstore {
namespace testfake {
FakeBlockStore::FakeBlockStore()
: _blocks(), _used_dataregions_for_blocks() {}
: _blocks(), _used_dataregions_for_blocks(), _mutex() {}
optional<unique_ref<Block>> FakeBlockStore::tryCreate(const Key &key, Data data) {
std::unique_lock<std::mutex> lock(_mutex);

View File

@ -30,6 +30,8 @@ public:
private:
ConditionBarrier *_onDestructorStarted;
bool *_destructorFinished;
DISALLOW_COPY_AND_ASSIGN(ObjectWithLongDestructor);
};
class CacheTest_RaceCondition: public ::testing::Test {

View File

@ -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<int> pop(int key);

View File

@ -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) {

View File

@ -17,6 +17,8 @@ using cpputils::make_unique_ref;
class OnDiskBlockStoreTestFixture: public BlockStoreTestFixture {
public:
OnDiskBlockStoreTestFixture(): tempdir() {}
unique_ref<BlockStore> createBlockStore() override {
return make_unique_ref<OnDiskBlockStore>(tempdir.path());
}
@ -28,6 +30,8 @@ INSTANTIATE_TYPED_TEST_CASE_P(OnDisk, BlockStoreTest, OnDiskBlockStoreTestFixtur
class OnDiskBlockStoreWithRandomKeysTestFixture: public BlockStoreWithRandomKeysTestFixture {
public:
OnDiskBlockStoreWithRandomKeysTestFixture(): tempdir() {}
unique_ref<BlockStoreWithRandomKeys> createBlockStore() override {
return make_unique_ref<OnDiskBlockStore>(tempdir.path());
}

View File

@ -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));

View File

@ -8,12 +8,15 @@
class BlockStoreTestFixture {
public:
virtual ~BlockStoreTestFixture() {}
virtual cpputils::unique_ref<blockstore::BlockStore> createBlockStore() = 0;
};
template<class ConcreteBlockStoreTestFixture>
class BlockStoreTest: public ::testing::Test {
public:
BlockStoreTest() :fixture() {}
BOOST_STATIC_ASSERT_MSG(
(std::is_base_of<BlockStoreTestFixture, ConcreteBlockStoreTestFixture>::value),
"Given test fixture for instantiating the (type parameterized) BlockStoreTest must inherit from BlockStoreTestFixture"

View File

@ -8,12 +8,15 @@
class BlockStoreWithRandomKeysTestFixture {
public:
virtual ~BlockStoreWithRandomKeysTestFixture() {}
virtual cpputils::unique_ref<blockstore::BlockStoreWithRandomKeys> createBlockStore() = 0;
};
template<class ConcreteBlockStoreWithRandomKeysTestFixture>
class BlockStoreWithRandomKeysTest: public ::testing::Test {
public:
BlockStoreWithRandomKeysTest(): fixture() {}
BOOST_STATIC_ASSERT_MSG(
(std::is_base_of<BlockStoreWithRandomKeysTestFixture, ConcreteBlockStoreWithRandomKeysTestFixture>::value),
"Given test fixture for instantiating the (type parameterized) BlockStoreWithRandomKeysTest must inherit from BlockStoreWithRandomKeysTestFixture"