Skip to content

Commit

Permalink
Merge bitcoin/bitcoin#28741: refactor: Fix bugprone-string-constructo…
Browse files Browse the repository at this point in the history
…r warning

fa56067 refactor: Fix bugprone-string-constructor warning (MarcoFalke)

Pull request description:

  String literals in C++ have a trailing null character, so the current code is fine to rely on that implicitly. However,
  * the sqlite documentation explicitly mentions the null character
  * code readers may wonder if the code is intentional
  * clang-tidy warns about the code via `bugprone-string-constructor`

  Address the points by putting the null character into the code and enable the clang-tidy `bugprone-string-constructor` check.

ACKs for top commit:
  stickies-v:
    ACK fa56067

Tree-SHA512: da519184d792a885a8151ffc44c8da5781f5aaae12ef768a187cc6d9e542ca8952aebc2ec6c1a05f673f29a86ef44902ee96e7b491af7b4705ad38e14624882e
  • Loading branch information
fanquake committed Oct 30, 2023
2 parents 7d6c646 + fa56067 commit 4458ae8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Checks: '
-*,
bitcoin-*,
bugprone-argument-comment,
bugprone-string-constructor,
bugprone-use-after-move,
bugprone-lambda-function-name,
misc-unused-using-decls,
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ bool IsSQLiteFile(const fs::path& path)

file.close();

// Check the magic, see https://sqlite.org/fileformat2.html
// Check the magic, see https://sqlite.org/fileformat.html
std::string magic_str(magic, 16);
if (magic_str != std::string("SQLite format 3", 16)) {
if (magic_str != std::string{"SQLite format 3\000", 16}) {
return false;
}

Expand Down

0 comments on commit 4458ae8

Please sign in to comment.