Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Checks: "-*,
cppcoreguidelines-use-default-member-init,
cppcoreguidelines-virtual-class-destructor,
hicpp-ignored-remove-result,
misc-const-correctness,
misc-definitions-in-headers,
misc-header-include-cycle,
misc-misplaced-const,
Expand All @@ -95,6 +96,7 @@ Checks: "-*,
modernize-deprecated-headers,
modernize-make-shared,
modernize-make-unique,
llvm-namespace-comment,
performance-implicit-conversion-in-loop,
performance-move-constructor-init,
performance-trivially-destructible,
Expand Down Expand Up @@ -127,8 +129,6 @@ Checks: "-*,
# ---
# checks that have some issues that need to be resolved:
#
# llvm-namespace-comment,
# misc-const-correctness,
# misc-include-cleaner,
# misc-redundant-expression,
#
Expand Down
5 changes: 3 additions & 2 deletions src/libxrpl/basics/Archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extractTarLz4(boost::filesystem::path const& src, boost::filesystem::path const&
Throw<std::runtime_error>("Invalid source file");

using archive_ptr = std::unique_ptr<struct archive, void (*)(struct archive*)>;
archive_ptr ar{archive_read_new(), [](struct archive* a) { archive_read_free(a); }};
archive_ptr const ar{archive_read_new(), [](struct archive* a) { archive_read_free(a); }};
if (!ar)
Throw<std::runtime_error>("Failed to allocate archive");

Expand All @@ -36,7 +36,8 @@ extractTarLz4(boost::filesystem::path const& src, boost::filesystem::path const&
Throw<std::runtime_error>(archive_error_string(ar.get()));
}

archive_ptr aw{archive_write_disk_new(), [](struct archive* a) { archive_write_free(a); }};
archive_ptr const aw{
archive_write_disk_new(), [](struct archive* a) { archive_write_free(a); }};
if (!aw)
Throw<std::runtime_error>("Failed to allocate archive");

Expand Down
2 changes: 1 addition & 1 deletion src/libxrpl/basics/BasicConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ BasicConfig::section(std::string const& name)
Section const&
BasicConfig::section(std::string const& name) const
{
static Section none("");
static Section const none("");
auto const iter = map_.find(name);
if (iter == map_.end())
return none;
Expand Down
2 changes: 1 addition & 1 deletion src/libxrpl/basics/FileUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ getFileContents(
using namespace boost::filesystem;
using namespace boost::system::errc;

path fullPath{canonical(sourcePath, ec)};
path const fullPath{canonical(sourcePath, ec)};
if (ec)
return {};

Expand Down
14 changes: 7 additions & 7 deletions src/libxrpl/basics/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Logs::open(boost::filesystem::path const& pathToLogFile)
beast::Journal::Sink&
Logs::get(std::string const& name)
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
auto const result = sinks_.emplace(name, makeSink(name, thresh_));
return *result.first->second;
}
Expand All @@ -145,7 +145,7 @@ Logs::threshold() const
void
Logs::threshold(beast::severities::Severity thresh)
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
thresh_ = thresh;
for (auto& sink : sinks_)
sink.second->threshold(thresh);
Expand All @@ -155,7 +155,7 @@ std::vector<std::pair<std::string, std::string>>
Logs::partition_severities() const
{
std::vector<std::pair<std::string, std::string>> list;
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
list.reserve(sinks_.size());
for (auto const& [name, sink] : sinks_)
list.emplace_back(name, toString(fromSeverity(sink->threshold())));
Expand All @@ -171,7 +171,7 @@ Logs::write(
{
std::string s;
format(s, text, level, partition);
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
file_.writeln(s);
if (!silent_)
std::cerr << s << '\n';
Expand All @@ -183,7 +183,7 @@ Logs::write(
std::string
Logs::rotate()
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
bool const wasOpened = file_.closeAndReopen();
if (wasOpened)
return "The log file was closed and reopened.";
Expand Down Expand Up @@ -411,7 +411,7 @@ class DebugSink
std::unique_ptr<beast::Journal::Sink>
set(std::unique_ptr<beast::Journal::Sink> sink)
{
std::lock_guard _(m_);
std::lock_guard const _(m_);

using std::swap;
swap(holder_, sink);
Expand All @@ -431,7 +431,7 @@ class DebugSink
beast::Journal::Sink&
get()
{
std::lock_guard _(m_);
std::lock_guard const _(m_);
return sink_.get();
}
};
Expand Down
30 changes: 15 additions & 15 deletions src/libxrpl/basics/Number.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ Number::Guard::push(T d) noexcept
inline unsigned
Number::Guard::pop() noexcept
{
unsigned d = (digits_ & 0xF000'0000'0000'0000) >> 60;
unsigned const d = (digits_ & 0xF000'0000'0000'0000) >> 60;
digits_ <<= 4;
return d;
}
Expand Down Expand Up @@ -325,7 +325,7 @@ Number::externalToInternal(rep mantissa)
// int128_t, negate that, and cast it back down to the internalrep
// In practice, this is only going to cover the case of
// std::numeric_limits<rep>::min().
int128_t temp = mantissa;
int128_t const temp = mantissa;
return static_cast<internalrep>(-temp);
}

Expand Down Expand Up @@ -530,7 +530,7 @@ Number::operator+=(Number const& y)
uint128_t xm = mantissa_;
auto xe = exponent_;

bool yn = y.negative_;
bool const yn = y.negative_;
uint128_t ym = y.mantissa_;
auto ye = y.exponent_;
Guard g;
Expand Down Expand Up @@ -644,14 +644,14 @@ Number::operator*=(Number const& y)
// *m = mantissa
// *e = exponent

bool xn = negative_;
int xs = xn ? -1 : 1;
bool const xn = negative_;
int const xs = xn ? -1 : 1;
internalrep xm = mantissa_;
auto xe = exponent_;

bool yn = y.negative_;
int ys = yn ? -1 : 1;
internalrep ym = y.mantissa_;
bool const yn = y.negative_;
int const ys = yn ? -1 : 1;
internalrep const ym = y.mantissa_;
auto ye = y.exponent_;

auto zm = uint128_t(xm) * uint128_t(ym);
Expand Down Expand Up @@ -706,13 +706,13 @@ Number::operator/=(Number const& y)
// *m = mantissa
// *e = exponent

bool np = negative_;
int ns = (np ? -1 : 1);
bool const np = negative_;
int const ns = (np ? -1 : 1);
auto nm = mantissa_;
auto ne = exponent_;

bool dp = y.negative_;
int ds = (dp ? -1 : 1);
bool const dp = y.negative_;
int const ds = (dp ? -1 : 1);
auto dm = y.mantissa_;
auto de = y.exponent_;

Expand All @@ -728,7 +728,7 @@ Number::operator/=(Number const& y)
// f can be up to 10^(38-19) = 10^19 safely
static_assert(smallRange.log == 15);
static_assert(largeRange.log == 18);
bool small = Number::getMantissaScale() == MantissaRange::small;
bool const small = Number::getMantissaScale() == MantissaRange::small;
uint128_t const f = small ? 100'000'000'000'000'000 : 10'000'000'000'000'000'000ULL;
XRPL_ASSERT_PARTS(f >= minMantissa * 10, "Number::operator/=", "factor expected size");

Expand Down Expand Up @@ -980,8 +980,8 @@ root(Number f, unsigned d)
auto const di = static_cast<int>(d);
auto ex = [e = e, di = di]() // Euclidean remainder of e/d
{
int k = (e >= 0 ? e : e - (di - 1)) / di;
int k2 = e - (k * di);
int const k = (e >= 0 ? e : e - (di - 1)) / di;
int const k2 = e - (k * di);
if (k2 == 0)
return 0;
return di - k2;
Expand Down
6 changes: 3 additions & 3 deletions src/libxrpl/basics/ResolverAsio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class ResolverAsioImpl : public ResolverAsio, public AsyncObject<ResolverAsioImp
void
asyncHandlersComplete()
{
std::unique_lock<std::mutex> lk{m_mut};
std::unique_lock<std::mutex> const lk{m_mut};
m_asyncHandlersCompleted = true;
m_cv.notify_all();
}
Expand All @@ -172,7 +172,7 @@ class ResolverAsioImpl : public ResolverAsio, public AsyncObject<ResolverAsioImp
if (m_stopped.exchange(false))
{
{
std::lock_guard lk{m_mut};
std::lock_guard const lk{m_mut};
m_asyncHandlersCompleted = false;
}
addReference();
Expand Down Expand Up @@ -327,7 +327,7 @@ class ResolverAsioImpl : public ResolverAsio, public AsyncObject<ResolverAsioImp
return;

std::string const name(m_work.front().names.back());
HandlerType handler(m_work.front().handler);
HandlerType const handler(m_work.front().handler);

m_work.front().names.pop_back();

Expand Down
2 changes: 1 addition & 1 deletion src/libxrpl/basics/StringUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ bool
parseUrl(parsedURL& pUrl, std::string const& strUrl)
{
// scheme://username:password@hostname:port/rest
static boost::regex reUrl(
static boost::regex const reUrl(
"(?i)\\`\\s*"
// required scheme
"([[:alpha:]][-+.[:alpha:][:digit:]]*?):"
Expand Down
4 changes: 2 additions & 2 deletions src/libxrpl/basics/base64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ std::size_t constexpr decoded_size(std::size_t n)
std::size_t
encode(void* dest, void const* src, std::size_t len)
{
char* out = static_cast<char*>(dest);
char* out = static_cast<char*>(dest); // NOLINT(misc-const-correctness)
char const* in = static_cast<char const*>(src);
auto const tab = base64::get_alphabet();

Expand Down Expand Up @@ -154,7 +154,7 @@ encode(void* dest, void const* src, std::size_t len)
std::pair<std::size_t, std::size_t>
decode(void* dest, char const* src, std::size_t len)
{
char* out = static_cast<char*>(dest);
char* out = static_cast<char*>(dest); // NOLINT(misc-const-correctness)
auto in = reinterpret_cast<unsigned char const*>(src);
unsigned char c3[3]{}, c4[4]{};
int i = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/libxrpl/basics/make_SSLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ initAnonymous(boost::asio::ssl::context& context)

auto const ts = std::time(nullptr) - (25 * 60 * 60);

int ret = std::strftime(buf, sizeof(buf) - 1, "%y%m%d000000Z", std::gmtime(&ts));
int const ret = std::strftime(buf, sizeof(buf) - 1, "%y%m%d000000Z", std::gmtime(&ts));

buf[ret] = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/libxrpl/beast/clock/basic_seconds_clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ seconds_clock_thread::~seconds_clock_thread()
XRPL_ASSERT(
thread_.joinable(), "beast::seconds_clock_thread::~seconds_clock_thread : thread joinable");
{
std::lock_guard lock(mut_);
std::lock_guard const lock(mut_);
stop_ = true;
} // publish stop_ asap so if waiting thread times-out, it will see it
cv_.notify_one();
Expand Down
4 changes: 2 additions & 2 deletions src/libxrpl/beast/core/SemanticVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ chopUInt(int& value, int limit, std::string& input)
return std::isdigit(c, std::locale::classic());
});

std::string item(input.begin(), left_iter);
std::string const item(input.begin(), left_iter);

// Must not be empty
if (item.empty())
Expand Down Expand Up @@ -320,7 +320,7 @@ compare(SemanticVersion const& lhs, SemanticVersion const& rhs)
{
XRPL_ASSERT(!isNumeric(right), "beast::compare : both inputs non-numeric");

int result = left.compare(right);
int const result = left.compare(right);

if (result != 0)
return result;
Expand Down
2 changes: 1 addition & 1 deletion src/libxrpl/beast/insight/Collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ namespace beast {
namespace insight {

Collector::~Collector() = default;
}
} // namespace insight
} // namespace beast
2 changes: 1 addition & 1 deletion src/libxrpl/beast/insight/Groups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class GroupsImp : public Groups
Group::ptr const&
get(std::string const& name) override
{
std::pair<Items::iterator, bool> result(m_items.emplace(name, Group::ptr()));
std::pair<Items::iterator, bool> const result(m_items.emplace(name, Group::ptr()));
Group::ptr& group(result.first->second);
if (result.second)
group = std::make_shared<GroupImp>(name, m_collector);
Expand Down
2 changes: 1 addition & 1 deletion src/libxrpl/beast/insight/Hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace beast {
namespace insight {

HookImpl::~HookImpl() = default;
}
} // namespace insight
} // namespace beast
6 changes: 3 additions & 3 deletions src/libxrpl/beast/insight/StatsDCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,14 @@ class StatsDCollectorImp : public StatsDCollector,
void
add(StatsDMetricBase& metric)
{
std::lock_guard _(metricsLock_);
std::lock_guard const _(metricsLock_);
metrics_.push_back(metric);
}

void
remove(StatsDMetricBase& metric)
{
std::lock_guard _(metricsLock_);
std::lock_guard const _(metricsLock_);
metrics_.erase(metrics_.iterator_to(metric));
}

Expand Down Expand Up @@ -444,7 +444,7 @@ class StatsDCollectorImp : public StatsDCollector,
return;
}

std::lock_guard _(metricsLock_);
std::lock_guard const _(metricsLock_);

for (auto& m : metrics_)
m.do_process();
Expand Down
Loading
Loading