Skip to content

Commit 9116563

Browse files
achow101PastaPastaPasta
authored andcommitted
Merge bitcoin#29315: refactor: Compile unreachable walletdb code
fa3373d refactor: Compile unreachable code (MarcoFalke) Pull request description: When unreachable code isn't compiled, compile failures are not detected. Fix this by leaving it unreachable, but compiling it. Fixes bitcoin#28999 (comment) ACKs for top commit: achow101: ACK fa3373d ryanofsky: Code review ACK fa3373d. This looks good, and should prevent code in the else blocks from accidentally breaking. Tree-SHA512: 3a3764915dfc935bf5d7a48f1ca151dcbac340c1cbdce8236b24ae9b4f04d6ee9771ed058ca60bcbca6e19d13671de3517f828a8f7ab6444c7cc4e3538d1ba4e
1 parent ddbe865 commit 9116563

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/wallet/walletdb.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,21 +1160,27 @@ std::unique_ptr<WalletDatabase> MakeDatabase(const fs::path& path, const Databas
11601160

11611161
if (format == DatabaseFormat::SQLITE) {
11621162
#ifdef USE_SQLITE
1163-
return MakeSQLiteDatabase(path, options, status, error);
1164-
#else
1165-
error = Untranslated(strprintf("Failed to open database path '%s'. Build does not support SQLite database format.", fs::PathToString(path)));
1166-
status = DatabaseStatus::FAILED_BAD_FORMAT;
1167-
return nullptr;
1163+
if constexpr (true) {
1164+
return MakeSQLiteDatabase(path, options, status, error);
1165+
} else
11681166
#endif
1167+
{
1168+
error = Untranslated(strprintf("Failed to open database path '%s'. Build does not support SQLite database format.", fs::PathToString(path)));
1169+
status = DatabaseStatus::FAILED_BAD_FORMAT;
1170+
return nullptr;
1171+
}
11691172
}
11701173

11711174
#ifdef USE_BDB
1172-
return MakeBerkeleyDatabase(path, options, status, error);
1173-
#else
1174-
error = Untranslated(strprintf("Failed to open database path '%s'. Build does not support Berkeley DB database format.", fs::PathToString(path)));
1175-
status = DatabaseStatus::FAILED_BAD_FORMAT;
1176-
return nullptr;
1175+
if constexpr (true) {
1176+
return MakeBerkeleyDatabase(path, options, status, error);
1177+
} else
11771178
#endif
1179+
{
1180+
error = Untranslated(strprintf("Failed to open database path '%s'. Build does not support Berkeley DB database format.", fs::PathToString(path)));
1181+
status = DatabaseStatus::FAILED_BAD_FORMAT;
1182+
return nullptr;
1183+
}
11781184
}
11791185

11801186
/** Return object for accessing dummy database with no read/write capabilities. */

0 commit comments

Comments
 (0)