0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-03-05 14:06:27 -05:00

Merge bitcoin/bitcoin#28741: refactor: Fix bugprone-string-constructor warning

fa56067a8f 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 fa56067a8f

Tree-SHA512: da519184d792a885a8151ffc44c8da5781f5aaae12ef768a187cc6d9e542ca8952aebc2ec6c1a05f673f29a86ef44902ee96e7b491af7b4705ad38e14624882e
This commit is contained in:
fanquake 2023-10-30 16:33:57 +00:00
commit 4458ae811a
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1
2 changed files with 3 additions and 2 deletions

View file

@ -2,6 +2,7 @@ Checks: '
-*, -*,
bitcoin-*, bitcoin-*,
bugprone-argument-comment, bugprone-argument-comment,
bugprone-string-constructor,
bugprone-use-after-move, bugprone-use-after-move,
bugprone-lambda-function-name, bugprone-lambda-function-name,
misc-unused-using-decls, misc-unused-using-decls,

View file

@ -129,9 +129,9 @@ bool IsSQLiteFile(const fs::path& path)
file.close(); 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); 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; return false;
} }