refactor: clean-up some clang-tidy warnings

This commit is contained in:
CJ van den Berg 2024-08-27 19:25:19 +02:00
parent ee6b1276df
commit 858dcf09e0
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
6 changed files with 21 additions and 21 deletions

View file

@ -1,2 +1,2 @@
--- ---
Checks: '*,-llvmlibc-*,-readability-*,-google-readability-*,-fuchsia-*,-hicpp-exception-baseclass,-altera-*,-hicpp-braces-around-statements,-google-runtime-int,-misc-non-private-member-variables-in-classes,-cert-err58-cpp,-hicpp-no-array-decay,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-type-union-access,-hicpp-signed-bitwise,-cppcoreguidelines-avoid-magic-numbers,-misc-no-recursion,-bugprone-easily-swappable-parameters,-cppcoreguidelines-owning-memory,-cppcoreguidelines-macro-usage,-google-objc-*' Checks: '*,-llvmlibc-*,-readability-*,-google-readability-*,-fuchsia-*,-hicpp-exception-baseclass,-altera-*,-hicpp-braces-around-statements,-google-runtime-int,-misc-non-private-member-variables-in-classes,-cert-err58-cpp,-hicpp-no-array-decay,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-type-union-access,-hicpp-signed-bitwise,-cppcoreguidelines-avoid-magic-numbers,-misc-no-recursion,-bugprone-easily-swappable-parameters,-cppcoreguidelines-owning-memory,-cppcoreguidelines-macro-usage,-cppcoreguidelines-avoid-const-or-ref-data-members,-google-objc-*'

View file

