CI: fixing the files to be complient with pre-commit hooks

This commit is contained in:
Suren Gabrielyan
2022-10-11 16:31:57 +02:00
parent 9d45d505d5
commit 945bd17701
205 changed files with 3130 additions and 3441 deletions

View File

@ -4,7 +4,7 @@
//
// SPDX-License-Identifier: BSL-1.0
//
// SPDX-FileContributor: 2021 Espressif Systems (Shanghai) CO LTD
// SPDX-FileContributor: 2021-2022 Espressif Systems (Shanghai) CO LTD
//
#include "asio/detail/config.hpp"
@ -22,19 +22,19 @@ namespace ssl {
context::context(context::method m)
: handle_(0)
: handle_(0)
{
handle_ = mbedtls::shared_ctx::create("mbedtls-context", m);
set_options(no_compression);
}
context::context(context&& other)
context::context(context &&other)
{
handle_ = other.handle_;
other.handle_ = 0;
}
context& context::operator=(context&& other)
context &context::operator=(context &&other)
{
context tmp(ASIO_MOVE_CAST(context)(*this));
handle_ = other.handle_;
@ -60,14 +60,14 @@ void context::set_options(context::options o)
}
ASIO_SYNC_OP_VOID context::set_options(
context::options o, asio::error_code& ec)
context::options o, asio::error_code &ec)
{
handle_->get()->options_ = o;
ec = asio::error_code();
ASIO_SYNC_OP_VOID_RETURN(ec);
}
void context::add_certificate_authority(const const_buffer& ca)
void context::add_certificate_authority(const const_buffer &ca)
{
asio::error_code ec;
add_certificate_authority(ca, ec);
@ -75,13 +75,13 @@ void context::add_certificate_authority(const const_buffer& ca)
}
ASIO_SYNC_OP_VOID context::add_certificate_authority(
const const_buffer& ca, asio::error_code& ec)
const const_buffer &ca, asio::error_code &ec)
{
handle_->get()->ca_cert_ = ca;
ASIO_SYNC_OP_VOID_RETURN(asio::error_code());
}
void context::use_certificate_chain(const const_buffer& chain)
void context::use_certificate_chain(const const_buffer &chain)
{
asio::error_code ec;
use_certificate_chain(chain, ec);
@ -89,14 +89,14 @@ void context::use_certificate_chain(const const_buffer& chain)
}
ASIO_SYNC_OP_VOID context::use_certificate_chain(
const const_buffer& chain, asio::error_code& ec)
const const_buffer &chain, asio::error_code &ec)
{
handle_->get()->cert_chain_ = chain;
ASIO_SYNC_OP_VOID_RETURN(asio::error_code());
}
void context::use_private_key(
const const_buffer& private_key, context::file_format format)
const const_buffer &private_key, context::file_format format)
{
asio::error_code ec;
use_private_key(private_key, format, ec);
@ -104,8 +104,8 @@ void context::use_private_key(
}
ASIO_SYNC_OP_VOID context::use_private_key(
const const_buffer& private_key, context::file_format format,
asio::error_code& ec)
const const_buffer &private_key, context::file_format format,
asio::error_code &ec)
{
handle_->get()->private_key_ = private_key;
ASIO_SYNC_OP_VOID_RETURN(asio::error_code());

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: BSL-1.0
//
// SPDX-FileContributor: 2021 Espressif Systems (Shanghai) CO LTD
// SPDX-FileContributor: 2021-2022 Espressif Systems (Shanghai) CO LTD
//
#include "asio/detail/config.hpp"
@ -24,8 +24,8 @@ namespace ssl {
namespace detail {
engine::engine(SSL_CTX* context)
: ssl_(nullptr)
engine::engine(SSL_CTX *context)
: ssl_(nullptr)
{
ssl_ = mbedtls::create<mbedtls::engine>("mbedtls-engine", context->get());
}
@ -35,49 +35,47 @@ engine::~engine()
delete ssl_;
}
SSL* engine::native_handle()
SSL *engine::native_handle()
{
return ssl_;
}
asio::error_code engine::set_verify_mode(
verify_mode v, asio::error_code& ec)
verify_mode v, asio::error_code &ec)
{
ssl_->set_verify_mode(v);
return {};
}
engine::want engine::handshake(
stream_base::handshake_type type, asio::error_code& ec)
stream_base::handshake_type type, asio::error_code &ec)
{
return perform((type == asio::ssl::stream_base::client)
? &engine::do_connect : &engine::do_accept, 0, 0, ec, 0);
}
engine::want engine::shutdown(asio::error_code& ec)
engine::want engine::shutdown(asio::error_code &ec)
{
return perform(&engine::do_shutdown, 0, 0, ec, 0);
}
engine::want engine::write(const asio::const_buffer& data,
asio::error_code& ec, std::size_t& bytes_transferred)
engine::want engine::write(const asio::const_buffer &data,
asio::error_code &ec, std::size_t &bytes_transferred)
{
if (data.size() == 0)
{
if (data.size() == 0) {
ec = asio::error_code();
return engine::want_nothing;
}
return perform(&engine::do_write,
const_cast<void*>(data.data()),
const_cast<void *>(data.data()),
data.size(), ec, &bytes_transferred);
}
engine::want engine::read(const asio::mutable_buffer& data,
asio::error_code& ec, std::size_t& bytes_transferred)
engine::want engine::read(const asio::mutable_buffer &data,
asio::error_code &ec, std::size_t &bytes_transferred)
{
if (data.size() == 0)
{
if (data.size() == 0) {
ec = asio::error_code();
return engine::want_nothing;
}
@ -87,7 +85,7 @@ engine::want engine::read(const asio::mutable_buffer& data,
}
asio::mutable_buffer engine::get_output(
const asio::mutable_buffer& data)
const asio::mutable_buffer &data)
{
int length = ssl_->ext_bio()->read(data.data(), static_cast<int>(data.size()));
@ -96,7 +94,7 @@ asio::mutable_buffer engine::get_output(
}
asio::const_buffer engine::put_input(
const asio::const_buffer& data)
const asio::const_buffer &data)
{
int length = ssl_->ext_bio()->write(data.data(), static_cast<int>(data.size()));
@ -104,23 +102,22 @@ asio::const_buffer engine::put_input(
(length > 0 ? static_cast<std::size_t>(length) : 0));
}
const asio::error_code& engine::map_error_code(
asio::error_code& ec) const
const asio::error_code &engine::map_error_code(
asio::error_code &ec) const
{
// We only want to map the error::eof code.
if (ec != asio::error::eof)
if (ec != asio::error::eof) {
return ec;
}
// If there's data yet to be read, it's an error.
if (ssl_->ext_bio()->wpending())
{
if (ssl_->ext_bio()->wpending()) {
ec = asio::ssl::error::stream_truncated;
return ec;
}
// Otherwise, the peer should have negotiated a proper shutdown.
if (ssl_->shutdown() != 0)
{
if (ssl_->shutdown() != 0) {
ec = asio::ssl::error::stream_truncated;
}
@ -129,47 +126,39 @@ const asio::error_code& engine::map_error_code(
// This is a simplified implementation of a generic ssl io operation
// original implementation using openssl's SSL object is in asio/include/asio/ssl/detail/impl/engine.ipp
engine::want engine::perform(int (engine::* op)(void*, std::size_t),
void* data, std::size_t length, asio::error_code& ec,
std::size_t* bytes_transferred)
engine::want engine::perform(int (engine::* op)(void *, std::size_t),
void *data, std::size_t length, asio::error_code &ec,
std::size_t *bytes_transferred)
{
std::size_t pending_output_before = ssl_->ext_bio()->ctrl_pending();
int result = (this->*op)(data, length);
std::size_t pending_output_after = ssl_->ext_bio()->ctrl_pending();
if (mbedtls::error_codes::is_error(result))
{
if (mbedtls::error_codes::is_error(result)) {
ec = asio::error_code(result, asio::error::get_mbedtls_category());
return pending_output_after > pending_output_before ? want_output : want_nothing;
}
if (result == 0)
{
if (result == 0) {
return pending_output_after > pending_output_before
? want_output : want_nothing;
}
if (result > 0 && bytes_transferred)
if (result > 0 && bytes_transferred) {
*bytes_transferred = static_cast<std::size_t>(result);
}
if (mbedtls::error_codes::want_write(result))
{
if (mbedtls::error_codes::want_write(result)) {
ec = asio::error_code();
return want_output_and_retry;
}
else if (pending_output_after > pending_output_before)
{
} else if (pending_output_after > pending_output_before) {
ec = asio::error_code();
return result > 0 ? want_output : want_output_and_retry;
}
else if (mbedtls::error_codes::want_read(result))
{
} else if (mbedtls::error_codes::want_read(result)) {
ec = asio::error_code();
return want_input_and_retry;
}
else if (ssl_->get_state() == mbedtls::CLOSED)
{
} else if (ssl_->get_state() == mbedtls::CLOSED) {
ec = asio::error::eof;
return want_nothing;
}
@ -178,27 +167,27 @@ engine::want engine::perform(int (engine::* op)(void*, std::size_t),
return want_nothing;
}
int engine::do_accept(void*, std::size_t)
int engine::do_accept(void *, std::size_t)
{
return ssl_->accept();
}
int engine::do_connect(void*, std::size_t)
int engine::do_connect(void *, std::size_t)
{
return ssl_->connect();
}
int engine::do_shutdown(void*, std::size_t)
int engine::do_shutdown(void *, std::size_t)
{
return ssl_->shutdown();
}
int engine::do_read(void* data, std::size_t length)
int engine::do_read(void *data, std::size_t length)
{
return ssl_->read(data, length < INT_MAX ? static_cast<int>(length) : INT_MAX);
}
int engine::do_write(void* data, std::size_t length)
int engine::do_write(void *data, std::size_t length)
{
return ssl_->write(data, length < INT_MAX ? static_cast<int>(length) : INT_MAX);
}