Fix warnings from -Weffc++
This commit is contained in:
parent
457d5e032b
commit
a4ce9f1c97
2
implementations/caching/cache/Cache.h
vendored
2
implementations/caching/cache/Cache.h
vendored
@ -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);
|
||||
|
@ -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>
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
|
@ -30,6 +30,8 @@ public:
|
||||
private:
|
||||
ConditionBarrier *_onDestructorStarted;
|
||||
bool *_destructorFinished;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ObjectWithLongDestructor);
|
||||
};
|
||||
|
||||
class CacheTest_RaceCondition: public ::testing::Test {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user