@ -40,7 +40,7 @@ auto thespian_self() -> thespian_handle {
auto thespian_spawn_link(thespian_behaviour b, thespian_behaviour_state s, auto thespian_spawn_link(thespian_behaviour b, thespian_behaviour_state s,
const char *name, thespian_env env, const char *name, thespian_env env,
thespian_handle *handle) -> int { thespian_handle *handle) -> int {
thespian::env_t empty_env_{}; const thespian::env_t empty_env_{};
thespian::env_t env_ = thespian::env_t env_ =
env ? *reinterpret_cast<thespian::env_t *>(env) : empty_env_; // NOLINT env ? *reinterpret_cast<thespian::env_t *>(env) : empty_env_; // NOLINT

View file

@ -33,12 +33,12 @@ hub::pipe::~pipe() = default;
struct subscribe_queue : public hub::pipe { struct subscribe_queue : public hub::pipe {
[[nodiscard]] auto push(const handle &from, filter f) { [[nodiscard]] auto push(const handle &from, filter f) {
lock_guard<mutex> lock(m_); const lock_guard<mutex> lock(m_);
q_.push_back(move(f)); q_.push_back(move(f));
return from.send("subscribe_filtered"); return from.send("subscribe_filtered");
} }
auto pop() -> filter { auto pop() -> filter {
lock_guard<mutex> lock(m_); const lock_guard<mutex> lock(m_);
filter f = move(q_.front()); filter f = move(q_.front());
q_.pop_front(); q_.pop_front();
return f; return f;

View file

@ -1292,7 +1292,7 @@ struct acceptor_impl {
void listen(string_view origpath, mode m) { void listen(string_view origpath, mode m) {
private_call(); private_call();
string path = unx_mode_path(m, origpath); const string path = unx_mode_path(m, origpath);
if (auto ec = acceptor_.bind(path)) { if (auto ec = acceptor_.bind(path)) {
auto _ = owner_.send("acceptor", tag_, "error", ec.value(), ec.message()); auto _ = owner_.send("acceptor", tag_, "error", ec.value(), ec.message());
return; return;
@ -1353,7 +1353,7 @@ struct connector_impl {
void connect(string_view origpath, mode m) { void connect(string_view origpath, mode m) {
private_call(); private_call();
open_ = true; open_ = true;
string path = unx_mode_path(m, origpath); const string path = unx_mode_path(m, origpath);
socket_.connect(path, [this](error_code ec) -> void { socket_.connect(path, [this](error_code ec) -> void {
if (!open_) if (!open_)
return; return;
@ -1574,7 +1574,7 @@ struct connector {
static auto connect(in6_addr ip, port_t port, milliseconds retry_time, static auto connect(in6_addr ip, port_t port, milliseconds retry_time,
size_t retry_count) -> expected<handle, error> { size_t retry_count) -> expected<handle, error> {
handle owner = self(); const handle owner = self();
return spawn_link( return spawn_link(
[=]() { [=]() {
trap(true); trap(true);
@ -1628,7 +1628,7 @@ struct acceptor {
} }
static auto start(in6_addr ip, port_t port) -> expected<handle, error> { static auto start(in6_addr ip, port_t port) -> expected<handle, error> {
handle owner = self(); const handle owner = self();
return spawn_link( return spawn_link(
[=]() { [=]() {
trap(true); trap(true);
@ -1709,7 +1709,7 @@ struct connector {
static auto connect(string_view path, mode m_, milliseconds retry_time, static auto connect(string_view path, mode m_, milliseconds retry_time,
size_t retry_count) -> expected<handle, error> { size_t retry_count) -> expected<handle, error> {
handle owner = self(); const handle owner = self();
return spawn_link( return spawn_link(
[path{string(path)}, m_, owner, retry_time, retry_count]() { [path{string(path)}, m_, owner, retry_time, retry_count]() {
trap(true); trap(true);
@ -1765,7 +1765,7 @@ struct acceptor {
} }
static auto start(string_view path, mode m_) -> expected<handle, error> { static auto start(string_view path, mode m_) -> expected<handle, error> {
handle owner = self(); const handle owner = self();
return spawn_link( return spawn_link(
[path{string(path)}, m_, owner]() { [path{string(path)}, m_, owner]() {
trap(true); trap(true);
@ -1804,7 +1804,7 @@ auto isenabled(context &ctx) -> bool { return isenabled(impl(ctx)); }
void disable(context_impl &ctx) { void disable(context_impl &ctx) {
auto prev = ctx.debug_enabled.fetch_sub(1, memory_order_relaxed); auto prev = ctx.debug_enabled.fetch_sub(1, memory_order_relaxed);
if (prev == 1) { if (prev == 1) {
lock_guard<mutex> lock(ctx.registry_mux); const lock_guard<mutex> lock(ctx.registry_mux);
ctx.registry.clear(); ctx.registry.clear();
} }
} }
@ -1820,7 +1820,7 @@ void register_instance(context_impl &ctx, const handle &h) {
return; return;
// if (trace) // if (trace)
// trace(array("register", name, ref_m(r))); // trace(array("register", name, ref_m(r)));
lock_guard<mutex> lock(ctx.registry_mux); const lock_guard<mutex> lock(ctx.registry_mux);
ctx.registry[name] = h; ctx.registry[name] = h;
} }
} }
@ -1828,14 +1828,14 @@ void register_instance(context_impl &ctx, const handle &h) {
void unregister_instance(context_impl &ctx, const string &name) { void unregister_instance(context_impl &ctx, const string &name) {
if (not isenabled(ctx)) if (not isenabled(ctx))
return; return;
lock_guard<mutex> lock(ctx.registry_mux); const lock_guard<mutex> lock(ctx.registry_mux);
// if (trace) // if (trace)
// trace(array("unregister", name, ref_m(handle_ref(registry[name])))); // trace(array("unregister", name, ref_m(handle_ref(registry[name]))));
ctx.registry.erase(name); ctx.registry.erase(name);
} }
auto get_name(context_impl &ctx, const string &name) -> handle { auto get_name(context_impl &ctx, const string &name) -> handle {
lock_guard<mutex> lock(ctx.registry_mux); const lock_guard<mutex> lock(ctx.registry_mux);
auto r = ctx.registry.find(name); auto r = ctx.registry.find(name);
return r != ctx.registry.end() ? r->second : handle{}; return r != ctx.registry.end() ? r->second : handle{};
} }
@ -1843,7 +1843,7 @@ auto get_name(context_impl &ctx, const string &name) -> handle {
auto get_names(context_impl &ctx) -> buffer { auto get_names(context_impl &ctx) -> buffer {
vector<string> names; vector<string> names;
{ {
lock_guard<mutex> lock(ctx.registry_mux); const lock_guard<mutex> lock(ctx.registry_mux);
for (const auto &a : ctx.registry) for (const auto &a : ctx.registry)
if (not a.second.expired()) if (not a.second.expired())
names.push_back(a.first); names.push_back(a.first);
@ -1877,7 +1877,7 @@ struct connection {
pos = str.find_first_of(delim); pos = str.find_first_of(delim);
if (pos == string::npos) if (pos == string::npos)
return make_pair(str, ""); return make_pair(str, "");
string word(str.data(), pos); const string word(str.data(), pos);
str.erase(0, pos + 1); str.erase(0, pos + 1);
return make_pair(word, str); return make_pair(word, str);
} }
@ -1886,7 +1886,7 @@ struct connection {
if (buf.empty()) { if (buf.empty()) {
vector<string> expired_names; vector<string> expired_names;
{ {
lock_guard<mutex> lock(ctx.registry_mux); const lock_guard<mutex> lock(ctx.registry_mux);
bool first{true}; bool first{true};
for (const auto &a : ctx.registry) { for (const auto &a : ctx.registry) {
if (not a.second.expired()) { if (not a.second.expired()) {
@ -1909,7 +1909,7 @@ struct connection {
} else { } else {
auto x = getword(buf); auto x = getword(buf);
buf = x.second; buf = x.second;
handle a = get_name(ctx, x.first); const handle a = get_name(ctx, x.first);
if (a.expired()) { if (a.expired()) {
s.write("error: "); s.write("error: ");
s.write(x.first); s.write(x.first);

View file

@ -86,7 +86,7 @@ struct controller {
auto endpoint_unx(context &ctx, bool &result, env_t env_) -> ::result { auto endpoint_unx(context &ctx, bool &result, env_t env_) -> ::result {
stringstream ss; stringstream ss;
ss << "/net/vdbonline/thespian/endpoint_t_" << getpid(); ss << "/net/vdbonline/thespian/endpoint_t_" << getpid();
string path = ss.str(); const string path = ss.str();
return to_result(ctx.spawn_link( return to_result(ctx.spawn_link(
[path]() { [path]() {
link(env().proc("log")); link(env().proc("log"));

View file

@ -50,7 +50,7 @@ struct logger {
auto receive(const buffer &m) { auto receive(const buffer &m) {
if (verbose) { if (verbose) {
std::lock_guard<mutex> lock(trace_m); const std::lock_guard<mutex> lock(trace_m);
cout << name << ": "; cout << name << ": ";
auto dump = [&](auto val) { cout << val << " "; }; auto dump = [&](auto val) { cout << val << " "; };
for (const auto val : m) for (const auto val : m)
@ -115,7 +115,7 @@ extern "C" auto runtestcase(const char *name) -> int {
env_t env{}; env_t env{};
env_t log_env{}; env_t log_env{};
auto trace = [&](const buffer &buf) { auto trace = [&](const buffer &buf) {
lock_guard<mutex> lock(trace_m); const lock_guard<mutex> lock(trace_m);
cout << buf.to_json() << '\n'; cout << buf.to_json() << '\n';
}; };
log_env.on_trace(trace); log_env.on_trace(trace);