Skip to content

Commit

Permalink
Change clang-format rule about aligning function parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
notlesh committed Apr 3, 2020
1 parent a93f49d commit 308adb6
Show file tree
Hide file tree
Showing 160 changed files with 1,363 additions and 1,145 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BasedOnStyle: Google
AlignAfterOpenBracket: Align
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: 'false'
AlignConsecutiveDeclarations: 'false'
AlignEscapedNewlinesLeft: 'true'
Expand Down
15 changes: 8 additions & 7 deletions daemon/lokinetctl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@ namespace
int
main(int argc, char* argv[])
{
cxxopts::Options options("lokinetctl",
"LokiNET is a free, open source, private, "
"decentralized, \"market based sybil resistant\" "
"and IP based onion routing network");

options.add_options()("v,verbose", "Verbose", cxxopts::value<bool>())("h,help", "help",
cxxopts::value<bool>())(
cxxopts::Options options(
"lokinetctl",
"LokiNET is a free, open source, private, "
"decentralized, \"market based sybil resistant\" "
"and IP based onion routing network");

options.add_options()("v,verbose", "Verbose", cxxopts::value<bool>())(
"h,help", "help", cxxopts::value<bool>())(
"c,config", "config file",
cxxopts::value<std::string>()->default_value(llarp::GetDefaultConfigPath().string()))
#ifdef WITH_CURL
Expand Down
21 changes: 11 additions & 10 deletions daemon/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,20 @@ main(int argc, char *argv[])
// SetUnhandledExceptionFilter(win32_signal_handler);
#endif

cxxopts::Options options("lokinet",
"LokiNET is a free, open source, private, "
"decentralized, \"market based sybil resistant\" "
"and IP based onion routing network");
cxxopts::Options options(
"lokinet",
"LokiNET is a free, open source, private, "
"decentralized, \"market based sybil resistant\" "
"and IP based onion routing network");
options.add_options()("v,verbose", "Verbose", cxxopts::value<bool>())(
"h,help", "help", cxxopts::value<bool>())("version", "version", cxxopts::value<bool>())(
"g,generate", "generate client config", cxxopts::value<bool>())(
"r,router", "generate router config", cxxopts::value<bool>())("f,force", "overwrite",
cxxopts::value<bool>())(
"r,router", "generate router config", cxxopts::value<bool>())(
"f,force", "overwrite", cxxopts::value<bool>())(
"c,colour", "colour output", cxxopts::value<bool>()->default_value("true"))(
"b,background", "background mode (start, but do not connect to the network)",
cxxopts::value<bool>())("config", "path to configuration file",
cxxopts::value<std::string>());
cxxopts::value<bool>())(
"config", "path to configuration file", cxxopts::value<std::string>());

options.parse_positional("config");

Expand Down Expand Up @@ -244,8 +245,8 @@ main(int argc, char *argv[])
auto fpath = llarp::GetDefaultConfigPath();

// if using default INI file, we're create it even if you don't ask us too
if (!llarp_ensure_config(fpath.string().c_str(), basepath.string().c_str(), overWrite,
asRouter))
if (!llarp_ensure_config(
fpath.string().c_str(), basepath.string().c_str(), overWrite, asRouter))
return 1;
conffname = fpath.string();
}
Expand Down
9 changes: 5 additions & 4 deletions include/llarp.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,14 @@ extern "C"
/// deferred call to llarp_vpn_io.injected is queued unconditionally
/// thread safe
bool
llarp_main_inject_vpn_by_name(struct llarp_main *m, const char *epName, struct llarp_vpn_io *io,
struct llarp_vpn_ifaddr_info info);
llarp_main_inject_vpn_by_name(
struct llarp_main *m, const char *epName, struct llarp_vpn_io *io,
struct llarp_vpn_ifaddr_info info);

/// give main context a vpn io on its default endpoint
static bool
llarp_main_inject_default_vpn(struct llarp_main *m, struct llarp_vpn_io *io,
struct llarp_vpn_ifaddr_info info)
llarp_main_inject_default_vpn(
struct llarp_main *m, struct llarp_vpn_io *io, struct llarp_vpn_ifaddr_info info)
{
return llarp_main_inject_vpn_by_name(m, llarp_main_get_default_endpoint_name(m), io, info);
}
Expand Down
4 changes: 2 additions & 2 deletions include/tuntap.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ extern "C"
int
tuntap_sys_set_ipv4_tap(struct device *, t_tun_in_addr *, uint32_t);
int
tuntap_sys_set_ipv4_tun(struct device *dev, t_tun_in_addr *s4, t_tun_in_addr *s4dest,
uint32_t bits, int netmask);
tuntap_sys_set_ipv4_tun(
struct device *dev, t_tun_in_addr *s4, t_tun_in_addr *s4dest, uint32_t bits, int netmask);
#endif

int
Expand Down
14 changes: 7 additions & 7 deletions jni/lokinet_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ extern "C"
llarp_config* conf = GetImpl<llarp_config>(env, self);
if (conf == nullptr)
return JNI_FALSE;
return VisitStringAsStringView<jboolean>(env, fname,
[conf](llarp::string_view val) -> jboolean {
const auto filename = llarp::string_view_string(val);
if (llarp_config_read_file(conf, filename.c_str()))
return JNI_TRUE;
return JNI_FALSE;
});
return VisitStringAsStringView<jboolean>(
env, fname, [conf](llarp::string_view val) -> jboolean {
const auto filename = llarp::string_view_string(val);
if (llarp_config_read_file(conf, filename.c_str()))
return JNI_TRUE;
return JNI_FALSE;
});
}
}
20 changes: 10 additions & 10 deletions jni/lokinet_vpn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ extern "C"
lokinet_jni_vpnio *vpn = GetImpl<lokinet_jni_vpnio>(env, self);
if (vpn == nullptr)
return;
VisitObjectMemberStringAsStringView<bool>(env, info, "ifaddr",
[vpn](llarp::string_view val) -> bool {
vpn->SetIfAddr(val);
return true;
});
VisitObjectMemberStringAsStringView<bool>(env, info, "ifname",
[vpn](llarp::string_view val) -> bool {
vpn->SetIfName(val);
return true;
});
VisitObjectMemberStringAsStringView<bool>(
env, info, "ifaddr", [vpn](llarp::string_view val) -> bool {
vpn->SetIfAddr(val);
return true;
});
VisitObjectMemberStringAsStringView<bool>(
env, info, "ifname", [vpn](llarp::string_view val) -> bool {
vpn->SetIfName(val);
return true;
});
vpn->info.netmask = GetObjectMemberAsInt<uint8_t>(env, info, "netmask");
}
}
4 changes: 2 additions & 2 deletions libabyss/include/abyss/server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ namespace abyss
virtual ~BaseReqHandler();

bool
ServeAsync(llarp_ev_loop_ptr loop, std::shared_ptr<llarp::Logic> logic,
const sockaddr* bindaddr);
ServeAsync(
llarp_ev_loop_ptr loop, std::shared_ptr<llarp::Logic> logic, const sockaddr* bindaddr);

void
RemoveConn(IRPCHandler* handler);
Expand Down
10 changes: 6 additions & 4 deletions libabyss/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ struct DemoCall : public abyss::http::IRPCClientHandler
std::function<void(void)> m_Callback;
std::shared_ptr<llarp::Logic> m_Logic;

DemoCall(abyss::http::ConnImpl* impl, std::shared_ptr<llarp::Logic> logic,
std::function<void(void)> callback)
DemoCall(
abyss::http::ConnImpl* impl, std::shared_ptr<llarp::Logic> logic,
std::function<void(void)> callback)
: abyss::http::IRPCClientHandler(impl), m_Callback(callback), m_Logic(logic)
{
llarp::LogInfo("new call");
Expand Down Expand Up @@ -71,8 +72,9 @@ struct DemoClient : public abyss::http::JSONRPC
void
DoDemoRequest()
{
QueueRPC("test", nlohmann::json::object(),
std::bind(&DemoClient::NewConn, this, std::placeholders::_1));
QueueRPC(
"test", nlohmann::json::object(),
std::bind(&DemoClient::NewConn, this, std::placeholders::_1));
Flush();
}
};
Expand Down
5 changes: 3 additions & 2 deletions libabyss/src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ namespace abyss

State state;

