diff options
author | fanquake <fanquake@gmail.com> | 2023-12-11 15:31:51 +0000 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2023-12-11 15:44:16 +0000 |
commit | d5e5810bd36f6e899d64a57e9264729b27a9c3f8 (patch) | |
tree | 3a1c54d5bd99a6107a0196fff986f890af9c02e9 | |
parent | dabd7046420501a028903a68e9f185d1e347ba3e (diff) | |
parent | fa8adbe7c17b16cf7ecd16eb9f3f1792e9da2876 (diff) | |
download | bitcoin-d5e5810bd36f6e899d64a57e9264729b27a9c3f8.tar.xz |
Merge bitcoin/bitcoin#28999: build: Enable -Wunreachable-code
fa8adbe7c17b16cf7ecd16eb9f3f1792e9da2876 build: Enable -Wunreachable-code (MarcoFalke)
Pull request description:
It seems a bit confusing to write code after a `return`. This can even lead to bugs, or incorrect code, such as https://github.com/bitcoin/bitcoin/pull/28830/files#r1415372320 . (Edit: The linked instance is not found by clang's `-Wunreachable-code`).
Fix all issues by enabling `-Wunreachable-code`.
This flag also enables `-Wunreachable-code-loop-increment`, according to https://clang.llvm.org/docs/DiagnosticsReference.html#wunreachable-code, so remove that.
ACKs for top commit:
ajtowns:
> ACK [fa8adbe](https://github.com/bitcoin/bitcoin/commit/fa8adbe7c17b16cf7ecd16eb9f3f1792e9da2876)
stickies-v:
ACK fa8adbe7c17b16cf7ecd16eb9f3f1792e9da2876
jonatack:
ACK fa8adbe7c17b16cf7ecd16eb9f3f1792e9da2876 tested with arm64 clang 17.0.6
Tree-SHA512: 12a2f74b69ae002e62ae08038f7458837090a12051a4c154d05ae4bb26fb19fc1fa76c63aedf2b3fbb36f048c593ca3b8c0efe03fe93cf07a0fd114fc84ce1e7
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/wallet/walletdb.cpp | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac index 9b39159a32..58235d67c6 100644 --- a/configure.ac +++ b/configure.ac @@ -436,8 +436,8 @@ if test "$CXXFLAGS_overridden" = "no"; then AX_CHECK_COMPILE_FLAG([-Wlogical-op], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wlogical-op"], [], [$CXXFLAG_WERROR]) AX_CHECK_COMPILE_FLAG([-Woverloaded-virtual], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Woverloaded-virtual"], [], [$CXXFLAG_WERROR]) AX_CHECK_COMPILE_FLAG([-Wsuggest-override], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsuggest-override"], [], [$CXXFLAG_WERROR]) - AX_CHECK_COMPILE_FLAG([-Wunreachable-code-loop-increment], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunreachable-code-loop-increment"], [], [$CXXFLAG_WERROR]) AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wimplicit-fallthrough"], [], [$CXXFLAG_WERROR]) + AX_CHECK_COMPILE_FLAG([-Wunreachable-code], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunreachable-code"], [], [$CXXFLAG_WERROR]) if test "$suppress_external_warnings" != "no" ; then AX_CHECK_COMPILE_FLAG([-Wdocumentation], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wdocumentation"], [], [$CXXFLAG_WERROR]) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 96999de97b..ba453b47e7 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -1499,17 +1499,19 @@ std::unique_ptr<WalletDatabase> MakeDatabase(const fs::path& path, const Databas if (format == DatabaseFormat::SQLITE) { #ifdef USE_SQLITE return MakeSQLiteDatabase(path, options, status, error); -#endif +#else error = Untranslated(strprintf("Failed to open database path '%s'. Build does not support SQLite database format.", fs::PathToString(path))); status = DatabaseStatus::FAILED_BAD_FORMAT; return nullptr; +#endif } #ifdef USE_BDB return MakeBerkeleyDatabase(path, options, status, error); -#endif +#else error = Untranslated(strprintf("Failed to open database path '%s'. Build does not support Berkeley DB database format.", fs::PathToString(path))); status = DatabaseStatus::FAILED_BAD_FORMAT; return nullptr; +#endif } } // namespace wallet |