1
0
Fork 0

Fixed some compiler warnings.

This commit is contained in:
Dan Larkin 2017-03-13 13:10:22 -04:00
parent 646baee446
commit 45ca4bca08
5 changed files with 21 additions and 22 deletions

View File

@ -71,7 +71,6 @@ bool PlainCache::insert(CachedValue* value) {
if (ok) {
bool allowed = true;
bool eviction = false;
bool maybeMigrate = false;
int64_t change = static_cast<int64_t>(value->size());
CachedValue* candidate = bucket->find(hash, value->key(), value->keySize);
@ -93,6 +92,7 @@ bool PlainCache::insert(CachedValue* value) {
_metadata.unlock();
if (allowed) {
bool eviction = false;
if (candidate != nullptr) {
bucket->evict(candidate, true);
freeValue(candidate);
@ -121,7 +121,6 @@ bool PlainCache::insert(CachedValue* value) {
bool PlainCache::remove(void const* key, uint32_t keySize) {
TRI_ASSERT(key != nullptr);
bool removed = false;
bool maybeMigrate = false;
uint32_t hash = hashKey(key, keySize);
bool ok;
@ -130,6 +129,7 @@ bool PlainCache::remove(void const* key, uint32_t keySize) {
std::tie(ok, bucket, source) = getBucket(hash, Cache::triesSlow);
if (ok) {
bool maybeMigrate = false;
CachedValue* candidate = bucket->remove(hash, key, keySize);
if (candidate != nullptr) {

View File

@ -180,7 +180,7 @@ std::unique_ptr<Table::Subtable> Table::auxiliaryBuckets(uint32_t index) {
uint32_t diff = _auxiliary->_logSize - _logSize;
base = &(_auxiliary->_buckets[index << diff]);
size = static_cast<uint64_t>(1) << diff;
mask = ((size - 1) << _auxiliary->_shift);
mask = (static_cast<uint32_t>(size - 1) << _auxiliary->_shift);
shift = _auxiliary->_shift;
}
_state.unlock();

View File

@ -75,7 +75,6 @@ bool TransactionalCache::insert(CachedValue* value) {
bool maybeMigrate = false;
bool allowed = !bucket->isBlacklisted(hash);
if (allowed) {
bool eviction = false;
int64_t change = value->size();
CachedValue* candidate = bucket->find(hash, value->key(), value->keySize);
@ -96,6 +95,7 @@ bool TransactionalCache::insert(CachedValue* value) {
_metadata.unlock();
if (allowed) {
bool eviction = false;
if (candidate != nullptr) {
bucket->evict(candidate, true);
freeValue(candidate);

View File

@ -52,7 +52,8 @@ TEST_CASE("cache::CachedValue", "[cache]") {
delete cv;
// variable key, fixed value
cv = CachedValue::construct(v.data(), v.size(), &k, sizeof(uint64_t));
cv = CachedValue::construct(v.data(), static_cast<uint32_t>(v.size()), &k,
sizeof(uint64_t));
REQUIRE(nullptr != cv);
REQUIRE(v.size() == cv->keySize);
REQUIRE(sizeof(uint64_t) == cv->valueSize);
@ -119,17 +120,17 @@ TEST_CASE("cache::CachedValue", "[cache]") {
std::string k3("TEST");
uint64_t v = 1;
auto cv =
CachedValue::construct(k1.data(), k1.size(), &v, sizeof(uint64_t));
auto cv = CachedValue::construct(
k1.data(), static_cast<uint32_t>(k1.size()), &v, sizeof(uint64_t));
// same key
REQUIRE(cv->sameKey(k1.data(), k1.size()));
REQUIRE(cv->sameKey(k1.data(), static_cast<uint32_t>(k1.size())));
// different length, matching prefix
REQUIRE(!cv->sameKey(k2.data(), k2.size()));
REQUIRE(!cv->sameKey(k2.data(), static_cast<uint32_t>(k2.size())));
// same length, different key
REQUIRE(!cv->sameKey(k3.data(), k3.size()));
REQUIRE(!cv->sameKey(k3.data(), static_cast<uint32_t>(k3.size())));
delete cv;
}

View File

@ -102,10 +102,9 @@ TEST_CASE("cache::Table", "[cache]") {
auto res = small->setAuxiliary(large);
REQUIRE(res.get() == nullptr);
uint64_t indexSmall = 17; // picked something at "random"
uint64_t indexLarge = indexSmall << 2;
uint32_t hash =
static_cast<uint32_t>(indexSmall << (32 - small->logSize()));
uint32_t indexSmall = 17; // picked something at "random"
uint32_t indexLarge = indexSmall << 2;
uint32_t hash = indexSmall << (32 - small->logSize());
auto pair = small->fetchAndLockBucket(hash, -1);
auto bucket = reinterpret_cast<PlainBucket*>(pair.first);
@ -132,10 +131,9 @@ TEST_CASE("cache::Table", "[cache]") {
auto res = large->setAuxiliary(small);
REQUIRE(res.get() == nullptr);
uint64_t indexLarge = 822; // picked something at "random"
uint64_t indexSmall = indexLarge >> 2;
uint32_t hash =
static_cast<uint32_t>(indexLarge << (32 - large->logSize()));
uint32_t indexLarge = 822; // picked something at "random"
uint32_t indexSmall = indexLarge >> 2;
uint32_t hash = indexLarge << (32 - large->logSize());
auto subtable = large->auxiliaryBuckets(indexLarge);
REQUIRE(subtable.get() != nullptr);
@ -147,8 +145,8 @@ TEST_CASE("cache::Table", "[cache]") {
auto res = small->setAuxiliary(large);
REQUIRE(res.get() == nullptr);
uint64_t indexSmall = 217; // picked something at "random"
uint64_t indexLargeBase = indexSmall << 2;
uint32_t indexSmall = 217; // picked something at "random"
uint32_t indexLargeBase = indexSmall << 2;
auto subtable = small->auxiliaryBuckets(indexSmall);
REQUIRE(subtable.get() != nullptr);
@ -164,8 +162,8 @@ TEST_CASE("cache::Table", "[cache]") {
auto res = small->setAuxiliary(large);
REQUIRE(res.get() == nullptr);
uint64_t indexSmall = 172; // picked something at "random"
uint64_t indexLargeBase = indexSmall << 2;
uint32_t indexSmall = 172; // picked something at "random"
uint32_t indexLargeBase = indexSmall << 2;
auto subtable = small->auxiliaryBuckets(indexSmall);
REQUIRE(subtable.get() != nullptr);