diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-10-07 11:18:19 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-10-07 11:06:37 +0200 |
commit | fa165e954579436fe4b636e4222d8ce0c1269786 (patch) | |
tree | 433ce1d0439fcce2ae6ea393192b281caf0bf4a9 | |
parent | c0b6c96eee7c9e24b78935516225259e61cdabf7 (diff) | |
download | bitcoin-fa165e954579436fe4b636e4222d8ce0c1269786.tar.xz |
Replace stoul with ToIntegral in dbwrapper
-rw-r--r-- | src/dbwrapper.cpp | 8 | ||||
-rwxr-xr-x | test/lint/lint-locale-dependence.sh | 1 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp index 3a1086bf4c..bcaf746167 100644 --- a/src/dbwrapper.cpp +++ b/src/dbwrapper.cpp @@ -197,13 +197,15 @@ bool CDBWrapper::WriteBatch(CDBBatch& batch, bool fSync) return true; } -size_t CDBWrapper::DynamicMemoryUsage() const { +size_t CDBWrapper::DynamicMemoryUsage() const +{ std::string memory; - if (!pdb->GetProperty("leveldb.approximate-memory-usage", &memory)) { + std::optional<size_t> parsed; + if (!pdb->GetProperty("leveldb.approximate-memory-usage", &memory) || !(parsed = ToIntegral<size_t>(memory))) { LogPrint(BCLog::LEVELDB, "Failed to get approximate-memory-usage property\n"); return 0; } - return stoul(memory); + return parsed.value(); } // Prefixed with null character to avoid collisions with other keys diff --git a/test/lint/lint-locale-dependence.sh b/test/lint/lint-locale-dependence.sh index 3015c4f9b9..712c4f0d5b 100755 --- a/test/lint/lint-locale-dependence.sh +++ b/test/lint/lint-locale-dependence.sh @@ -42,7 +42,6 @@ export LC_ALL=C # TODO: Reduce KNOWN_VIOLATIONS by replacing uses of locale dependent snprintf with strprintf. KNOWN_VIOLATIONS=( "src/bitcoin-tx.cpp.*stoul" - "src/dbwrapper.cpp.*stoul" "src/dbwrapper.cpp:.*vsnprintf" "src/rest.cpp:.*strtol" "src/test/dbwrapper_tests.cpp:.*snprintf" |