From c9a5e48762e0ba3e9195786b49ca265ee7afe99d Mon Sep 17 00:00:00 2001 From: Burton Li Date: Thu, 30 Jan 2020 16:05:44 -0800 Subject: [PATCH] fix build warnnings on MSVC (#6309) Summary: Fix build warnings on MSVC. siying Pull Request resolved: https://github.com/facebook/rocksdb/pull/6309 Differential Revision: D19455012 Pulled By: ltamasi fbshipit-source-id: 940739f2c92de60e47cc2bed8dd7f921459545a9 --- db_stress_tool/db_stress_common.cc | 5 ++--- db_stress_tool/db_stress_test_base.cc | 4 ++-- util/filter_bench.cc | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/db_stress_tool/db_stress_common.cc b/db_stress_tool/db_stress_common.cc index 454256dd5..8834c533a 100644 --- a/db_stress_tool/db_stress_common.cc +++ b/db_stress_tool/db_stress_common.cc @@ -62,7 +62,7 @@ void InitializeHotKeyGenerator(double alpha) { int64_t GetOneHotKeyID(double rand_seed, int64_t max_key) { int64_t low = 1, mid, high = zipf_sum_size, zipf = 0; while (low <= high) { - mid = std::floor((low + high) / 2); + mid = (low + high) / 2; if (sum_probs[mid] >= rand_seed && sum_probs[mid - 1] < rand_seed) { zipf = mid; break; @@ -72,8 +72,7 @@ int64_t GetOneHotKeyID(double rand_seed, int64_t max_key) { low = mid + 1; } } - int64_t tmp_zipf_seed = static_cast( - std::floor(zipf * max_key / (static_cast(zipf_sum_size)))); + int64_t tmp_zipf_seed = zipf * max_key / zipf_sum_size; Random64 rand_local(tmp_zipf_seed); return rand_local.Next() % max_key; } diff --git a/db_stress_tool/db_stress_test_base.cc b/db_stress_tool/db_stress_test_base.cc index 6ed5f1536..0d3b29409 100644 --- a/db_stress_tool/db_stress_test_base.cc +++ b/db_stress_tool/db_stress_test_base.cc @@ -771,7 +771,7 @@ std::vector StressTest::GetWhiteBoxKeys(ThreadState* thread, k[i] = static_cast(cur - 1); break; } else if (i > 0) { - k[i] = 0xFF; + k[i] = 0xFFu; } } } else if (thread->rand.OneIn(2)) { @@ -1550,7 +1550,7 @@ void StressTest::TestCompactRange(ThreadState* thread, int64_t rand_key, cro.max_subcompactions = static_cast(thread->rand.Next() % 4); const Snapshot* pre_snapshot = nullptr; - uint32_t pre_hash; + uint32_t pre_hash = 0; if (thread->rand.OneIn(2)) { // Do some validation by declaring a snapshot and compare the data before // and after the compaction diff --git a/util/filter_bench.cc b/util/filter_bench.cc index d466a469d..482865129 100644 --- a/util/filter_bench.cc +++ b/util/filter_bench.cc @@ -330,8 +330,8 @@ void FilterBench::Go() { if (FLAGS_use_plain_table_bloom) { info.plain_table_bloom_.reset(new PlainTableBloomV1()); info.plain_table_bloom_->SetTotalBits( - &arena_, keys_to_add * FLAGS_bits_per_key, FLAGS_impl, - 0 /*huge_page*/, nullptr /*logger*/); + &arena_, static_cast(keys_to_add * FLAGS_bits_per_key), + FLAGS_impl, 0 /*huge_page*/, nullptr /*logger*/); for (uint32_t i = 0; i < keys_to_add; ++i) { uint32_t hash = GetSliceHash(kms_[0].Get(filter_id, i)); info.plain_table_bloom_->AddHash(hash);