modify proc_chk macros

- change the parameter
- remove debug output
- remove return value modify

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
This commit is contained in:
Jerry Yu 2021-09-02 13:53:46 +08:00
parent 0c63af6ed6
commit 2c0fbf3405
3 changed files with 18 additions and 24 deletions

View File

@ -26,7 +26,6 @@
#include "mbedtls/ssl.h"
#include "mbedtls/cipher.h"
#include "mbedtls/debug.h"
#if defined(MBEDTLS_USE_PSA_CRYPTO)
#include "psa/crypto.h"
@ -135,33 +134,25 @@
/*
* Helper macros for function call with returen check.
*/
/* utils for strip parens in marcro */
#define MBEDTLS_SSL_PROC_STRIP_PARENS( ... ) __VA_ARGS__
/*
* Exit and print debug message when return none zero value
*/
#define MBEDTLS_SSL_PROC_CHK( fn, args ) \
#define MBEDTLS_SSL_PROC_CHK( f ) \
do { \
ret = fn(MBEDTLS_SSL_PROC_STRIP_PARENS args); \
ret = ( f ); \
if( ret != 0 ) \
{ \
if( ret > 0 ) \
ret = MBEDTLS_ERR_SSL_INTERNAL_ERROR; \
MBEDTLS_SSL_DEBUG_RET( 1, #fn, ret ); \
goto cleanup; \
} \
} while( 0 )
/*
* Exit and print debug message when return negative value
*/
#define MBEDTLS_SSL_PROC_CHK_NEG( fn, args ) \
#define MBEDTLS_SSL_PROC_CHK_NEG( f ) \
do { \
ret = fn(MBEDTLS_SSL_PROC_STRIP_PARENS args); \
ret = ( f ); \
if( ret < 0 ) \
{ \
MBEDTLS_SSL_DEBUG_RET( 1, #fn, ret ); \
goto cleanup; \
} \
} while( 0 )

View File

@ -381,22 +381,25 @@ static int ssl_tls13_write_client_hello( mbedtls_ssl_context *ssl )
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write client hello" ) );
MBEDTLS_SSL_PROC_CHK( ssl_tls13_prepare_client_hello, ( ssl ) );
MBEDTLS_SSL_PROC_CHK( ssl_tls13_prepare_client_hello( ssl ) );
MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_start_handshake_msg,
( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO,
&buf, &buf_len ) );
MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_start_handshake_msg(
ssl, MBEDTLS_SSL_HS_CLIENT_HELLO,
&buf, &buf_len ) );
MBEDTLS_SSL_PROC_CHK( ssl_tls13_write_client_hello_body,
( ssl, buf, buf_len, &msg_len ) );
MBEDTLS_SSL_PROC_CHK( ssl_tls13_write_client_hello_body( ssl, buf,
buf_len,
&msg_len ) );
mbedtls_ssl_tls13_add_hs_hdr_to_checksum( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO,
mbedtls_ssl_tls13_add_hs_hdr_to_checksum( ssl,
MBEDTLS_SSL_HS_CLIENT_HELLO,
msg_len );
ssl->handshake->update_checksum( ssl, buf, msg_len );
MBEDTLS_SSL_PROC_CHK( ssl_tls13_finalize_client_hello, ( ssl ) );
MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_finish_handshake_msg,
( ssl, buf_len, msg_len ) );
MBEDTLS_SSL_PROC_CHK( ssl_tls13_finalize_client_hello( ssl ) );
MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_finish_handshake_msg( ssl,
buf_len,
msg_len ) );
cleanup:

View File

@ -57,7 +57,7 @@ int mbedtls_ssl_tls13_finish_handshake_msg( mbedtls_ssl_context *ssl,
/* Add reserved 4 bytes for handshake header */
ssl->out_msglen = msg_len + 4;
MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_write_handshake_msg_ext, ( ssl, 0 ) );
MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_write_handshake_msg_ext( ssl, 0 ) );
cleanup:
return( ret );