From 73b175a7738a53cf9a906ef1389962378c7ddf72 Mon Sep 17 00:00:00 2001 From: Zhipeng Jia Date: Thu, 24 Dec 2015 04:10:00 +0800 Subject: [PATCH 1/2] Fix clang warnings regarding unnecessary std::move --- db/db_log_iter_test.cc | 2 +- db/wal_manager.cc | 4 ++-- db/wal_manager_test.cc | 4 ++-- utilities/backupable/backupable_db.cc | 8 ++++---- utilities/document/json_document.cc | 4 ++-- utilities/flashcache/flashcache.cc | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/db/db_log_iter_test.cc b/db/db_log_iter_test.cc index 64a74e02e..33b5e4ef9 100644 --- a/db/db_log_iter_test.cc +++ b/db/db_log_iter_test.cc @@ -27,7 +27,7 @@ class DBTestXactLogIterator : public DBTestBase { Status status = dbfull()->GetUpdatesSince(seq, &iter); EXPECT_OK(status); EXPECT_TRUE(iter->Valid()); - return std::move(iter); + return iter; } }; diff --git a/db/wal_manager.cc b/db/wal_manager.cc index 58b0b1643..adeb6b96f 100644 --- a/db/wal_manager.cc +++ b/db/wal_manager.cc @@ -329,8 +329,8 @@ Status WalManager::GetSortedWalsOfType(const std::string& path, return s; } - log_files.push_back(std::move(std::unique_ptr( - new LogFileImpl(number, log_type, sequence, size_bytes)))); + log_files.push_back(std::unique_ptr( + new LogFileImpl(number, log_type, sequence, size_bytes))); } } CompareLogByPointer compare_log_files; diff --git a/db/wal_manager_test.cc b/db/wal_manager_test.cc index 428f4c954..764706d33 100644 --- a/db/wal_manager_test.cc +++ b/db/wal_manager_test.cc @@ -95,7 +95,7 @@ class WalManagerTest : public testing::Test { Status status = wal_manager_->GetUpdatesSince( seq, &iter, TransactionLogIterator::ReadOptions(), versions_.get()); EXPECT_OK(status); - return std::move(iter); + return iter; } std::unique_ptr env_; @@ -184,7 +184,7 @@ std::vector ListSpecificFiles( } } } - return std::move(file_numbers); + return file_numbers; } int CountRecords(TransactionLogIterator* iter) { diff --git a/utilities/backupable/backupable_db.cc b/utilities/backupable/backupable_db.cc index 3a3d152ee..b4964950a 100644 --- a/utilities/backupable/backupable_db.cc +++ b/utilities/backupable/backupable_db.cc @@ -521,10 +521,10 @@ Status BackupEngineImpl::Initialize() { continue; } assert(backups_.find(backup_id) == backups_.end()); - backups_.insert(std::move( + backups_.insert( std::make_pair(backup_id, unique_ptr(new BackupMeta( GetBackupMetaFile(backup_id), - &backuped_file_infos_, backup_env_))))); + &backuped_file_infos_, backup_env_)))); } latest_backup_id_ = 0; @@ -619,10 +619,10 @@ Status BackupEngineImpl::CreateNewBackup( BackupID new_backup_id = latest_backup_id_ + 1; assert(backups_.find(new_backup_id) == backups_.end()); - auto ret = backups_.insert(std::move( + auto ret = backups_.insert( std::make_pair(new_backup_id, unique_ptr(new BackupMeta( GetBackupMetaFile(new_backup_id), - &backuped_file_infos_, backup_env_))))); + &backuped_file_infos_, backup_env_)))); assert(ret.second == true); auto& new_backup = ret.first->second; new_backup->RecordTimestamp(); diff --git a/utilities/document/json_document.cc b/utilities/document/json_document.cc index b8d178bb2..f26787b97 100644 --- a/utilities/document/json_document.cc +++ b/utilities/document/json_document.cc @@ -307,7 +307,7 @@ JSONDocument JSONDocument::operator[](const std::string& key) const { assert(foundValue != nullptr); // No need to save paths in const objects JSONDocument ans(foundValue, false); - return std::move(ans); + return ans; } size_t JSONDocument::Count() const { @@ -330,7 +330,7 @@ JSONDocument JSONDocument::operator[](size_t i) const { auto arrayVal = reinterpret_cast(value_); auto foundValue = arrayVal->get(static_cast(i)); JSONDocument ans(foundValue, false); - return std::move(ans); + return ans; } bool JSONDocument::IsNull() const { diff --git a/utilities/flashcache/flashcache.cc b/utilities/flashcache/flashcache.cc index 886d449e8..d50232440 100644 --- a/utilities/flashcache/flashcache.cc +++ b/utilities/flashcache/flashcache.cc @@ -103,7 +103,7 @@ class FlashcacheAwareEnv : public EnvWrapper { std::unique_ptr NewFlashcacheAwareEnv(Env* base, const int cachedev_fd) { std::unique_ptr ret(new FlashcacheAwareEnv(base, cachedev_fd)); - return std::move(ret); + return ret; } int FlashcacheBlacklistCurrentThread(Env* flashcache_aware_env) { From ec2664fefd231e9ad297a8d2da8c5a529aa8cee6 Mon Sep 17 00:00:00 2001 From: Zhipeng Jia Date: Thu, 24 Dec 2015 04:10:28 +0800 Subject: [PATCH 2/2] Fix clang compile error under Linux --- util/options_sanity_check.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/options_sanity_check.h b/util/options_sanity_check.h index 83f7e38c2..6f18a58c8 100644 --- a/util/options_sanity_check.h +++ b/util/options_sanity_check.h @@ -23,7 +23,7 @@ enum OptionsSanityCheckLevel : unsigned char { // The sanity check level for DB options static const std::unordered_map - sanity_level_db_options; + sanity_level_db_options {}; // The sanity check level for column-family options static const std::unordered_map @@ -35,7 +35,7 @@ static const std::unordered_map // The sanity check level for block-based table options static const std::unordered_map - sanity_level_bbt_options; + sanity_level_bbt_options {}; OptionsSanityCheckLevel DBOptionSanityCheckLevel( const std::string& options_name);