From 58e7c0e7dd8ca758f4821dc61358b77ce78307ed Mon Sep 17 00:00:00 2001 From: raffertyyu Date: Sat, 11 May 2024 10:34:53 +0800 Subject: [PATCH] fix gcc warning about dangling-reference in backup_engine_test --- utilities/backup/backup_engine_test.cc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/utilities/backup/backup_engine_test.cc b/utilities/backup/backup_engine_test.cc index 917effceab8..9882ea7daaf 100644 --- a/utilities/backup/backup_engine_test.cc +++ b/utilities/backup/backup_engine_test.cc @@ -4406,9 +4406,9 @@ TEST_F(BackupEngineTest, ExcludeFiles) { delete db; db = nullptr; - for (auto be_pair : - {std::make_pair(backup_engine_.get(), alt_backup_engine), - std::make_pair(alt_backup_engine, backup_engine_.get())}) { + auto backup_engine = backup_engine_.get(); + for (auto be_pair : {std::make_pair(backup_engine, alt_backup_engine), + std::make_pair(alt_backup_engine, backup_engine)}) { ASSERT_OK(DestroyDB(dbname_, options_)); RestoreOptions ro; // Fails without alternate dir @@ -4430,9 +4430,9 @@ TEST_F(BackupEngineTest, ExcludeFiles) { CloseBackupEngine(); OpenBackupEngine(); - for (auto be_pair : - {std::make_pair(backup_engine_.get(), alt_backup_engine), - std::make_pair(alt_backup_engine, backup_engine_.get())}) { + backup_engine = backup_engine_.get(); + for (auto be_pair : {std::make_pair(backup_engine, alt_backup_engine), + std::make_pair(alt_backup_engine, backup_engine)}) { ASSERT_OK(DestroyDB(dbname_, options_)); RestoreOptions ro; ro.alternate_dirs.push_front(be_pair.second); @@ -4459,9 +4459,9 @@ TEST_F(BackupEngineTest, ExcludeFiles) { AssertBackupInfoConsistency(/*allow excluded*/ true); // Excluded file(s) deleted, unable to restore - for (auto be_pair : - {std::make_pair(backup_engine_.get(), alt_backup_engine), - std::make_pair(alt_backup_engine, backup_engine_.get())}) { + backup_engine = backup_engine_.get(); + for (auto be_pair : {std::make_pair(backup_engine, alt_backup_engine), + std::make_pair(alt_backup_engine, backup_engine)}) { RestoreOptions ro; ro.alternate_dirs.push_front(be_pair.second); ASSERT_TRUE(be_pair.first->RestoreDBFromLatestBackup(dbname_, dbname_, ro) @@ -4475,9 +4475,9 @@ TEST_F(BackupEngineTest, ExcludeFiles) { AssertBackupInfoConsistency(/*allow excluded*/ true); // Excluded file(s) deleted, unable to restore - for (auto be_pair : - {std::make_pair(backup_engine_.get(), alt_backup_engine), - std::make_pair(alt_backup_engine, backup_engine_.get())}) { + backup_engine = backup_engine_.get(); + for (auto be_pair : {std::make_pair(backup_engine, alt_backup_engine), + std::make_pair(alt_backup_engine, backup_engine)}) { RestoreOptions ro; ro.alternate_dirs.push_front(be_pair.second); ASSERT_TRUE(be_pair.first->RestoreDBFromLatestBackup(dbname_, dbname_, ro)