Skip to content

Commit 04cca33

Browse files
committed
Style cleanup.
1 parent 4c01e4e commit 04cca33

File tree

4 files changed

+20
-23
lines changed

4 files changed

+20
-23
lines changed

src/flatfile.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,24 @@ fs::path FlatFileSeq::FileName(const FlatFilePos& pos) const
3030
return m_dir / strprintf("%s%05u.dat", m_prefix, pos.nFile);
3131
}
3232

33-
FILE* FlatFileSeq::Open(const FlatFilePos& pos, bool fReadOnly)
33+
FILE* FlatFileSeq::Open(const FlatFilePos& pos, bool read_only)
3434
{
35-
if (pos.IsNull())
35+
if (pos.IsNull()) {
3636
return nullptr;
37+
}
3738
fs::path path = FileName(pos);
3839
fs::create_directories(path.parent_path());
39-
FILE* file = fsbridge::fopen(path, fReadOnly ? "rb": "rb+");
40-
if (!file && !fReadOnly)
40+
FILE* file = fsbridge::fopen(path, read_only ? "rb": "rb+");
41+
if (!file && !read_only)
4142
file = fsbridge::fopen(path, "wb+");
4243
if (!file) {
4344
LogPrintf("Unable to open file %s\n", path.string());
4445
return nullptr;
4546
}
46-
if (pos.nPos) {
47-
if (fseek(file, pos.nPos, SEEK_SET)) {
48-
LogPrintf("Unable to seek to position %u of %s\n", pos.nPos, path.string());
49-
fclose(file);
50-
return nullptr;
51-
}
47+
if (pos.nPos && fseek(file, pos.nPos, SEEK_SET)) {
48+
LogPrintf("Unable to seek to position %u of %s\n", pos.nPos, path.string());
49+
fclose(file);
50+
return nullptr;
5251
}
5352
return file;
5453
}

src/flatfile.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ struct FlatFilePos
2424
READWRITE(VARINT(nPos));
2525
}
2626

27-
FlatFilePos() {
28-
SetNull();
29-
}
27+
FlatFilePos() : nFile(-1), nPos(0) {}
3028

31-
FlatFilePos(int nFileIn, unsigned int nPosIn) {
32-
nFile = nFileIn;
33-
nPos = nPosIn;
34-
}
29+
FlatFilePos(int nFileIn, unsigned int nPosIn) :
30+
nFile(nFileIn),
31+
nPos(nPosIn)
32+
{}
3533

3634
friend bool operator==(const FlatFilePos &a, const FlatFilePos &b) {
3735
return (a.nFile == b.nFile && a.nPos == b.nPos);
@@ -72,7 +70,7 @@ class FlatFileSeq
7270
fs::path FileName(const FlatFilePos& pos) const;
7371

7472
/** Open a handle to the file at the given position. */
75-
FILE* Open(const FlatFilePos& pos, bool fReadOnly = false);
73+
FILE* Open(const FlatFilePos& pos, bool read_only = false);
7674

7775
/**
7876
* Allocate additional space in a file after the given starting position. The amount allocated

src/util/system.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ bool DirIsWritable(const fs::path& directory)
135135
return true;
136136
}
137137

138-
bool CheckDiskSpace(const fs::path& dir, uint64_t nAdditionalBytes)
138+
bool CheckDiskSpace(const fs::path& dir, uint64_t additional_bytes)
139139
{
140-
constexpr uint64_t nMinDiskSpace = 52428800; // 50 MiB
140+
constexpr uint64_t min_disk_space = 52428800; // 50 MiB
141141

142-
uint64_t nFreeBytesAvailable = fs::space(dir).available;
143-
return nFreeBytesAvailable >= nMinDiskSpace + nAdditionalBytes;
142+
uint64_t free_bytes_available = fs::space(dir).available;
143+
return free_bytes_available >= min_disk_space + additional_bytes;
144144
}
145145

146146
/**

src/util/system.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ bool RenameOver(fs::path src, fs::path dest);
7272
bool LockDirectory(const fs::path& directory, const std::string lockfile_name, bool probe_only=false);
7373
void UnlockDirectory(const fs::path& directory, const std::string& lockfile_name);
7474
bool DirIsWritable(const fs::path& directory);
75-
bool CheckDiskSpace(const fs::path& dir, uint64_t nAdditionalBytes = 0);
75+
bool CheckDiskSpace(const fs::path& dir, uint64_t additional_bytes = 0);
7676

7777
/** Release all directory locks. This is used for unit testing only, at runtime
7878
* the global destructor will take care of the locks.

0 commit comments

Comments
 (0)