ConnImpl(llarp_tcp_conn* conn, JSONRPC* parent, const RPC_Method_t& method,
const RPC_Params& params, JSONRPC::HandlerFactory factory)
ConnImpl(
llarp_tcp_conn* conn, JSONRPC* parent, const RPC_Method_t& method,
const RPC_Params& params, JSONRPC::HandlerFactory factory)
: m_Conn(conn)
, m_Parent(parent)
, m_RequestBody(nlohmann::json::object())
Expand Down
29 changes: 15 additions & 14 deletions libabyss/src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,16 @@ namespace abyss
}

bool
WriteResponseSimple(int code, const std::string& msg, const char* contentType,
const char* content)
WriteResponseSimple(
int code, const std::string& msg, const char* contentType, const char* content)
{
char buf[512] = {0};
size_t contentLength = strlen(content);
int sz = snprintf(buf, sizeof(buf),
"HTTP/1.0 %d %s\r\nContent-Type: "
"%s\r\nContent-Length: %zu\r\n\r\n",
code, msg.c_str(), contentType, contentLength);
int sz = snprintf(
buf, sizeof(buf),
"HTTP/1.0 %d %s\r\nContent-Type: "
"%s\r\nContent-Length: %zu\r\n\r\n",
code, msg.c_str(), contentType, contentLength);
if (sz <= 0)
return false;
if (!llarp_tcp_conn_async_write(_conn, llarp_buffer_t(buf, sz)))
Expand All @@ -130,13 +131,13 @@ namespace abyss
auto itr = Header.Headers.find("content-type");
if (itr == Header.Headers.end())
{
return WriteResponseSimple(415, "Unsupported Media Type", "text/plain",
"no content type provided");
return WriteResponseSimple(
415, "Unsupported Media Type", "text/plain", "no content type provided");
}
else if (itr->second != string_view("application/json"))
{
return WriteResponseSimple(415, "Unsupported Media Type", "text/plain",
"this does not look like jsonrpc 2.0");
return WriteResponseSimple(
415, "Unsupported Media Type", "text/plain", "this does not look like jsonrpc 2.0");
}
}
// initialize body parser
Expand Down Expand Up @@ -185,8 +186,8 @@ namespace abyss
nlohmann::json response;
response["jsonrpc"] = "2.0";
response["id"] = m_Request["id"].get<std::string>();
auto value = handler->HandleJSONRPC(m_Request["method"].get<std::string>(),
m_Request["params"]);
auto value = handler->HandleJSONRPC(
m_Request["method"].get<std::string>(), m_Request["params"]);

if (!value.is_null())
response["result"] = std::move(value);
Expand Down Expand Up @@ -333,8 +334,8 @@ namespace abyss
}

bool
BaseReqHandler::ServeAsync(llarp_ev_loop_ptr loop, std::shared_ptr<llarp::Logic> logic,
const sockaddr* bindaddr)
BaseReqHandler::ServeAsync(
llarp_ev_loop_ptr loop, std::shared_ptr<llarp::Logic> logic, const sockaddr* bindaddr)
{
m_loop = loop;
m_Logic = logic;
Expand Down
13 changes: 7 additions & 6 deletions llarp/android/ifaddrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ netlink_send(int p_socket, int p_request)
struct sockaddr_nl l_addr;
memset(&l_addr, 0, sizeof(l_addr));
l_addr.nl_family = AF_NETLINK;
return (sendto(p_socket, &l_data.m_hdr, l_data.m_hdr.nlmsg_len, 0, (struct sockaddr *)&l_addr,
sizeof(l_addr)));
return (sendto(
p_socket, &l_data.m_hdr, l_data.m_hdr.nlmsg_len, 0, (struct sockaddr *)&l_addr,
sizeof(l_addr)));
}

static int
Expand Down Expand Up @@ -261,8 +262,8 @@ calcAddrLen(sa_family_t p_family, int p_dataSize)
case AF_INET6:
return sizeof(struct sockaddr_in6);
case AF_PACKET:
return maxSize(sizeof(struct sockaddr_ll),
offsetof(struct sockaddr_ll, sll_addr) + p_dataSize);
return maxSize(
sizeof(struct sockaddr_ll), offsetof(struct sockaddr_ll, sll_addr) + p_dataSize);
default:
return maxSize(sizeof(struct sockaddr), offsetof(struct sockaddr, sa_data) + p_dataSize);
}
Expand Down Expand Up @@ -604,8 +605,8 @@ interpretLinks(int p_socket, NetlinkList *p_netlinkList, struct ifaddrs **p_resu
}

