Skip to content

Commit

Permalink
Reformat code with clang-format-18
Browse files Browse the repository at this point in the history
Switch to BreakBeforeBinaryOperators: NonAssignment
due to issues with pure-virtual methods.
cf. llvm/llvm-project#57569

Signed-off-by: Frank Lichtenheld <[email protected]>
  • Loading branch information
flichtenheld authored and Jenkins-dev committed Nov 1, 2024
1 parent 43a52c3 commit 28ccaff
Show file tree
Hide file tree
Showing 31 changed files with 164 additions and 226 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
BasedOnStyle: Microsoft
ColumnLimit: 0
SortIncludes: Never
BreakBeforeBinaryOperators: All
BreakBeforeBinaryOperators: NonAssignment
BinPackArguments: False
BinPackParameters: False
IndentCaseBlocks: true
Expand Down
3 changes: 1 addition & 2 deletions openvpn/acceptor/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ struct Base : public RC<thread_unsafe_refcount>

virtual void async_accept(ListenerBase *listener,
const size_t acceptor_index,
openvpn_io::io_context &io_context)
= 0;
openvpn_io::io_context &io_context) = 0;
virtual void close() = 0;
};

Expand Down
10 changes: 5 additions & 5 deletions openvpn/acceptor/namedpipe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ class NamedPipe : public Base
listener = ListenerBase::Ptr(listener),
acceptor_index](const openvpn_io::error_code &ec, size_t bytes_transferred)
{
// accept client connection
listener->handle_accept(new AsioPolySock::NamedPipe(std::move(self->handle), acceptor_index),
ec.value() == ERROR_PIPE_CONNECTED // not an error
? openvpn_io::error_code()
: ec);
// accept client connection
listener->handle_accept(new AsioPolySock::NamedPipe(std::move(self->handle), acceptor_index),
ec.value() == ERROR_PIPE_CONNECTED // not an error
? openvpn_io::error_code()
: ec);
});

const BOOL ok = ::ConnectNamedPipe(handle.native_handle(), over.get());
Expand Down
6 changes: 2 additions & 4 deletions openvpn/asio/asiopolysock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ class Base : public RC<thread_unsafe_refcount>
typedef RCPtr<Base> Ptr;

virtual void async_send(const openvpn_io::const_buffer &buf,
Function<void(const openvpn_io::error_code &, const size_t)> &&callback)
= 0;
Function<void(const openvpn_io::error_code &, const size_t)> &&callback) = 0;

virtual void async_receive(const openvpn_io::mutable_buffer &buf,
Function<void(const openvpn_io::error_code &, const size_t)> &&callback)
= 0;
Function<void(const openvpn_io::error_code &, const size_t)> &&callback) = 0;

virtual std::string remote_endpoint_str() const = 0;
virtual bool remote_ip_port(IP::Addr &addr, unsigned int &port) const = 0;
Expand Down
3 changes: 1 addition & 2 deletions openvpn/client/async_resolve/asio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ class AsyncResolvable
}

virtual void resolve_callback(const openvpn_io::error_code &error,
results_type results)
= 0;
results_type results) = 0;

// mimic the asynchronous DNS resolution by performing a
// synchronous one in a detached thread.
Expand Down
3 changes: 1 addition & 2 deletions openvpn/client/async_resolve/generic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class AsyncResolvable : public virtual RC<thread_unsafe_refcount>
}

virtual void resolve_callback(const openvpn_io::error_code &error,
results_type results)
= 0;
results_type results) = 0;

// This implementation assumes that the i/o reactor provides an asynchronous
// DNS resolution routine using its own primitives and that doesn't require
Expand Down
42 changes: 21 additions & 21 deletions openvpn/common/pipe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ class SD_OUT : public SD
sd->async_write_some(buf.const_buffer_limit(2048),
[this](const openvpn_io::error_code &ec, const size_t bytes_sent)
{
if (!ec && bytes_sent < buf.size())
{
buf.advance(bytes_sent);
queue_write();
}
else
{
sd->close();
}
});
if (!ec && bytes_sent < buf.size())
{
buf.advance(bytes_sent);
queue_write();
}
else
{
sd->close();
}
});
}

BufferAllocated buf;
Expand Down Expand Up @@ -99,17 +99,17 @@ class SD_IN : public SD
sd->async_read_some(buf.mutable_buffer_clamp(),
[this](const openvpn_io::error_code &ec, const size_t bytes_recvd)
{
if (!ec)
{
buf.set_size(bytes_recvd);
data.put_consume(buf);
queue_read();
}
else
{
sd->close();
}
});
if (!ec)
{
buf.set_size(bytes_recvd);
data.put_consume(buf);
queue_read();
}
else
{
sd->close();
}
});
}

BufferAllocated buf;
Expand Down
3 changes: 1 addition & 2 deletions openvpn/common/rc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,8 +913,7 @@ class RC
public:
typedef RCPtr<RC> Ptr;

RC()
noexcept = default;
RC() noexcept = default;
virtual ~RC() = default;
RC(const RC &) = delete;
RC &operator=(const RC &) = delete;
Expand Down
6 changes: 3 additions & 3 deletions openvpn/common/runcontext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ class RunContext : public RunContextBase
exit_sock->async_read_some(openvpn_io::null_buffers(),
[self = Ptr(this)](const openvpn_io::error_code &error, const size_t bytes_recvd)
{
if (!error)
self->cancel();
});
if (!error)
self->cancel();
});
}
#endif

Expand Down
12 changes: 6 additions & 6 deletions openvpn/common/signal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ struct SignalBlockerDefault : public SignalBlocker
{
SignalBlockerDefault()
: SignalBlocker( // these signals should be handled by parent thread
Signal::F_SIGINT
| Signal::F_SIGTERM
| Signal::F_SIGHUP
| Signal::F_SIGUSR1
| Signal::F_SIGUSR2
| Signal::F_SIGPIPE)
Signal::F_SIGINT
| Signal::F_SIGTERM
| Signal::F_SIGHUP
| Signal::F_SIGUSR1
| Signal::F_SIGUSR2
| Signal::F_SIGPIPE)
{
}
};
Expand Down
9 changes: 3 additions & 6 deletions openvpn/crypto/cryptodc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,14 @@ class CryptoDCInstance : public RC<thread_unsafe_refcount>
virtual unsigned int defined() const = 0;

virtual void init_cipher(StaticKey &&encrypt_key,
StaticKey &&decrypt_key)
= 0;
StaticKey &&decrypt_key) = 0;

virtual void init_hmac(StaticKey &&encrypt_key,
StaticKey &&decrypt_key)
= 0;
StaticKey &&decrypt_key) = 0;

virtual void init_pid(const char *recv_name,
const int recv_unit,
const SessionStats::Ptr &recv_stats_arg)
= 0;
const SessionStats::Ptr &recv_stats_arg) = 0;

virtual void init_remote_peer_id(const int remote_peer_id)
{
Expand Down
6 changes: 2 additions & 4 deletions openvpn/crypto/ovpnhmac.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,13 @@ class OvpnHMACInstance : public RC<thread_unsafe_refcount>
const size_t data_size,
const size_t l1,
const size_t l2,
const size_t l3)
= 0;
const size_t l3) = 0;

virtual bool ovpn_hmac_cmp(const unsigned char *data,
const size_t data_size,
const size_t l1,
const size_t l2,
const size_t l3)
= 0;
const size_t l3) = 0;
};

class OvpnHMACContext : public RC<thread_unsafe_refcount>
Expand Down
3 changes: 1 addition & 2 deletions openvpn/dco/korekey.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class Receiver : public virtual RC<thread_unsafe_refcount>
typedef RCPtr<Receiver> Ptr;

virtual void rekey(const CryptoDCInstance::RekeyType type,
const Info &info)
= 0;
const Info &info) = 0;

virtual void explicit_exit_notify()
{
Expand Down
28 changes: 14 additions & 14 deletions openvpn/dco/ovpndcocli.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,22 +641,22 @@ class OvpnDcoClient : public Client,
pkt = PacketFrom::SPtr(pkt)](const openvpn_io::error_code &error,
const size_t bytes_recvd) mutable
{
if (!error)
{
pkt->buf.set_size(bytes_recvd);
if (self->tun_read_handler(pkt->buf))
self->queue_read_pipe(pkt.release());
}
else
{
if (!self->halt)
if (!error)
{
OPENVPN_LOG("ovpn-dco pipe read error: " << error.message());
self->stop_();
self->transport_parent->transport_error(Error::TUN_HALT,
error.message());
pkt->buf.set_size(bytes_recvd);
if (self->tun_read_handler(pkt->buf))
self->queue_read_pipe(pkt.release());
}
else
{
if (!self->halt)
{
OPENVPN_LOG("ovpn-dco pipe read error: " << error.message());
self->stop_();
self->transport_parent->transport_error(Error::TUN_HALT,
error.message());
}
}
}
});
}

Expand Down
54 changes: 27 additions & 27 deletions openvpn/dco/ovpndcowincli.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,21 +309,21 @@ class OvpnDcoWinClient : public Client,
[self = Ptr(this)](const openvpn_io::error_code &error,
const size_t bytes_recvd)
{
if (self->halt)
return;
if (!error)
{
self->buf_.set_size(bytes_recvd);
self->transport_parent->transport_recv(self->buf_);
if (!self->halt)
self->queue_read_();
}
else if (!self->halt)
{
self->stop_();
self->transport_parent->transport_error(Error::TRANSPORT_ERROR,
error.message());
}
if (self->halt)
return;
if (!error)
{
self->buf_.set_size(bytes_recvd);
self->transport_parent->transport_recv(self->buf_);
if (!self->halt)
self->queue_read_();
}
else if (!self->halt)
{
self->stop_();
self->transport_parent->transport_error(Error::TRANSPORT_ERROR,
error.message());
}
});
}

Expand Down Expand Up @@ -400,18 +400,18 @@ class OvpnDcoWinClient : public Client,
[self = Ptr(this), complete](const openvpn_io::error_code &ec,
std::size_t len)
{
if (self->halt)
return;
if (!ec)
complete();
else
{
std::ostringstream errmsg;
errmsg << "TCP connection error: " << ec.message();
self->config->transport.stats->error(Error::TCP_CONNECT_ERROR);
self->transport_parent->transport_error(Error::UNDEF, errmsg.str());
self->stop_();
}
if (self->halt)
return;
if (!ec)
complete();
else
{
std::ostringstream errmsg;
errmsg << "TCP connection error: " << ec.message();
self->config->transport.stats->error(Error::TCP_CONNECT_ERROR);
self->transport_parent->transport_error(Error::UNDEF, errmsg.str());
self->stop_();
}
}};

const DWORD ec = dco_ioctl_(OVPN_IOCTL_NEW_PEER, &peer, sizeof(peer), NULL, 0, &ov);
Expand Down
2 changes: 1 addition & 1 deletion openvpn/ip/tcp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct TCPHeader
{
static unsigned int length(const std::uint8_t doff_res)
{
return ((doff_res)&0xF0) >> 2;
return ((doff_res) & 0xF0) >> 2;
}

std::uint16_t source;
Expand Down
20 changes: 10 additions & 10 deletions openvpn/omi/omi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -894,9 +894,9 @@ class OMICore : public Acceptor::ListenerBase
s->socket.async_connect(ep,
[self = Ptr(this), sock](const openvpn_io::error_code &error) mutable
{
// this is a connect, but we reuse the accept method
self->handle_accept(std::move(sock), error);
});
// this is a connect, but we reuse the accept method
self->handle_accept(std::move(sock), error);
});
}

void connect_unix(const std::string &socket_path)
Expand All @@ -908,9 +908,9 @@ class OMICore : public Acceptor::ListenerBase
s->socket.async_connect(ep,
[self = Ptr(this), sock](const openvpn_io::error_code &error) mutable
{
// this is a connect, but we reuse the accept method
self->handle_accept(std::move(sock), error);
});
// this is a connect, but we reuse the accept method
self->handle_accept(std::move(sock), error);
});
#else
throw Exception("unix sockets not supported on this platform");
#endif
Expand All @@ -924,8 +924,8 @@ class OMICore : public Acceptor::ListenerBase
socket->async_receive(buf->mutable_buffer_clamp(),
[self = Ptr(this), sock = socket, buf](const openvpn_io::error_code &error, const size_t bytes_recvd)
{
self->handle_recv(error, bytes_recvd, std::move(buf), sock.get());
});
self->handle_recv(error, bytes_recvd, std::move(buf), sock.get());
});
recv_queued = true;
}

Expand Down Expand Up @@ -984,8 +984,8 @@ class OMICore : public Acceptor::ListenerBase
socket->async_send(buf.const_buffer_clamp(),
[self = Ptr(this), sock = socket](const openvpn_io::error_code &error, const size_t bytes_sent)
{
self->handle_send(error, bytes_sent, sock.get());
});
self->handle_send(error, bytes_sent, sock.get());
});
}

void handle_send(const openvpn_io::error_code &error,
Expand Down
3 changes: 1 addition & 2 deletions openvpn/openssl/pki/crl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class CRL
{
}

CRL(CRL &&other)
noexcept
CRL(CRL &&other) noexcept
: crl_(other.crl_)
{
other.crl_ = nullptr;
Expand Down
3 changes: 1 addition & 2 deletions openvpn/openssl/pki/dh-compat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ class DH
dup(other.dh_);
}

DH(DH &&other)
noexcept
DH(DH &&other) noexcept
: dh_(other.dh_)
{
other.dh_ = nullptr;
Expand Down
Loading

0 comments on commit 28ccaff

Please sign in to comment.