fix MSVC build failures (#6517)

Summary:
fix a few build warnings that are treated as failures with more strict MSVC warning settings
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6517

Differential Revision: D20401325

Pulled By: pdillinger

fbshipit-source-id: b44979dfaafdc7b3b8cb44a565400a99b331dd30
This commit is contained in:
Huisheng Liu 2020-03-12 08:39:46 -07:00 committed by Facebook GitHub Bot
parent 6dea7530b5
commit 07a3f7f008
3 changed files with 18 additions and 13 deletions

View File

@ -1527,7 +1527,7 @@ bool tryUnlockClean(Atomic& state, Proxy& proxy, Sleepers sleepers) {
template <template <typename> class Atomic, bool Publish> template <template <typename> class Atomic, bool Publish>
void DistributedMutex<Atomic, Publish>::unlock( void DistributedMutex<Atomic, Publish>::unlock(
DistributedMutex::DistributedMutexStateProxy proxy) { typename DistributedMutex::DistributedMutexStateProxy proxy) {
// we always wake up ready threads and timed waiters if we saw either // we always wake up ready threads and timed waiters if we saw either
assert(proxy); assert(proxy);
assert(!proxy.combined_); assert(!proxy.combined_);

View File

@ -327,7 +327,7 @@ TEST_F(BlockCacheTracerTest, BlockCacheAnalyzer) {
} }
num_misses += ParseInt(substr); num_misses += ParseInt(substr);
} }
ASSERT_EQ(51, num_misses); ASSERT_EQ(51u, num_misses);
ASSERT_FALSE(getline(mt_file, line)); ASSERT_FALSE(getline(mt_file, line));
mt_file.close(); mt_file.close();
ASSERT_OK(env_->DeleteFile(miss_timeline_path)); ASSERT_OK(env_->DeleteFile(miss_timeline_path));
@ -594,7 +594,7 @@ TEST_F(BlockCacheTracerTest, BlockCacheAnalyzer) {
sum_percent += ParseDouble(percent); sum_percent += ParseDouble(percent);
nrows++; nrows++;
} }
ASSERT_EQ(11, nrows); ASSERT_EQ(11u, nrows);
ASSERT_EQ(100.0, sum_percent); ASSERT_EQ(100.0, sum_percent);
ASSERT_OK(env_->DeleteFile(filename)); ASSERT_OK(env_->DeleteFile(filename));
} }
@ -632,8 +632,10 @@ TEST_F(BlockCacheTracerTest, MixedBlocks) {
BlockCacheTraceReader reader(std::move(trace_reader)); BlockCacheTraceReader reader(std::move(trace_reader));
BlockCacheTraceHeader header; BlockCacheTraceHeader header;
ASSERT_OK(reader.ReadHeader(&header)); ASSERT_OK(reader.ReadHeader(&header));
ASSERT_EQ(kMajorVersion, header.rocksdb_major_version); ASSERT_EQ(static_cast<uint32_t>(kMajorVersion),
ASSERT_EQ(kMinorVersion, header.rocksdb_minor_version); header.rocksdb_major_version);
ASSERT_EQ(static_cast<uint32_t>(kMinorVersion),
header.rocksdb_minor_version);
// Read blocks. // Read blocks.
BlockCacheTraceAnalyzer analyzer( BlockCacheTraceAnalyzer analyzer(
trace_file_path_, trace_file_path_,

View File

@ -200,14 +200,14 @@ TEST_F(BlockBasedBloomTest, Schema) {
Add(Key(key, buffer)); Add(Key(key, buffer));
} }
Build(); Build();
ASSERT_EQ(BloomHash(FilterData()), 969445585); ASSERT_EQ(BloomHash(FilterData()), 969445585U);
ResetPolicy(11); // num_probes = 7 ResetPolicy(11); // num_probes = 7
for (int key = 0; key < 87; key++) { for (int key = 0; key < 87; key++) {
Add(Key(key, buffer)); Add(Key(key, buffer));
} }
Build(); Build();
ASSERT_EQ(BloomHash(FilterData()), 1694458207); ASSERT_EQ(BloomHash(FilterData()), 1694458207U);
ResetPolicy(10); // num_probes = 6 ResetPolicy(10); // num_probes = 6
for (int key = 0; key < 87; key++) { for (int key = 0; key < 87; key++) {
@ -221,7 +221,7 @@ TEST_F(BlockBasedBloomTest, Schema) {
Add(Key(key, buffer)); Add(Key(key, buffer));
} }
Build(); Build();
ASSERT_EQ(BloomHash(FilterData()), 1908442116); ASSERT_EQ(BloomHash(FilterData()), 1908442116U);
ResetPolicy(10); ResetPolicy(10);
for (int key = 1; key < /*CHANGED*/ 88; key++) { for (int key = 1; key < /*CHANGED*/ 88; key++) {
@ -623,7 +623,8 @@ TEST_P(FullBloomTest, Schema) {
Add(Key(key, buffer)); Add(Key(key, buffer));
} }
Build(); Build();
EXPECT_EQ(GetNumProbesFromFilterData(), SelectByImpl(9, 8)); EXPECT_EQ(static_cast<uint32_t>(GetNumProbesFromFilterData()),
SelectByImpl(9, 8));
EXPECT_EQ( EXPECT_EQ(
BloomHash(FilterData()), BloomHash(FilterData()),
SelectByImpl(SelectByCacheLineSize(178861123, 379087593, 2574136516U), SelectByImpl(SelectByCacheLineSize(178861123, 379087593, 2574136516U),
@ -642,7 +643,8 @@ TEST_P(FullBloomTest, Schema) {
Add(Key(key, buffer)); Add(Key(key, buffer));
} }
Build(); Build();
EXPECT_EQ(GetNumProbesFromFilterData(), SelectByImpl(11, 9)); EXPECT_EQ(static_cast<uint32_t>(GetNumProbesFromFilterData()),
SelectByImpl(11, 9));
EXPECT_EQ( EXPECT_EQ(
BloomHash(FilterData()), BloomHash(FilterData()),
SelectByImpl(SelectByCacheLineSize(1129406313, 3049154394U, 1727750964), SelectByImpl(SelectByCacheLineSize(1129406313, 3049154394U, 1727750964),
@ -716,7 +718,8 @@ TEST_P(FullBloomTest, Schema) {
Add(Key(key, buffer)); Add(Key(key, buffer));
} }
Build(); Build();
EXPECT_EQ(GetNumProbesFromFilterData(), SelectByImpl(6, 7)); EXPECT_EQ(static_cast<uint32_t>(GetNumProbesFromFilterData()),
SelectByImpl(6, 7));
EXPECT_EQ(BloomHash(FilterData()), EXPECT_EQ(BloomHash(FilterData()),
SelectByImpl(/*SAME*/ SelectByCacheLineSize(2885052954U, 769447944, SelectByImpl(/*SAME*/ SelectByCacheLineSize(2885052954U, 769447944,
4175124908U), 4175124908U),
@ -858,11 +861,11 @@ TEST_P(FullBloomTest, CorruptFilters) {
// Bad filter bits - returns false as if built from zero keys // Bad filter bits - returns false as if built from zero keys
// < 5 bytes overall means missing even metadata // < 5 bytes overall means missing even metadata
OpenRaw(cft.Reset(-1, 3, 6, fill)); OpenRaw(cft.Reset(static_cast<uint32_t>(-1), 3, 6, fill));
ASSERT_FALSE(Matches("hello")); ASSERT_FALSE(Matches("hello"));
ASSERT_FALSE(Matches("world")); ASSERT_FALSE(Matches("world"));
OpenRaw(cft.Reset(-5, 3, 6, fill)); OpenRaw(cft.Reset(static_cast<uint32_t>(-5), 3, 6, fill));
ASSERT_FALSE(Matches("hello")); ASSERT_FALSE(Matches("hello"));
ASSERT_FALSE(Matches("world")); ASSERT_FALSE(Matches("world"));