mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
This commit is contained in:
parent
07bc4e2f96
commit
0ee0fa42e6
683 changed files with 22803 additions and 12225 deletions
|
|
@ -35,8 +35,9 @@
|
|||
#include "core/os/file_access.h"
|
||||
|
||||
int PacketPeerMbedDTLS::bio_send(void *ctx, const unsigned char *buf, size_t len) {
|
||||
if (buf == nullptr || len <= 0)
|
||||
if (buf == nullptr || len <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PacketPeerMbedDTLS *sp = (PacketPeerMbedDTLS *)ctx;
|
||||
|
||||
|
|
@ -52,8 +53,9 @@ int PacketPeerMbedDTLS::bio_send(void *ctx, const unsigned char *buf, size_t len
|
|||
}
|
||||
|
||||
int PacketPeerMbedDTLS::bio_recv(void *ctx, unsigned char *buf, size_t len) {
|
||||
if (buf == nullptr || len <= 0)
|
||||
if (buf == nullptr || len <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PacketPeerMbedDTLS *sp = (PacketPeerMbedDTLS *)ctx;
|
||||
|
||||
|
|
@ -167,8 +169,9 @@ Error PacketPeerMbedDTLS::accept_peer(Ref<PacketPeerUDP> p_base, Ref<CryptoKey>
|
|||
Error PacketPeerMbedDTLS::put_packet(const uint8_t *p_buffer, int p_bytes) {
|
||||
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_UNCONFIGURED);
|
||||
|
||||
if (p_bytes == 0)
|
||||
if (p_bytes == 0) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int ret = mbedtls_ssl_write(ssl_ctx->get_context(), p_buffer, p_bytes);
|
||||
if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) {
|
||||
|
|
@ -251,15 +254,16 @@ PacketPeerMbedDTLS::~PacketPeerMbedDTLS() {
|
|||
}
|
||||
|
||||
void PacketPeerMbedDTLS::disconnect_from_peer() {
|
||||
if (status != STATUS_CONNECTED && status != STATUS_HANDSHAKING)
|
||||
if (status != STATUS_CONNECTED && status != STATUS_HANDSHAKING) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (status == STATUS_CONNECTED) {
|
||||
int ret = 0;
|
||||
// Send SSL close notification, blocking, but ignore other errors.
|
||||
do
|
||||
do {
|
||||
ret = mbedtls_ssl_close_notify(ssl_ctx->get_context());
|
||||
while (ret == MBEDTLS_ERR_SSL_WANT_WRITE);
|
||||
} while (ret == MBEDTLS_ERR_SSL_WANT_WRITE);
|
||||
}
|
||||
|
||||
_cleanup();
|
||||
|
|
|
|||
|
|
@ -67,8 +67,9 @@ Error CookieContextMbedTLS::setup() {
|
|||
}
|
||||
|
||||
void CookieContextMbedTLS::clear() {
|
||||
if (!inited)
|
||||
if (!inited) {
|
||||
return;
|
||||
}
|
||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||
mbedtls_entropy_free(&entropy);
|
||||
mbedtls_ssl_cookie_free(&cookie_ctx);
|
||||
|
|
@ -120,10 +121,12 @@ Error SSLContextMbedTLS::init_server(int p_transport, int p_authmode, Ref<Crypto
|
|||
// Locking key and certificate(s)
|
||||
pkey = p_pkey;
|
||||
certs = p_cert;
|
||||
if (pkey.is_valid())
|
||||
if (pkey.is_valid()) {
|
||||
pkey->lock();
|
||||
if (certs.is_valid())
|
||||
}
|
||||
if (certs.is_valid()) {
|
||||
certs->lock();
|
||||
}
|
||||
|
||||
// Adding key and certificate
|
||||
int ret = mbedtls_ssl_conf_own_cert(&conf, &(certs->cert), &(pkey->pkey));
|
||||
|
|
@ -175,19 +178,22 @@ Error SSLContextMbedTLS::init_client(int p_transport, int p_authmode, Ref<X509Ce
|
|||
}
|
||||
|
||||
void SSLContextMbedTLS::clear() {
|
||||
if (!inited)
|
||||
if (!inited) {
|
||||
return;
|
||||
}
|
||||
mbedtls_ssl_free(&ssl);
|
||||
mbedtls_ssl_config_free(&conf);
|
||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||
mbedtls_entropy_free(&entropy);
|
||||
|
||||
// Unlock and key and certificates
|
||||
if (certs.is_valid())
|
||||
if (certs.is_valid()) {
|
||||
certs->unlock();
|
||||
}
|
||||
certs = Ref<X509Certificate>();
|
||||
if (pkey.is_valid())
|
||||
if (pkey.is_valid()) {
|
||||
pkey->unlock();
|
||||
}
|
||||
pkey = Ref<CryptoKeyMbedTLS>();
|
||||
cookies = Ref<CookieContextMbedTLS>();
|
||||
inited = false;
|
||||
|
|
|
|||
|
|
@ -34,8 +34,9 @@
|
|||
#include "core/os/file_access.h"
|
||||
|
||||
int StreamPeerMbedTLS::bio_send(void *ctx, const unsigned char *buf, size_t len) {
|
||||
if (buf == nullptr || len <= 0)
|
||||
if (buf == nullptr || len <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
StreamPeerMbedTLS *sp = (StreamPeerMbedTLS *)ctx;
|
||||
|
||||
|
|
@ -53,8 +54,9 @@ int StreamPeerMbedTLS::bio_send(void *ctx, const unsigned char *buf, size_t len)
|
|||
}
|
||||
|
||||
int StreamPeerMbedTLS::bio_recv(void *ctx, unsigned char *buf, size_t len) {
|
||||
if (buf == nullptr || len <= 0)
|
||||
if (buf == nullptr || len <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
StreamPeerMbedTLS *sp = (StreamPeerMbedTLS *)ctx;
|
||||
|
||||
|
|
@ -167,8 +169,9 @@ Error StreamPeerMbedTLS::put_partial_data(const uint8_t *p_data, int p_bytes, in
|
|||
|
||||
r_sent = 0;
|
||||
|
||||
if (p_bytes == 0)
|
||||
if (p_bytes == 0) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int ret = mbedtls_ssl_write(ssl_ctx->get_context(), p_data, p_bytes);
|
||||
if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) {
|
||||
|
|
@ -279,8 +282,9 @@ StreamPeerMbedTLS::~StreamPeerMbedTLS() {
|
|||
}
|
||||
|
||||
void StreamPeerMbedTLS::disconnect_from_stream() {
|
||||
if (status != STATUS_CONNECTED && status != STATUS_HANDSHAKING)
|
||||
if (status != STATUS_CONNECTED && status != STATUS_HANDSHAKING) {
|
||||
return;
|
||||
}
|
||||
|
||||
Ref<StreamPeerTCP> tcp = base;
|
||||
if (tcp.is_valid() && tcp->get_status() == StreamPeerTCP::STATUS_CONNECTED) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue