From 78a6e07c839aa4b8a2a8e0ee2a17341ef9007c1e Mon Sep 17 00:00:00 2001 From: Yuchi Chen Date: Mon, 22 Apr 2019 15:59:16 -0700 Subject: [PATCH] Fix compilation errors for 32bits/LITE/ios build. (#5220) Summary: When I build RocksDB for 32bits/LITE/iOS environment, some errors like the following. ` table/block_based_table_reader.cc:971:44: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'size_t' (aka 'unsigned long') [-Werror,-Wshorten-64-to-32] size_t block_size = props_block_handle.size(); ~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~^~~~~~ ./util/file_reader_writer.h:177:8: error: private field 'env_' is not used [-Werror,-Wunused-private-field] Env* env_; ^ ` Pull Request resolved: https://github.com/facebook/rocksdb/pull/5220 Differential Revision: D15023481 Pulled By: siying fbshipit-source-id: 1b5d121d3016f2b0a8a9a2cc1bd638479357f9f7 --- monitoring/iostats_context_imp.h | 2 +- table/block_based_table_builder.cc | 3 ++- table/block_based_table_reader.cc | 2 +- table/meta_blocks.cc | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/monitoring/iostats_context_imp.h b/monitoring/iostats_context_imp.h index 23c2088ca..19e34209b 100644 --- a/monitoring/iostats_context_imp.h +++ b/monitoring/iostats_context_imp.h @@ -55,6 +55,6 @@ extern __thread IOStatsContext iostats_context; #define IOSTATS(metric) 0 #define IOSTATS_TIMER_GUARD(metric) -#define IOSTATS_CPU_TIMER_GUARD(metric, env) +#define IOSTATS_CPU_TIMER_GUARD(metric, env) static_cast(env) #endif // ROCKSDB_SUPPORT_THREAD_LOCAL diff --git a/table/block_based_table_builder.cc b/table/block_based_table_builder.cc index 738637495..9a1742e5f 100644 --- a/table/block_based_table_builder.cc +++ b/table/block_based_table_builder.cc @@ -1064,7 +1064,8 @@ void BlockBasedTableBuilder::EnterUnbuffered() { if (!r->data_block_and_keys_buffers.empty()) { while (compression_dict_samples.size() < kSampleBytes) { size_t rand_idx = - generator.Uniform(r->data_block_and_keys_buffers.size()); + static_cast( + generator.Uniform(r->data_block_and_keys_buffers.size())); size_t copy_len = std::min(kSampleBytes - compression_dict_samples.size(), r->data_block_and_keys_buffers[rand_idx].first.size()); diff --git a/table/block_based_table_reader.cc b/table/block_based_table_reader.cc index 9db053842..4aefbe7c5 100644 --- a/table/block_based_table_reader.cc +++ b/table/block_based_table_reader.cc @@ -968,7 +968,7 @@ Status BlockBasedTable::TryReadPropertiesWithGlobalSeqno( (*table_properties) ->properties_offsets.find( ExternalSstFilePropertyNames::kGlobalSeqno); - size_t block_size = props_block_handle.size(); + size_t block_size = static_cast(props_block_handle.size()); if (seqno_pos_iter != (*table_properties)->properties_offsets.end()) { uint64_t global_seqno_offset = seqno_pos_iter->second; EncodeFixed64( diff --git a/table/meta_blocks.cc b/table/meta_blocks.cc index 661ea85e6..3f48095c5 100644 --- a/table/meta_blocks.cc +++ b/table/meta_blocks.cc @@ -339,7 +339,7 @@ Status ReadProperties(const Slice& handle_value, RandomAccessFileReader* file, *ret_block_handle = handle; } if (verification_buf != nullptr) { - size_t len = handle.size() + kBlockTrailerSize; + size_t len = static_cast(handle.size() + kBlockTrailerSize); *verification_buf = rocksdb::AllocateBlock(len, memory_allocator); if (verification_buf->get() != nullptr) { memcpy(verification_buf->get(), block_contents.data.data(), len);