refactor: run clang linter and formatter

This commit is contained in:
CJ van den Berg 2025-01-20 18:21:54 +01:00
parent 7668befc06
commit 2dd2b9e087
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
27 changed files with 189 additions and 157 deletions

View file

@ -3,7 +3,6 @@
#include <thespian/instance.hpp>
#include <thespian/trace.hpp>
#include <limits>
#include <string>
using cbor::A;

View file

@ -11,8 +11,8 @@
#include <memory>
#if defined(_WIN32)
#include <winsock2.h>
#include <in6addr.h>
#include <winsock2.h>
#include <ws2ipdef.h>
#include <ws2tcpip.h>
#endif
@ -60,9 +60,10 @@ struct debuggee {
static auto start() -> expected<handle, error> {
return spawn_link(
[=]() {
::receive([p{make_shared<debuggee>()}](auto from, auto m) {
return p->receive(move(from), move(m));
});
::receive(
[p{make_shared<debuggee>()}](const auto &from, const auto &m) {
return p->receive(from, m);
});
return ok();
},
"debuggee");
@ -188,9 +189,9 @@ auto debug(context &ctx, bool &result, env_t env_) -> ::result {
ret2 = debuggee.send("ping");
if (not ret2)
return ret2;
receive([p{make_shared<controller>(debug_tcp, debuggee)}](auto from,
auto m) {
return p->receive(move(from), move(m));
receive([p{make_shared<controller>(debug_tcp, debuggee)}](
const auto &from, const auto &m) {
return p->receive(from, m);
});
return ok();
},

View file

@ -12,8 +12,8 @@
#include <utility>
#if defined(_WIN32)
#include <winsock2.h>
#include <in6addr.h>
#include <winsock2.h>
#include <ws2ipdef.h>
#include <ws2tcpip.h>
#endif
@ -86,8 +86,9 @@ auto endpoint_tcp(context &ctx, bool &result, env_t env_) -> ::result {
if (not ret)
return ret;
receive([p{make_shared<controller>(ep_listen)}](auto from, auto m) {
return p->receive(move(from), move(m));
receive([p{make_shared<controller>(ep_listen)}](const auto &from,
const auto &m) {
return p->receive(from, m);
});
return ok();
},

View file

@ -91,8 +91,9 @@ auto endpoint_unx(context &ctx, bool &result, env_t env_) -> ::result {
[path]() {
link(env().proc("log"));
handle ep_listen = listen(path).value();
receive([p{make_shared<controller>(ep_listen)}](auto from, auto m) {
return p->receive(move(from), move(m));
receive([p{make_shared<controller>(ep_listen)}](const auto &from,
const auto &m) {
return p->receive(from, m);
});
return ok();
},

View file

@ -33,7 +33,7 @@ auto sub_plain(const hub &h, const handle &controller, string name) -> result {
ret = controller.send("ready", name);
if (not ret)
return ret;
receive([=](auto /*from*/, auto m) {
receive([=](const auto & /*from*/, const auto &m) {
string_view cmd;
check(m("parmA", "parmB", "parmC", extract(cmd)));
check(cmd == "continue" || cmd == "done");
@ -50,13 +50,13 @@ auto sub_plain(const hub &h, const handle &controller, string name) -> result {
auto sub_filtered(const hub &h, const handle &controller, string name)
-> result {
auto ret = h.subscribe(
[](auto m) { return m(type::any, type::any, type::any, "done"); });
[](const auto &m) { return m(type::any, type::any, type::any, "done"); });
if (not ret)
return ret;
ret = controller.send("ready", name);
if (not ret)
return ret;
receive([=](auto /*from*/, auto m) {
receive([=](const auto & /*from*/, const auto &m) {
check(m("parmA", "parmB", "parmC", "done"));
auto ret = controller.send("done", name);
if (not ret)
@ -66,7 +66,7 @@ auto sub_filtered(const hub &h, const handle &controller, string name)
return ok();
}
map<string, auto(*)(const hub &, const handle &, string)->result>
map<string, auto (*)(const hub &, const handle &, string)->result>
subscription_defs // NOLINT
= {
{"sub_plain", sub_plain},
@ -95,7 +95,7 @@ auto controller() -> result {
submap not_ready = subs;
submap done = subs;
receive([=](auto, auto m) mutable {
receive([=](const auto &, const auto &m) mutable {
string name;
if (m("ready", extract(name))) {
not_ready.erase(name);

View file

@ -10,8 +10,8 @@
#if !defined(_WIN32)
#include <netinet/in.h>
#else
#include <winsock2.h>
#include <in6addr.h>
#include <winsock2.h>
#include <ws2ipdef.h>
#include <ws2tcpip.h>
#endif
@ -80,7 +80,9 @@ struct client_connection {
[fd, connector]() {
::thespian::receive(
[p{make_shared<client_connection>(fd, connector)}](
auto /*from*/, auto m) { return p->receive(move(m)); });
const auto & /*from*/, const auto &m) {
return p->receive(m);
});
return ok();
},
"client_connection");
@ -111,9 +113,8 @@ struct client {
static auto init(handle server, port_t server_port) -> result {
::thespian::receive(
[p{make_shared<client>(server, server_port)}](auto /*from*/, auto m) {
return p->receive(move(m));
});
[p{make_shared<client>(server, server_port)}](
const auto & /*from*/, const auto &m) { return p->receive(m); });
return ok();
}
};
@ -155,9 +156,10 @@ struct server_connection {
[[nodiscard]] static auto init(int fd, const handle &server) {
return spawn_link(
[fd, server]() {
::thespian::receive(
[p{make_shared<server_connection>(fd, server)}](
auto /*from*/, auto m) { return p->receive(move(m)); });
::thespian::receive([p{make_shared<server_connection>(fd, server)}](
const auto & /*from*/, const auto &m) {
return p->receive(m);
});
return ok();
},
"server_connection");
@ -210,7 +212,7 @@ struct server {
if (not ret)
return to_result(ret);
thespian::receive(
[p](auto /*from*/, auto m) { return p->receive(move(m)); });
[p](const auto & /*from*/, const auto &m) { return p->receive(m); });
return ok();
}
};

View file

@ -9,8 +9,8 @@
#if !defined(_WIN32)
#include <netinet/in.h>
#else
#include <winsock2.h>
#include <in6addr.h>
#include <winsock2.h>
#include <ws2ipdef.h>
#include <ws2tcpip.h>
#endif
@ -116,8 +116,9 @@ auto ip_udp_echo(context &ctx, bool &result, env_t env_) -> ::result {
return to_result(ctx.spawn_link(
[=]() {
link(env().proc("log"));
receive([p{make_shared<controller>()}](auto /*from*/, auto m) {
return p->receive(move(m));
receive([p{make_shared<controller>()}](const auto & /*from*/,
const auto &m) {
return p->receive(m);
});
return ok();
},

View file

@ -6,7 +6,6 @@
#include <chrono>
#include <memory>
#include <string>
using cbor::buffer;
using std::move;
@ -64,7 +63,9 @@ auto initA() {
}
};
shared_ptr<state_t> state{new state_t};
receive([state](auto, auto m) mutable { return state->receive(m); });
receive([state](const auto &, const auto &m) mutable {
return state->receive(m);
});
return ok();
}

View file

@ -35,7 +35,7 @@ using clk = std::chrono::system_clock;
namespace {
enum class tag {
enum class tag : uint8_t {
ready = 1,
done = 2,
};

View file

@ -28,8 +28,8 @@ auto slave(const handle &last, int n) -> result {
if (n)
next = spawn_link([=]() { return slave(last, n - 1); }, "slave").value();
receive([n, next, last](auto, auto m) {
return n ? next.send_raw(move(m)) : last.send_raw(move(m));
receive([n, next, last](const auto &, const auto &m) {
return n ? next.send_raw(m) : last.send_raw(m);
});
return ok();
}
@ -41,11 +41,11 @@ auto controller(const int slaves) -> result {
auto ret = spawn_link([=]() { return slave(last, slaves); }, "slave");
if (not ret)
return to_result(ret);
handle first = ret.value();
const handle &first = ret.value();
auto ret2 = first.send("forward");
if (not ret2)
return ret2;
receive([loop, first, verbose](auto, auto m) mutable {
receive([loop, first, verbose](const auto &, const auto &m) mutable {
if (loop) {
if (verbose)
auto _ = env().proc("log").send(loop);

View file

@ -3,8 +3,6 @@
#include "thespian/env.hpp"
#include <thespian/instance.hpp>
#include <string>
using cbor::extract;
using std::move;
using thespian::context;
@ -21,7 +19,7 @@ using thespian::unexpected;
namespace {
auto slave(const int slaves, int spawned) -> result {
receive([slaves, spawned](auto, auto m) mutable {
receive([slaves, spawned](const auto &, const auto &m) mutable {
int n{0};
if (!m(extract(n)))
return unexpected(m);
@ -50,7 +48,7 @@ auto controller(const int slaves) -> result {
auto ret2 = ret.value().send(slaves - 1);
if (not ret2)
return ret2;
receive([](auto, auto) { return exit(); });
receive([](const auto &, const auto &) { return exit(); });
return ok();
}
} // namespace

View file

@ -34,7 +34,7 @@ auto initE() {
auto ret = env().proc("A").send("shutdown");
if (not ret)
return ret;
receive([](auto, auto) { return ok(); });
receive([](const auto &, const auto &) { return ok(); });
return ok();
}
@ -42,7 +42,7 @@ auto initD() {
auto ret = spawn(initE, "E");
if (not ret)
return to_result(ret);
receive([](auto, auto m) {
receive([](const auto &, const auto &m) {
if (m("die"))
return exit("died");
return unexpected(m);
@ -56,7 +56,7 @@ auto initC() {
if (not ret)
return to_result(ret);
trap(true);
receive([](auto /*from*/, auto m) {
receive([](const auto & /*from*/, const auto &m) {
if (m("exit", "died"))
return exit();
return unexpected(m);
@ -66,7 +66,7 @@ auto initC() {
auto initB() {
env().str("initBsays") = "noyoudont";
receive([](auto from, auto m) {
receive([](const auto &from, const auto &m) {
if (m("shutdown")) {
auto ret = from.send("done");
if (not ret)
@ -87,7 +87,7 @@ auto initA() {
if (not ret)
return ret;
spawn_link(initC, "C").value();
receive([i{0}](auto, auto m) mutable {
receive([i{0}](const auto &, const auto &m) mutable {
if (m("shutdown") || m("done"))
++i;
else

View file

@ -67,7 +67,7 @@ struct logger {
[name, &trace_m, verbose]() {
thespian::receive(
[p{make_shared<logger>(name, trace_m, verbose)}](
auto, auto m) { return p->receive(move(m)); });
const auto &, const auto &m) { return p->receive(m); });
return ok();
},
string("logger_") + name, move(env))

View file

@ -1,2 +1 @@
int runtestcase(const char *name); // NOLINT

View file

@ -4,7 +4,6 @@
#include <thespian/env.hpp>
#include <cstdlib>
#include <string_view>
constexpr auto check(bool expression) -> void {
if (!expression)
@ -12,7 +11,7 @@ constexpr auto check(bool expression) -> void {
}
using testcase = auto(thespian::context &ctx, bool &result, thespian::env_t env)
-> thespian::result;
-> thespian::result;
testcase cbor_match;
testcase debug;

View file

@ -7,7 +7,6 @@
#include <chrono>
#include <memory>
#include <string>
using cbor::array;
using cbor::buffer;
@ -47,7 +46,9 @@ auto initA() -> result {
}
};
shared_ptr<state_t> state{new state_t};
receive([state](auto, auto m) mutable { return state->receive(m); });
receive([state](const auto &, const auto &m) mutable {
return state->receive(m);
});
return ok();
}