static int
interpretAddrs(int p_socket, NetlinkList *p_netlinkList, struct ifaddrs **p_resultList,
int p_numLinks)
interpretAddrs(
int p_socket, NetlinkList *p_netlinkList, struct ifaddrs **p_resultList, int p_numLinks)
{
pid_t l_pid = getpid();
for (; p_netlinkList; p_netlinkList = p_netlinkList->m_next)
Expand Down
4 changes: 2 additions & 2 deletions llarp/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ namespace llarp
}
else
{
LogError("failed to open log file at '", val,
"' for an unknown reason, bailing tf out kbai");
LogError(
"failed to open log file at '", val, "' for an unknown reason, bailing tf out kbai");
::abort();
}
}
Expand Down
4 changes: 2 additions & 2 deletions llarp/config/ini.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ namespace llarp
}

bool
ConfigParser::VisitSection(const char* name,
std::function<bool(const Section_t& sect)> visit) const
ConfigParser::VisitSection(
const char* name, std::function<bool(const Section_t& sect)> visit) const
{
auto itr = m_Config.find(name);
if (itr == m_Config.end())
Expand Down
10 changes: 6 additions & 4 deletions llarp/config/key_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ namespace llarp
}
else
{
LogWarn("Our RouterContact ", m_rcPath,
" seems out of date, backing up and regenerating private keys");
LogWarn(
"Our RouterContact ", m_rcPath,
" seems out of date, backing up and regenerating private keys");

if (!backupKeyFilesByMoving())
{
Expand Down Expand Up @@ -177,8 +178,9 @@ namespace llarp
}

bool
KeyManager::loadOrCreateKey(const std::string& filepath, llarp::SecretKey& key,
std::function<void(llarp::SecretKey& key)> keygen)
KeyManager::loadOrCreateKey(
const std::string& filepath, llarp::SecretKey& key,
std::function<void(llarp::SecretKey& key)> keygen)
{
fs::path path(filepath);
std::error_code ec;
Expand Down
5 changes: 3 additions & 2 deletions llarp/config/key_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ namespace llarp
///
/// @param keygen is a function that will generate the key if needed
static bool
loadOrCreateKey(const std::string& filepath, llarp::SecretKey& key,
std::function<void(llarp::SecretKey& key)> keygen);
loadOrCreateKey(
const std::string& filepath, llarp::SecretKey& key,
std::function<void(llarp::SecretKey& key)> keygen);

/// Requests the identity key from lokid via HTTP (curl)
bool
Expand Down
5 changes: 3 additions & 2 deletions llarp/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,9 @@ extern "C"
}

bool
llarp_main_inject_vpn_by_name(struct llarp_main *ptr, const char *name, struct llarp_vpn_io *io,
struct llarp_vpn_ifaddr_info info)
llarp_main_inject_vpn_by_name(
struct llarp_main *ptr, const char *name, struct llarp_vpn_io *io,
struct llarp_vpn_ifaddr_info info)
{
if (name == nullptr || io == nullptr)
return false;
Expand Down
8 changes: 4 additions & 4 deletions llarp/crypto/crypto.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ namespace llarp

/// xchacha symmetric cipher (multibuffer)
virtual bool
xchacha20_alt(const llarp_buffer_t &, const llarp_buffer_t &, const SharedSecret &,
const byte_t *) = 0;
xchacha20_alt(
const llarp_buffer_t &, const llarp_buffer_t &, const SharedSecret &, const byte_t *) = 0;

/// path dh creator's side
virtual bool
Expand Down Expand Up @@ -67,8 +67,8 @@ namespace llarp

/// derive sub keys for private keys
virtual bool
derive_subkey_private(PrivateKey &, const SecretKey &, uint64_t,
const AlignedBuffer<32> * = nullptr) = 0;
derive_subkey_private(
PrivateKey &, const SecretKey &, uint64_t, const AlignedBuffer<32> * = nullptr) = 0;

/// seed to secretkey
virtual bool
Expand Down

0 comments on commit 308adb6

Please sign in to comment.