GetUniquePath
is only used in tests and in DirIsWritable
. The check by DirIsWritable
is redundant with the check done in LockDirectory
.
Fix the redundancy by removing everything, except LockDirectory
.
GetUniquePath
is only used in tests and in DirIsWritable
. The check by DirIsWritable
is redundant with the check done in LockDirectory
.
Fix the redundancy by removing everything, except LockDirectory
.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
For detailed information about the code coverage, see the test coverage report.
See the guideline for information on the review process.
Type | Reviewers |
---|---|
ACK | TheCharlatan, hebasto |
Concept ACK | theuni |
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
0make[2]: Entering directory '/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-arm-linux-gnueabihf/src'
1/usr/bin/ccache arm-linux-gnueabihf-g++ -std=c++17 -DHAVE_CONFIG_H -I. -I../src/config -fmacro-prefix-map=/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-arm-linux-gnueabihf=. -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -DHAVE_BUILD_INFO -D_FILE_OFFSET_BITS=64 -DPROVIDE_FUZZ_MAIN_FUNCTION -I. -I./minisketch/include -I./secp256k1/include -I./univalue/include -I./leveldb/include -isystem /tmp/cirrus-ci-build/depends/arm-linux-gnueabihf/include -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_NO_CXX98_FUNCTION_BASE -isystem /tmp/cirrus-ci-build/depends/arm-linux-gnueabihf/include -pthread -I/tmp/cirrus-ci-build/depends/arm-linux-gnueabihf/include -I/tmp/cirrus-ci-build/depends/arm-linux-gnueabihf/include/ -fdebug-prefix-map=/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-arm-linux-gnueabihf=. -fstack-reuse=none -Wstack-protector -fstack-protector-all -fstack-clash-protection -Werror -fno-extended-identifiers -fvisibility=hidden -fPIE -pipe -std=c++17 -O2 -Wno-psabi -c -o libbitcoin_node_a-init.o `test -f 'init.cpp' || echo './'`init.cpp
2init.cpp: In function ‘bool LockDataDirectory(bool)’:
3init.cpp:1021:1: error: control reaches end of non-void function [-Werror=return-type]
4 1021 | }
5 | ^
6cc1plus: all warnings being treated as errors
7make[2]: *** [Makefile:10093: libbitcoin_node_a-init.o] Error 1
1011@@ -1012,10 +1012,9 @@ static bool LockDataDirectory(bool probeOnly)
1012 {
1013 // Make sure only a single Bitcoin process is using the data directory.
1014 const fs::path& datadir = gArgs.GetDataDirNet();
1015- if (!DirIsWritable(datadir)) {
1016- return InitError(strprintf(_("Cannot write to data directory '%s'; check permissions."), fs::PathToString(datadir)));
1017- }
1018 switch (util::LockDirectory(datadir, ".lock", probeOnly)) {
1019+ case util::LockResult::ErrorWrite:
1020+ return InitError(strprintf(_("Cannot write to data directory '%s'; check permissions."), fs::PathToString(datadir)));
148@@ -149,7 +149,7 @@ bool BerkeleyEnvironment::Open(bilingual_str& err)
149
150 fs::path pathIn = fs::PathFromString(strPath);
151 TryCreateDirectories(pathIn);
152- if (!LockDirectory(pathIn, ".walletlock")) {
153+ if (util::LockDirectory(pathIn, ".walletlock") != util::LockResult::Success) {
1121@@ -1122,6 +1122,7 @@ static constexpr char ExitCommand = 'X';
1122 ch = [&] {
1123 switch (util::LockDirectory(dirname, lockname)) {
1124 case util::LockResult::Success: return 1;
1125+ case util::LockResult::ErrorWrite: return 2;
This piece of code translates the return value of the LockDirectory
function to a value of type char
, so that it can be written as one byte in the next line. Previously, it would assign the boolean return value to char
, so I picked 1
for true
/Success
and 0
for false
/ErrorLock
.
Now that the LockResult
enum can hold more than a binary result, I am mapping the new return value ErrorWrite
to a char
value of 2
.
However, that value is never read and the code is never hit, so it can be anything.
Happy to change to anything else, if you have suggestions.
enum
erate all possible “return values” of TestOtherProcess
.
This makes it easier to add more Error cases in the future. Also, add
missing util namespace.
This allows the caller to remove a call to DirIsWritable(), which did a
similar check. Users should not notice any different behavior.