From 28ccaff741e8d017d76661fd5cef800b53429e70 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Wed, 30 Oct 2024 17:14:53 +0000 Subject: [PATCH] Reformat code with clang-format-18 Switch to BreakBeforeBinaryOperators: NonAssignment due to issues with pure-virtual methods. cf. https://github.com/llvm/llvm-project/issues/57569 Signed-off-by: Frank Lichtenheld --- .clang-format | 2 +- openvpn/acceptor/base.hpp | 3 +- openvpn/acceptor/namedpipe.hpp | 10 ++-- openvpn/asio/asiopolysock.hpp | 6 +-- openvpn/client/async_resolve/asio.hpp | 3 +- openvpn/client/async_resolve/generic.hpp | 3 +- openvpn/common/pipe.hpp | 42 +++++++-------- openvpn/common/rc.hpp | 3 +- openvpn/common/runcontext.hpp | 6 +-- openvpn/common/signal.hpp | 12 ++--- openvpn/crypto/cryptodc.hpp | 9 ++-- openvpn/crypto/ovpnhmac.hpp | 6 +-- openvpn/dco/korekey.hpp | 3 +- openvpn/dco/ovpndcocli.hpp | 28 +++++----- openvpn/dco/ovpndcowincli.hpp | 54 ++++++++++---------- openvpn/ip/tcp.hpp | 2 +- openvpn/omi/omi.hpp | 20 ++++---- openvpn/openssl/pki/crl.hpp | 3 +- openvpn/openssl/pki/dh-compat.hpp | 3 +- openvpn/openssl/pki/dh.hpp | 3 +- openvpn/openssl/pki/x509.hpp | 3 +- openvpn/openssl/pki/xkey.hpp | 8 ++- openvpn/ssl/proto.hpp | 8 +-- openvpn/transport/tcplinkbase.hpp | 3 +- openvpn/transport/tcplinkcommon.hpp | 58 ++++++++++----------- openvpn/transport/udplink.hpp | 6 +-- openvpn/tun/client/tunbase.hpp | 4 +- openvpn/tun/linux/client/genl.hpp | 4 +- openvpn/tun/tunio.hpp | 6 +-- openvpn/ws/httpcli.hpp | 4 +- test/unittests/test_openssl_authcert.cpp | 65 ++++-------------------- 31 files changed, 164 insertions(+), 226 deletions(-) diff --git a/.clang-format b/.clang-format index d6c3fdd9..e1435c07 100644 --- a/.clang-format +++ b/.clang-format @@ -1,7 +1,7 @@ BasedOnStyle: Microsoft ColumnLimit: 0 SortIncludes: Never -BreakBeforeBinaryOperators: All +BreakBeforeBinaryOperators: NonAssignment BinPackArguments: False BinPackParameters: False IndentCaseBlocks: true diff --git a/openvpn/acceptor/base.hpp b/openvpn/acceptor/base.hpp index d6088e30..e6aa361f 100644 --- a/openvpn/acceptor/base.hpp +++ b/openvpn/acceptor/base.hpp @@ -44,8 +44,7 @@ struct Base : public RC 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; }; diff --git a/openvpn/acceptor/namedpipe.hpp b/openvpn/acceptor/namedpipe.hpp index 20414b91..aa53e851 100644 --- a/openvpn/acceptor/namedpipe.hpp +++ b/openvpn/acceptor/namedpipe.hpp @@ -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()); diff --git a/openvpn/asio/asiopolysock.hpp b/openvpn/asio/asiopolysock.hpp index d92b8d98..ddff6fae 100644 --- a/openvpn/asio/asiopolysock.hpp +++ b/openvpn/asio/asiopolysock.hpp @@ -50,12 +50,10 @@ class Base : public RC typedef RCPtr Ptr; virtual void async_send(const openvpn_io::const_buffer &buf, - Function &&callback) - = 0; + Function &&callback) = 0; virtual void async_receive(const openvpn_io::mutable_buffer &buf, - Function &&callback) - = 0; + Function &&callback) = 0; virtual std::string remote_endpoint_str() const = 0; virtual bool remote_ip_port(IP::Addr &addr, unsigned int &port) const = 0; diff --git a/openvpn/client/async_resolve/asio.hpp b/openvpn/client/async_resolve/asio.hpp index f7400512..de036c5b 100644 --- a/openvpn/client/async_resolve/asio.hpp +++ b/openvpn/client/async_resolve/asio.hpp @@ -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. diff --git a/openvpn/client/async_resolve/generic.hpp b/openvpn/client/async_resolve/generic.hpp index 676a3c8c..779c4d1e 100644 --- a/openvpn/client/async_resolve/generic.hpp +++ b/openvpn/client/async_resolve/generic.hpp @@ -38,8 +38,7 @@ class AsyncResolvable : public virtual RC } 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 diff --git a/openvpn/common/pipe.hpp b/openvpn/common/pipe.hpp index 9339a30e..61dec527 100644 --- a/openvpn/common/pipe.hpp +++ b/openvpn/common/pipe.hpp @@ -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; @@ -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; diff --git a/openvpn/common/rc.hpp b/openvpn/common/rc.hpp index 63857d1e..48163314 100644 --- a/openvpn/common/rc.hpp +++ b/openvpn/common/rc.hpp @@ -913,8 +913,7 @@ class RC public: typedef RCPtr Ptr; - RC() - noexcept = default; + RC() noexcept = default; virtual ~RC() = default; RC(const RC &) = delete; RC &operator=(const RC &) = delete; diff --git a/openvpn/common/runcontext.hpp b/openvpn/common/runcontext.hpp index 94506927..11fea8de 100644 --- a/openvpn/common/runcontext.hpp +++ b/openvpn/common/runcontext.hpp @@ -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 diff --git a/openvpn/common/signal.hpp b/openvpn/common/signal.hpp index 123f1435..867d0cba 100644 --- a/openvpn/common/signal.hpp +++ b/openvpn/common/signal.hpp @@ -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) { } }; diff --git a/openvpn/crypto/cryptodc.hpp b/openvpn/crypto/cryptodc.hpp index 8ade4472..9782b9ce 100644 --- a/openvpn/crypto/cryptodc.hpp +++ b/openvpn/crypto/cryptodc.hpp @@ -56,17 +56,14 @@ class CryptoDCInstance : public RC 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) { diff --git a/openvpn/crypto/ovpnhmac.hpp b/openvpn/crypto/ovpnhmac.hpp index fe417203..d568973e 100644 --- a/openvpn/crypto/ovpnhmac.hpp +++ b/openvpn/crypto/ovpnhmac.hpp @@ -149,15 +149,13 @@ class OvpnHMACInstance : public RC 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 diff --git a/openvpn/dco/korekey.hpp b/openvpn/dco/korekey.hpp index c83fbe8a..cb17739a 100644 --- a/openvpn/dco/korekey.hpp +++ b/openvpn/dco/korekey.hpp @@ -24,8 +24,7 @@ class Receiver : public virtual RC typedef RCPtr Ptr; virtual void rekey(const CryptoDCInstance::RekeyType type, - const Info &info) - = 0; + const Info &info) = 0; virtual void explicit_exit_notify() { diff --git a/openvpn/dco/ovpndcocli.hpp b/openvpn/dco/ovpndcocli.hpp index 4258c2d3..8d02334b 100644 --- a/openvpn/dco/ovpndcocli.hpp +++ b/openvpn/dco/ovpndcocli.hpp @@ -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()); + } } - } }); } diff --git a/openvpn/dco/ovpndcowincli.hpp b/openvpn/dco/ovpndcowincli.hpp index b123fcdd..bfc10a40 100644 --- a/openvpn/dco/ovpndcowincli.hpp +++ b/openvpn/dco/ovpndcowincli.hpp @@ -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()); + } }); } @@ -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); diff --git a/openvpn/ip/tcp.hpp b/openvpn/ip/tcp.hpp index e2ec3f46..5d4e3a0e 100644 --- a/openvpn/ip/tcp.hpp +++ b/openvpn/ip/tcp.hpp @@ -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; diff --git a/openvpn/omi/omi.hpp b/openvpn/omi/omi.hpp index 0526d7c2..eb55e0a7 100644 --- a/openvpn/omi/omi.hpp +++ b/openvpn/omi/omi.hpp @@ -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) @@ -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 @@ -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; } @@ -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, diff --git a/openvpn/openssl/pki/crl.hpp b/openvpn/openssl/pki/crl.hpp index d5e5274a..fa68830f 100644 --- a/openvpn/openssl/pki/crl.hpp +++ b/openvpn/openssl/pki/crl.hpp @@ -44,8 +44,7 @@ class CRL { } - CRL(CRL &&other) - noexcept + CRL(CRL &&other) noexcept : crl_(other.crl_) { other.crl_ = nullptr; diff --git a/openvpn/openssl/pki/dh-compat.hpp b/openvpn/openssl/pki/dh-compat.hpp index 61e17303..f8ca4842 100644 --- a/openvpn/openssl/pki/dh-compat.hpp +++ b/openvpn/openssl/pki/dh-compat.hpp @@ -62,8 +62,7 @@ class DH dup(other.dh_); } - DH(DH &&other) - noexcept + DH(DH &&other) noexcept : dh_(other.dh_) { other.dh_ = nullptr; diff --git a/openvpn/openssl/pki/dh.hpp b/openvpn/openssl/pki/dh.hpp index 307f0199..234cbfba 100644 --- a/openvpn/openssl/pki/dh.hpp +++ b/openvpn/openssl/pki/dh.hpp @@ -49,8 +49,7 @@ class DH dup(other.dh_); } - DH(DH &&other) - noexcept + DH(DH &&other) noexcept : dh_(other.dh_) { other.dh_ = nullptr; diff --git a/openvpn/openssl/pki/x509.hpp b/openvpn/openssl/pki/x509.hpp index 46d45a99..ec321fd5 100644 --- a/openvpn/openssl/pki/x509.hpp +++ b/openvpn/openssl/pki/x509.hpp @@ -51,8 +51,7 @@ class X509 { } - X509(X509 &&other) - noexcept + X509(X509 &&other) noexcept : x509_(std::move(other.x509_)) { } diff --git a/openvpn/openssl/pki/xkey.hpp b/openvpn/openssl/pki/xkey.hpp index b0b5eede..6d5a666a 100644 --- a/openvpn/openssl/pki/xkey.hpp +++ b/openvpn/openssl/pki/xkey.hpp @@ -81,9 +81,8 @@ class XKeyExternalPKIImpl : public std::enable_shared_from_this bool { - if (!alg.dc_cipher()) - return false; - out << alg.name() << ':'; - return true; + if (!alg.dc_cipher()) + return false; + out << alg.name() << ':'; + return true; }); out.seekp(-1, std::ios_base::cur); out << "\n"; diff --git a/openvpn/transport/tcplinkbase.hpp b/openvpn/transport/tcplinkbase.hpp index 288a4685..7646b089 100644 --- a/openvpn/transport/tcplinkbase.hpp +++ b/openvpn/transport/tcplinkbase.hpp @@ -20,8 +20,7 @@ class LinkBase : public RC { protected: virtual void recv_buffer(PacketFrom::SPtr &pfp, - const size_t bytes_recvd) - = 0; + const size_t bytes_recvd) = 0; virtual void from_app_send_buffer(BufferPtr &buf) = 0; public: diff --git a/openvpn/transport/tcplinkcommon.hpp b/openvpn/transport/tcplinkcommon.hpp index b3f7fa82..2aed09b9 100644 --- a/openvpn/transport/tcplinkcommon.hpp +++ b/openvpn/transport/tcplinkcommon.hpp @@ -189,32 +189,32 @@ class LinkCommon : public LinkBase socket.async_receive(frame_context.mutable_buffer_clamp(tcpfrom->buf), [self = Ptr(this), tcpfrom = PacketFrom::SPtr(tcpfrom)](const openvpn_io::error_code &error, const size_t bytes_recvd) mutable { - OPENVPN_ASYNC_HANDLER; - try - { - self->handle_recv(std::move(tcpfrom), error, bytes_recvd); - } - catch (const std::exception &e) - { - Error::Type err = Error::TCP_SIZE_ERROR; - const char *msg = "TCP_SIZE_ERROR"; - // if exception is an ExceptionCode, translate the code - // to return status string - { - const ExceptionCode *ec = dynamic_cast(&e); - if (ec && ec->code_defined()) - { - err = ec->code(); - msg = ec->what(); - } - } - - OPENVPN_LOG_TCPLINK_ERROR("TCP packet extract exception: " << e.what()); - self->stats->error(err); - self->read_handler->tcp_error_handler(msg); - self->stop(); - } - }); + OPENVPN_ASYNC_HANDLER; + try + { + self->handle_recv(std::move(tcpfrom), error, bytes_recvd); + } + catch (const std::exception &e) + { + Error::Type err = Error::TCP_SIZE_ERROR; + const char *msg = "TCP_SIZE_ERROR"; + // if exception is an ExceptionCode, translate the code + // to return status string + { + const ExceptionCode *ec = dynamic_cast(&e); + if (ec && ec->code_defined()) + { + err = ec->code(); + msg = ec->what(); + } + } + + OPENVPN_LOG_TCPLINK_ERROR("TCP packet extract exception: " << e.what()); + self->stats->error(err); + self->read_handler->tcp_error_handler(msg); + self->stop(); + } + }); } protected: @@ -281,9 +281,9 @@ class LinkCommon : public LinkBase socket.async_send(buf.const_buffer_clamp(), [self = Ptr(this)](const openvpn_io::error_code &error, const size_t bytes_sent) { - OPENVPN_ASYNC_HANDLER; - self->handle_send(error, bytes_sent); - }); + OPENVPN_ASYNC_HANDLER; + self->handle_send(error, bytes_sent); + }); } void handle_send(const openvpn_io::error_code &error, const size_t bytes_sent) diff --git a/openvpn/transport/udplink.hpp b/openvpn/transport/udplink.hpp index 39c9b582..ea0cfc92 100644 --- a/openvpn/transport/udplink.hpp +++ b/openvpn/transport/udplink.hpp @@ -136,9 +136,9 @@ class UDPLink : public RC udpfrom->sender_endpoint, [self = Ptr(this), udpfrom = PacketFrom::SPtr(udpfrom)](const openvpn_io::error_code &error, const size_t bytes_recvd) mutable { - OPENVPN_ASYNC_HANDLER; - self->handle_read(std::move(udpfrom), error, bytes_recvd); - }); + OPENVPN_ASYNC_HANDLER; + self->handle_read(std::move(udpfrom), error, bytes_recvd); + }); } void handle_read(PacketFrom::SPtr pfp, const openvpn_io::error_code &error, const size_t bytes_recvd) diff --git a/openvpn/tun/client/tunbase.hpp b/openvpn/tun/client/tunbase.hpp index 1072b6a3..1fc7552f 100644 --- a/openvpn/tun/client/tunbase.hpp +++ b/openvpn/tun/client/tunbase.hpp @@ -52,7 +52,7 @@ struct TunClient : public virtual RC virtual int vpn_mtu() const = 0; - virtual void adjust_mss(int mss){}; + virtual void adjust_mss(int mss) {}; /** * @brief Notifies tun client about received PUSH_UPDATE control channel message. @@ -65,7 +65,7 @@ struct TunClient : public virtual RC * @param opt merged options, to be applied by implementation * @param cli transport client, passed to tun_start() call */ - virtual void apply_push_update(const OptionList &opt, TransportClient &cli){}; + virtual void apply_push_update(const OptionList &opt, TransportClient &cli) {}; }; // Base class for parent of tun interface object, used to diff --git a/openvpn/tun/linux/client/genl.hpp b/openvpn/tun/linux/client/genl.hpp index 8f6c4ecc..4e2e8397 100644 --- a/openvpn/tun/linux/client/genl.hpp +++ b/openvpn/tun/linux/client/genl.hpp @@ -586,8 +586,8 @@ class GeNL : public RC stream->async_wait(openvpn_io::posix::stream_descriptor::wait_read, [self = Ptr(this)](const openvpn_io::error_code &error) { - self->handle_read(error); - }); + self->handle_read(error); + }); } NlMsgPtr create_msg(enum ovpn_nl_commands cmd) diff --git a/openvpn/tun/tunio.hpp b/openvpn/tun/tunio.hpp index 6671d09d..12fdf63d 100644 --- a/openvpn/tun/tunio.hpp +++ b/openvpn/tun/tunio.hpp @@ -209,9 +209,9 @@ class TunIO : public RC stream->async_read_some(frame_context.mutable_buffer(tunfrom->buf), [self = Ptr(this), tunfrom = typename PacketFrom::SPtr(tunfrom)](const openvpn_io::error_code &error, const size_t bytes_recvd) mutable { - OPENVPN_ASYNC_HANDLER; - self->handle_read(std::move(tunfrom), error, bytes_recvd); - }); + OPENVPN_ASYNC_HANDLER; + self->handle_read(std::move(tunfrom), error, bytes_recvd); + }); } void handle_read(typename PacketFrom::SPtr pfp, const openvpn_io::error_code &error, const size_t bytes_recvd) diff --git a/openvpn/ws/httpcli.hpp b/openvpn/ws/httpcli.hpp index b52547c2..a9d3e124 100644 --- a/openvpn/ws/httpcli.hpp +++ b/openvpn/ws/httpcli.hpp @@ -709,8 +709,8 @@ class HTTPCore : public Base, public TransportClientParent s->socket.async_connect(ep, [self = Ptr(this)](const openvpn_io::error_code &error) { - self->handle_unix_connect(error); - }); + self->handle_unix_connect(error); + }); set_connect_timeout(config->connect_timeout); return; } diff --git a/test/unittests/test_openssl_authcert.cpp b/test/unittests/test_openssl_authcert.cpp index 558351f5..37d88d4f 100644 --- a/test/unittests/test_openssl_authcert.cpp +++ b/test/unittests/test_openssl_authcert.cpp @@ -272,65 +272,25 @@ TEST(authcert_openssl, serial_parse) // failure cases - JY_EXPECT_THROW({ - const AuthCert::Serial ser(""); - }, - AuthCert::Serial::serial_number_error, - "expected leading serial number hex digit"); + JY_EXPECT_THROW({ const AuthCert::Serial ser(""); }, AuthCert::Serial::serial_number_error, "expected leading serial number hex digit"); - JY_EXPECT_THROW({ - const AuthCert::Serial ser(" "); - }, - AuthCert::Serial::serial_number_error, - "' ' is not a hex char"); + JY_EXPECT_THROW({ const AuthCert::Serial ser(" "); }, AuthCert::Serial::serial_number_error, "' ' is not a hex char"); - JY_EXPECT_THROW({ - const AuthCert::Serial ser(":"); - }, - AuthCert::Serial::serial_number_error, - "spurious colon"); + JY_EXPECT_THROW({ const AuthCert::Serial ser(":"); }, AuthCert::Serial::serial_number_error, "spurious colon"); - JY_EXPECT_THROW({ - const AuthCert::Serial ser(":aa"); - }, - AuthCert::Serial::serial_number_error, - "expected leading serial number hex digit"); + JY_EXPECT_THROW({ const AuthCert::Serial ser(":aa"); }, AuthCert::Serial::serial_number_error, "expected leading serial number hex digit"); - JY_EXPECT_THROW({ - const AuthCert::Serial ser("aa:"); - }, - AuthCert::Serial::serial_number_error, - "spurious colon"); + JY_EXPECT_THROW({ const AuthCert::Serial ser("aa:"); }, AuthCert::Serial::serial_number_error, "spurious colon"); - JY_EXPECT_THROW({ - const AuthCert::Serial ser("x"); - }, - AuthCert::Serial::serial_number_error, - "'x' is not a hex char"); + JY_EXPECT_THROW({ const AuthCert::Serial ser("x"); }, AuthCert::Serial::serial_number_error, "'x' is not a hex char"); - JY_EXPECT_THROW({ - const AuthCert::Serial ser("1:2:3x:4"); - }, - AuthCert::Serial::serial_number_error, - "'x' is not a hex char"); + JY_EXPECT_THROW({ const AuthCert::Serial ser("1:2:3x:4"); }, AuthCert::Serial::serial_number_error, "'x' is not a hex char"); - JY_EXPECT_THROW({ - const AuthCert::Serial ser("aa::bb"); - }, - AuthCert::Serial::serial_number_error, - "spurious colon"); + JY_EXPECT_THROW({ const AuthCert::Serial ser("aa::bb"); }, AuthCert::Serial::serial_number_error, "spurious colon"); - JY_EXPECT_THROW({ - const AuthCert::Serial ser("11:22:33:44:55:66:77:88:99:aa:BB:cc:dd:ee:ff:00:0f:1f:2f:3f:4f"); - }, - AuthCert::Serial::serial_number_error, - "serial number too large (C2)"); + JY_EXPECT_THROW({ const AuthCert::Serial ser("11:22:33:44:55:66:77:88:99:aa:BB:cc:dd:ee:ff:00:0f:1f:2f:3f:4f"); }, AuthCert::Serial::serial_number_error, "serial number too large (C2)"); - JY_EXPECT_THROW({ - const AuthCert::Serial ser("112233445566778899aaBBccddeeff000f1f2f3ff"); - }, - AuthCert::Serial::serial_number_error, - "serial number too large (C2)"); + JY_EXPECT_THROW({ const AuthCert::Serial ser("112233445566778899aaBBccddeeff000f1f2f3ff"); }, AuthCert::Serial::serial_number_error, "serial number too large (C2)"); } #ifdef OPENVPN_JSON_INTERNAL @@ -353,10 +313,7 @@ TEST(authcert_openssl, sn_json_type_err) { JY_EXPECT_THROW({ const Json::Value jv; - const AuthCert::Serial ser(jv); - }, - AuthCert::Serial::serial_number_error, - "JSON serial is missing"); + const AuthCert::Serial ser(jv); }, AuthCert::Serial::serial_number_error, "JSON serial is missing"); } #endif