1
0
mirror of https://github.com/ARMmbed/mbedtls.git synced 2025-05-11 17:32:34 +08:00

ssl_helpers.c: improve code readability

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
This commit is contained in:
Yanray Wang 2023-03-13 19:22:36 +08:00
parent 3463435ec5
commit af727a28c9
2 changed files with 14 additions and 16 deletions

View File

@ -317,16 +317,16 @@ int mbedtls_test_mock_socket_connect(mbedtls_test_mock_socket *peer1,
/*
* Callbacks for simulating blocking I/O over connection-oriented transport.
*/
int mbedtls_test_mock_tcp_send_b(void *ctx, const unsigned char *buf,
size_t len);
int mbedtls_test_mock_tcp_send_b(void *ctx,
const unsigned char *buf, size_t len);
int mbedtls_test_mock_tcp_recv_b(void *ctx, unsigned char *buf, size_t len);
/*
* Callbacks for simulating non-blocking I/O over connection-oriented transport.
*/
int mbedtls_test_mock_tcp_send_nb(void *ctx, const unsigned char *buf,
size_t len);
int mbedtls_test_mock_tcp_send_nb(void *ctx,
const unsigned char *buf, size_t len);
int mbedtls_test_mock_tcp_recv_nb(void *ctx, unsigned char *buf, size_t len);
@ -368,8 +368,8 @@ void mbedtls_test_message_socket_close(
* This function will also return any error from
* mbedtls_test_ssl_message_queue_push_info.
*/
int mbedtls_test_mock_tcp_send_msg(void *ctx, const unsigned char *buf,
size_t len);
int mbedtls_test_mock_tcp_send_msg(void *ctx,
const unsigned char *buf, size_t len);
/*
* Receive one message from a given message socket context and return message
@ -385,8 +385,8 @@ int mbedtls_test_mock_tcp_send_msg(void *ctx, const unsigned char *buf,
* MBEDTLS_TEST_ERROR_MESSAGE_TRUNCATED from
* mbedtls_test_message_queue_peek_info.
*/
int mbedtls_test_mock_tcp_recv_msg(void *ctx, unsigned char *buf,
size_t buf_len);
int mbedtls_test_mock_tcp_recv_msg(void *ctx,
unsigned char *buf, size_t buf_len);
#if defined(MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED)

View File

@ -405,8 +405,8 @@ exit:
return ret;
}
int mbedtls_test_mock_tcp_send_b(void *ctx, const unsigned char *buf,
size_t len)
int mbedtls_test_mock_tcp_send_b(void *ctx,
const unsigned char *buf, size_t len)
{
mbedtls_test_mock_socket *socket = (mbedtls_test_mock_socket *) ctx;
@ -561,8 +561,8 @@ int mbedtls_test_mock_tcp_recv_msg(void *ctx,
if (ret == MBEDTLS_TEST_ERROR_MESSAGE_TRUNCATED) {
/* Drop the remaining part of the message */
if (mbedtls_test_mock_tcp_recv_b(socket, NULL, drop_len)
!= (int) drop_len) {
if (mbedtls_test_mock_tcp_recv_b(socket, NULL, drop_len) !=
(int) drop_len) {
/* Inconsistent state - part of the message was read,
* and a part couldn't. Not much we can do here, but it should not
* happen in test environment, unless forced manually. */
@ -2106,11 +2106,9 @@ void mbedtls_test_ssl_perform_handshake(
exit:
mbedtls_test_ssl_endpoint_free(&client,
options->dtls != 0 ?
&client_context : NULL);
options->dtls != 0 ? &client_context : NULL);
mbedtls_test_ssl_endpoint_free(&server,
options->dtls != 0 ?
&server_context : NULL);
options->dtls != 0 ? &server_context : NULL);
#if defined(MBEDTLS_DEBUG_C)
if (options->cli_log_fun || options->srv_log_fun) {
mbedtls_debug_set_threshold(0);