From 50b33ebb1bc35ea4e1687b59b800553ffe6d65c8 Mon Sep 17 00:00:00 2001 From: clundro <859287553@qq.com> Date: Wed, 3 May 2023 09:37:21 -0700 Subject: [PATCH] remove redundant move (#11418) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: when I use g++-13 to exec the `make all` command, the output throws the warnings. ``` db/compaction/compaction_job_test.cc: In member function ‘void rocksdb::CompactionJobTestBase::AddMockFile(const rocksdb::mock::KVVector&, int)’: db/compaction/compaction_job_test.cc:376:57: error: redundant move in initialization [-Werror=redundant-move] 376 | env_, GenerateFileName(file_number), std::move(contents))); | ~~~~~~~~~^~~~~~~~~~ db/compaction/compaction_job_test.cc:375:7: note: in expansion of macro ‘EXPECT_OK’ 375 | EXPECT_OK(mock_table_factory_->CreateMockTable( | ^~~~~~~~~ db/compaction/compaction_job_test.cc:376:57: note: remove ‘std::move’ call 376 | env_, GenerateFileName(file_number), std::move(contents))); | ~~~~~~~~~^~~~~~~~~~ db/compaction/compaction_job_test.cc:375:7: note: in expansion of macro ‘EXPECT_OK’ 375 | EXPECT_OK(mock_table_factory_->CreateMockTable( | ^~~~~~~~~ cc1plus: all warnings being treated as errors make: *** [Makefile:2507: db/compaction/compaction_job_test.o] Error 1 ``` and I also add some `(void)unused_variable` statements because of the cmake argument `-Wunused-but-set-variable -Wunused-but-set-variable` Pull Request resolved: https://github.com/facebook/rocksdb/pull/11418 Reviewed By: akankshamahajan15 Differential Revision: D45528223 Pulled By: ajkr fbshipit-source-id: fee1a77c30039a56b481de953f0a834cc788abbc --- .gitignore | 1 + db/compaction/compaction_job_test.cc | 2 +- db/db_test.cc | 1 + file/prefetch_test.cc | 2 ++ memtable/inlineskiplist_test.cc | 1 + memtable/skiplist_test.cc | 1 + tools/db_bench_tool.cc | 2 ++ 7 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1ff5b7437..9b4ac1591 100644 --- a/.gitignore +++ b/.gitignore @@ -95,3 +95,4 @@ fuzz/crash-* cmake-build-* third-party/folly/ +.cache \ No newline at end of file diff --git a/db/compaction/compaction_job_test.cc b/db/compaction/compaction_job_test.cc index 79f8e5fd5..3f7966404 100644 --- a/db/compaction/compaction_job_test.cc +++ b/db/compaction/compaction_job_test.cc @@ -373,7 +373,7 @@ class CompactionJobTestBase : public testing::Test { } else if (table_type_ == TableTypeForTest::kMockTable) { file_size = 10; EXPECT_OK(mock_table_factory_->CreateMockTable( - env_, GenerateFileName(file_number), std::move(contents))); + env_, GenerateFileName(file_number), contents)); } else { assert(false); } diff --git a/db/db_test.cc b/db/db_test.cc index 7720cbbe4..1b01422a9 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -3460,6 +3460,7 @@ static bool CompareIterators(int step, DB* model, DB* db, ok = false; } } + (void)count; delete miter; delete dbiter; return ok; diff --git a/file/prefetch_test.cc b/file/prefetch_test.cc index 488e037ff..fb3114449 100644 --- a/file/prefetch_test.cc +++ b/file/prefetch_test.cc @@ -220,6 +220,7 @@ TEST_P(PrefetchTest, Basic) { for (iter->SeekToFirst(); iter->Valid(); iter->Next()) { num_keys++; } + (void)num_keys; } // Make sure prefetch is called only if file system support prefetch. @@ -1803,6 +1804,7 @@ TEST_P(PrefetchTest, MultipleSeekWithPosixFS) { } MoveFilesToLevel(2); } + (void)total_keys; int num_keys_first_batch = 0; int num_keys_second_batch = 0; diff --git a/memtable/inlineskiplist_test.cc b/memtable/inlineskiplist_test.cc index f85644064..930574ec7 100644 --- a/memtable/inlineskiplist_test.cc +++ b/memtable/inlineskiplist_test.cc @@ -576,6 +576,7 @@ static void ConcurrentReader(void* arg) { state->t_.ReadStep(&rnd); ++reads; } + (void)reads; state->Change(TestState::DONE); } diff --git a/memtable/skiplist_test.cc b/memtable/skiplist_test.cc index a07088511..868c51876 100644 --- a/memtable/skiplist_test.cc +++ b/memtable/skiplist_test.cc @@ -348,6 +348,7 @@ static void ConcurrentReader(void* arg) { state->t_.ReadStep(&rnd); ++reads; } + (void)reads; state->Change(TestState::DONE); } diff --git a/tools/db_bench_tool.cc b/tools/db_bench_tool.cc index ea40f5fa0..19ca1b4c0 100644 --- a/tools/db_bench_tool.cc +++ b/tools/db_bench_tool.cc @@ -6984,6 +6984,8 @@ class Benchmark { thread->stats.FinishedOps(&db_, db_.db, 1, kSeek); } + (void)num_seek_to_first; + (void)num_next; delete iter; }