Skip to content

Commit 4458ae8

Browse files
committed
Merge bitcoin#28741: refactor: Fix bugprone-string-constructor 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
2 parents 7d6c646 + fa56067 commit 4458ae8

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Checks: '
22
-*,
33
bitcoin-*,
44
bugprone-argument-comment,
5+
bugprone-string-constructor,
56
bugprone-use-after-move,
67
bugprone-lambda-function-name,
78
misc-unused-using-decls,

src/wallet/db.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ bool IsSQLiteFile(const fs::path& path)
129129

130130
file.close();
131131

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

0 commit comments

Comments
 (0)