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> constexpr double Cache<Key, Value, MAX_ENTRIES>::MAX_LIFETIME_SEC;
|
||||||
|
|
||||||
template<class Key, class Value, uint32_t MAX_ENTRIES>
|
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,
|
//Don't initialize timeoutFlusher in the initializer list,
|
||||||
//because it then might already call Cache::popOldEntries() before Cache is done constructing.
|
//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);
|
_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)),
|
_baseBlock(std::move(baseBlock)),
|
||||||
_plaintextWithHeader(std::move(plaintextWithHeader)),
|
_plaintextWithHeader(std::move(plaintextWithHeader)),
|
||||||
_encKey(encKey),
|
_encKey(encKey),
|
||||||
_dataChanged(false) {
|
_dataChanged(false),
|
||||||
|
_mutex() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Cipher>
|
template<class Cipher>
|
||||||
|
@ -23,7 +23,7 @@ namespace blockstore {
|
|||||||
namespace ondisk {
|
namespace ondisk {
|
||||||
|
|
||||||
OnDiskBlock::OnDiskBlock(const Key &key, const bf::path &filepath, Data data)
|
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() {
|
OnDiskBlock::~OnDiskBlock() {
|
||||||
|
@ -16,7 +16,7 @@ namespace blockstore {
|
|||||||
namespace testfake {
|
namespace testfake {
|
||||||
|
|
||||||
FakeBlockStore::FakeBlockStore()
|
FakeBlockStore::FakeBlockStore()
|
||||||
: _blocks(), _used_dataregions_for_blocks() {}
|
: _blocks(), _used_dataregions_for_blocks(), _mutex() {}
|
||||||
|
|
||||||
optional<unique_ref<Block>> FakeBlockStore::tryCreate(const Key &key, Data data) {
|
optional<unique_ref<Block>> FakeBlockStore::tryCreate(const Key &key, Data data) {
|
||||||
std::unique_lock<std::mutex> lock(_mutex);
|
std::unique_lock<std::mutex> lock(_mutex);
|
||||||
|
@ -30,6 +30,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
ConditionBarrier *_onDestructorStarted;
|
ConditionBarrier *_onDestructorStarted;
|
||||||
bool *_destructorFinished;
|
bool *_destructorFinished;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(ObjectWithLongDestructor);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CacheTest_RaceCondition: public ::testing::Test {
|
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).
|
// 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 {
|
class CacheTest: public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
|
CacheTest(): _cache() {}
|
||||||
|
|
||||||
void push(int key, int value);
|
void push(int key, int value);
|
||||||
boost::optional<int> pop(int key);
|
boost::optional<int> pop(int key);
|
||||||
|
|
||||||
|
@ -49,6 +49,9 @@ public:
|
|||||||
auto source = baseBlockStore->load(key).value();
|
auto source = baseBlockStore->load(key).value();
|
||||||
return blockstore::utils::copyToNewBlock(baseBlockStore, *source)->key();
|
return blockstore::utils::copyToNewBlock(baseBlockStore, *source)->key();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(EncryptedBlockStoreTest);
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(EncryptedBlockStoreTest, LoadingWithSameKeyWorks_WriteOnCreate) {
|
TEST_F(EncryptedBlockStoreTest, LoadingWithSameKeyWorks_WriteOnCreate) {
|
||||||
|
@ -17,6 +17,8 @@ using cpputils::make_unique_ref;
|
|||||||
|
|
||||||
class OnDiskBlockStoreTestFixture: public BlockStoreTestFixture {
|
class OnDiskBlockStoreTestFixture: public BlockStoreTestFixture {
|
||||||
public:
|
public:
|
||||||
|
OnDiskBlockStoreTestFixture(): tempdir() {}
|
||||||
|
|
||||||
unique_ref<BlockStore> createBlockStore() override {
|
unique_ref<BlockStore> createBlockStore() override {
|
||||||
return make_unique_ref<OnDiskBlockStore>(tempdir.path());
|
return make_unique_ref<OnDiskBlockStore>(tempdir.path());
|
||||||
}
|
}
|
||||||
@ -28,6 +30,8 @@ INSTANTIATE_TYPED_TEST_CASE_P(OnDisk, BlockStoreTest, OnDiskBlockStoreTestFixtur
|
|||||||
|
|
||||||
class OnDiskBlockStoreWithRandomKeysTestFixture: public BlockStoreWithRandomKeysTestFixture {
|
class OnDiskBlockStoreWithRandomKeysTestFixture: public BlockStoreWithRandomKeysTestFixture {
|
||||||
public:
|
public:
|
||||||
|
OnDiskBlockStoreWithRandomKeysTestFixture(): tempdir() {}
|
||||||
|
|
||||||
unique_ref<BlockStoreWithRandomKeys> createBlockStore() override {
|
unique_ref<BlockStoreWithRandomKeys> createBlockStore() override {
|
||||||
return make_unique_ref<OnDiskBlockStore>(tempdir.path());
|
return make_unique_ref<OnDiskBlockStore>(tempdir.path());
|
||||||
}
|
}
|
||||||
|
@ -44,9 +44,12 @@ public:
|
|||||||
|
|
||||||
class BlockStoreWithRandomKeysTest: public Test {
|
class BlockStoreWithRandomKeysTest: public Test {
|
||||||
public:
|
public:
|
||||||
|
BlockStoreWithRandomKeysTest() :blockStoreMock(), blockStore(blockStoreMock),
|
||||||
|
key(Key::FromString("1491BB4932A389EE14BC7090AC772972")) {}
|
||||||
|
|
||||||
BlockStoreWithRandomKeysMock blockStoreMock;
|
BlockStoreWithRandomKeysMock blockStoreMock;
|
||||||
BlockStore &blockStore = blockStoreMock;
|
BlockStore &blockStore;
|
||||||
const blockstore::Key key = Key::FromString("1491BB4932A389EE14BC7090AC772972");
|
const blockstore::Key key;
|
||||||
|
|
||||||
Data createDataWithSize(size_t size) {
|
Data createDataWithSize(size_t size) {
|
||||||
Data fixture(DataFixture::generate(size));
|
Data fixture(DataFixture::generate(size));
|
||||||
|
@ -8,12 +8,15 @@
|
|||||||
|
|
||||||
class BlockStoreTestFixture {
|
class BlockStoreTestFixture {
|
||||||
public:
|
public:
|
||||||
|
virtual ~BlockStoreTestFixture() {}
|
||||||
virtual cpputils::unique_ref<blockstore::BlockStore> createBlockStore() = 0;
|
virtual cpputils::unique_ref<blockstore::BlockStore> createBlockStore() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class ConcreteBlockStoreTestFixture>
|
template<class ConcreteBlockStoreTestFixture>
|
||||||
class BlockStoreTest: public ::testing::Test {
|
class BlockStoreTest: public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
|
BlockStoreTest() :fixture() {}
|
||||||
|
|
||||||
BOOST_STATIC_ASSERT_MSG(
|
BOOST_STATIC_ASSERT_MSG(
|
||||||
(std::is_base_of<BlockStoreTestFixture, ConcreteBlockStoreTestFixture>::value),
|
(std::is_base_of<BlockStoreTestFixture, ConcreteBlockStoreTestFixture>::value),
|
||||||
"Given test fixture for instantiating the (type parameterized) BlockStoreTest must inherit from BlockStoreTestFixture"
|
"Given test fixture for instantiating the (type parameterized) BlockStoreTest must inherit from BlockStoreTestFixture"
|
||||||
|
@ -8,12 +8,15 @@
|
|||||||
|
|
||||||
class BlockStoreWithRandomKeysTestFixture {
|
class BlockStoreWithRandomKeysTestFixture {
|
||||||
public:
|
public:
|
||||||
|
virtual ~BlockStoreWithRandomKeysTestFixture() {}
|
||||||
virtual cpputils::unique_ref<blockstore::BlockStoreWithRandomKeys> createBlockStore() = 0;
|
virtual cpputils::unique_ref<blockstore::BlockStoreWithRandomKeys> createBlockStore() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class ConcreteBlockStoreWithRandomKeysTestFixture>
|
template<class ConcreteBlockStoreWithRandomKeysTestFixture>
|
||||||
class BlockStoreWithRandomKeysTest: public ::testing::Test {
|
class BlockStoreWithRandomKeysTest: public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
|
BlockStoreWithRandomKeysTest(): fixture() {}
|
||||||
|
|
||||||
BOOST_STATIC_ASSERT_MSG(
|
BOOST_STATIC_ASSERT_MSG(
|
||||||
(std::is_base_of<BlockStoreWithRandomKeysTestFixture, ConcreteBlockStoreWithRandomKeysTestFixture>::value),
|
(std::is_base_of<BlockStoreWithRandomKeysTestFixture, ConcreteBlockStoreWithRandomKeysTestFixture>::value),
|
||||||
"Given test fixture for instantiating the (type parameterized) BlockStoreWithRandomKeysTest must inherit from BlockStoreWithRandomKeysTestFixture"
|
"Given test fixture for instantiating the (type parameterized) BlockStoreWithRandomKeysTest must inherit from BlockStoreWithRandomKeysTestFixture"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user