From 68effa0348b3368a83ae67ae2245ed9fa2912d18 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Fri, 7 Nov 2014 15:04:30 -0800 Subject: [PATCH] Fix -Wshadow for tools Summary: Previously I made `make check` work with -Wshadow, but there are some tools that are not compiled using `make check`. Test Plan: make all Reviewers: yhchiang, rven, ljin, sdong Reviewed By: ljin, sdong Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D28497 --- db/perf_context_test.cc | 38 ++++++++++++++++++++----------------- table/table_reader_bench.cc | 2 +- tools/blob_store_bench.cc | 24 +++++++++++++---------- tools/db_stress.cc | 7 ++----- tools/sst_dump.cc | 1 - util/cache_bench.cc | 6 ++---- 6 files changed, 40 insertions(+), 38 deletions(-) diff --git a/db/perf_context_test.cc b/db/perf_context_test.cc index 9d34409c3..6669aaec3 100644 --- a/db/perf_context_test.cc +++ b/db/perf_context_test.cc @@ -88,22 +88,27 @@ TEST(PerfContextTest, SeekIntoDeletion) { hist_get_time.Add(elapsed_nanos); } - std::cout << "Get uesr key comparison: \n" << hist_get.ToString() + std::cout << "Get user key comparison: \n" << hist_get.ToString() << "Get time: \n" << hist_get_time.ToString(); - HistogramImpl hist_seek_to_first; - std::unique_ptr iter(db->NewIterator(read_options)); + { + HistogramImpl hist_seek_to_first; + std::unique_ptr iter(db->NewIterator(read_options)); - perf_context.Reset(); - StopWatchNano timer(Env::Default(), true); - iter->SeekToFirst(); - hist_seek_to_first.Add(perf_context.user_key_comparison_count); - auto elapsed_nanos = timer.ElapsedNanos(); + perf_context.Reset(); + StopWatchNano timer(Env::Default(), true); + iter->SeekToFirst(); + hist_seek_to_first.Add(perf_context.user_key_comparison_count); + auto elapsed_nanos = timer.ElapsedNanos(); - std::cout << "SeekToFirst uesr key comparison: \n" << hist_seek_to_first.ToString() - << "ikey skipped: " << perf_context.internal_key_skipped_count << "\n" - << "idelete skipped: " << perf_context.internal_delete_skipped_count << "\n" - << "elapsed: " << elapsed_nanos << "\n"; + std::cout << "SeekToFirst uesr key comparison: \n" + << hist_seek_to_first.ToString() + << "ikey skipped: " << perf_context.internal_key_skipped_count + << "\n" + << "idelete skipped: " + << perf_context.internal_delete_skipped_count << "\n" + << "elapsed: " << elapsed_nanos << "\n"; + } HistogramImpl hist_seek; for (int i = 0; i < FLAGS_total_keys; ++i) { @@ -224,7 +229,6 @@ void ProfileQueries(bool enabled_time = false) { std::string key = "k" + std::to_string(i); std::string value = "v" + std::to_string(i); - std::vector keys = {Slice(key)}; std::vector values; perf_context.Reset(); @@ -239,7 +243,7 @@ void ProfileQueries(bool enabled_time = false) { std::string key = "k" + std::to_string(i); std::string value = "v" + std::to_string(i); - std::vector keys = {Slice(key)}; + std::vector multiget_keys = {Slice(key)}; std::vector values; perf_context.Reset(); @@ -252,7 +256,7 @@ void ProfileQueries(bool enabled_time = false) { hist_get.Add(perf_context.user_key_comparison_count); perf_context.Reset(); - db->MultiGet(read_options, keys, &values); + db->MultiGet(read_options, multiget_keys, &values); hist_mget_snapshot.Add(perf_context.get_snapshot_time); hist_mget_memtable.Add(perf_context.get_from_memtable_time); hist_mget_files.Add(perf_context.get_from_output_files_time); @@ -329,7 +333,7 @@ void ProfileQueries(bool enabled_time = false) { std::string key = "k" + std::to_string(i); std::string value = "v" + std::to_string(i); - std::vector keys = {Slice(key)}; + std::vector multiget_keys = {Slice(key)}; std::vector values; perf_context.Reset(); @@ -342,7 +346,7 @@ void ProfileQueries(bool enabled_time = false) { hist_get.Add(perf_context.user_key_comparison_count); perf_context.Reset(); - db->MultiGet(read_options, keys, &values); + db->MultiGet(read_options, multiget_keys, &values); hist_mget_snapshot.Add(perf_context.get_snapshot_time); hist_mget_memtable.Add(perf_context.get_from_memtable_time); hist_mget_files.Add(perf_context.get_from_output_files_time); diff --git a/table/table_reader_bench.cc b/table/table_reader_bench.cc index e6960f751..ea722a8bf 100644 --- a/table/table_reader_bench.cc +++ b/table/table_reader_bench.cc @@ -115,7 +115,7 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options, unique_ptr table_reader; unique_ptr raf; if (!through_db) { - Status s = env->NewRandomAccessFile(file_name, &raf, env_options); + s = env->NewRandomAccessFile(file_name, &raf, env_options); uint64_t file_size; env->GetFileSize(file_name, &file_size); s = opts.table_factory->NewTableReader( diff --git a/tools/blob_store_bench.cc b/tools/blob_store_bench.cc index 60a0b84a6..7b820a178 100644 --- a/tools/blob_store_bench.cc +++ b/tools/blob_store_bench.cc @@ -59,11 +59,13 @@ struct Result { writes = reads = deletes = data_read = data_written = 0; } - Result (uint32_t writes, uint32_t reads, uint32_t deletes, - uint64_t data_written, uint64_t data_read) : - writes(writes), reads(reads), deletes(deletes), - data_written(data_written), data_read(data_read) {} - + Result(uint32_t _writes, uint32_t _reads, uint32_t _deletes, + uint64_t _data_written, uint64_t _data_read) + : writes(_writes), + reads(_reads), + deletes(_deletes), + data_written(_data_written), + data_read(_data_read) {} }; namespace { @@ -81,11 +83,13 @@ struct WorkerThread { Result result; atomic stopped; - WorkerThread(uint64_t data_size_from, uint64_t data_size_to, - double read_ratio, uint64_t working_set_size) : - data_size_from(data_size_from), data_size_to(data_size_to), - read_ratio(read_ratio), working_set_size(working_set_size), - stopped(false) {} + WorkerThread(uint64_t _data_size_from, uint64_t _data_size_to, + double _read_ratio, uint64_t _working_set_size) + : data_size_from(_data_size_from), + data_size_to(_data_size_to), + read_ratio(_read_ratio), + working_set_size(_working_set_size), + stopped(false) {} WorkerThread(const WorkerThread& wt) : data_size_from(wt.data_size_from), data_size_to(wt.data_size_to), diff --git a/tools/db_stress.cc b/tools/db_stress.cc index 42d0fb534..a0d6ea723 100644 --- a/tools/db_stress.cc +++ b/tools/db_stress.cc @@ -751,11 +751,8 @@ struct ThreadState { SharedState* shared; Stats stats; - ThreadState(uint32_t index, SharedState *shared) - : tid(index), - rand(1000 + index + shared->GetSeed()), - shared(shared) { - } + ThreadState(uint32_t index, SharedState* _shared) + : tid(index), rand(1000 + index + shared->GetSeed()), shared(_shared) {} }; } // namespace diff --git a/tools/sst_dump.cc b/tools/sst_dump.cc index 6c496e8dd..03da2b840 100644 --- a/tools/sst_dump.cc +++ b/tools/sst_dump.cc @@ -378,7 +378,6 @@ int main(int argc, char** argv) { } rocksdb::SstFileReader reader(filename, verify_checksum, output_hex); - rocksdb::Status st; // scan all files in give file path. if (command == "" || command == "scan" || command == "check") { st = reader.ReadSequential(command != "check", diff --git a/util/cache_bench.cc b/util/cache_bench.cc index 3d006ecf8..92df77267 100644 --- a/util/cache_bench.cc +++ b/util/cache_bench.cc @@ -122,10 +122,8 @@ struct ThreadState { Random rnd; SharedState* shared; - ThreadState(uint32_t index, SharedState *shared) - : tid(index), - rnd(1000 + index), - shared(shared) {} + ThreadState(uint32_t index, SharedState* _shared) + : tid(index), rnd(1000 + index), shared(_shared) {} }; } // namespace