1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

Rewrite error addition interface

The previous implementation of the error addition interface did not comply
with the invasive testing architecture guidelines. This commit fixes that
by:

- Renaming functions/macros/variables to follow the mbedtls_error_xxx or
  mbedtls_test_hook_xxx convention.

- Making mbedtls_test_hook_error_add a global variable that can be set
  by the testing code.

- Using a static inline function call, as opposed to macro, to keep
  discrepancies between debug and production version to a minimum.

Signed-off-by: Chris Jones <christopher.jones@arm.com>
This commit is contained in:
Chris Jones
2021-04-01 16:00:01 +01:00
parent ac33a3ab12
commit 7439209bcc
5 changed files with 51 additions and 63 deletions

View File

@ -82,22 +82,6 @@ LOW_LEVEL_CODE_CHECKS
return( NULL );
}
#if defined(MBEDTLS_TEST_HOOKS)
static void (*err_add_hook)( int, int, const char *, int );
void mbedtls_set_err_add_hook( void (*hook)( int, int, const char *, int ) )
{
err_add_hook = hook;
}
int mbedtls_err_add( int high, int low, const char *file, int line )
{
if( err_add_hook != NULL )
(*err_add_hook)( high, low, file, line );
return ( high + low );
}
#endif /* MBEDTLS_TEST_HOOKS */
void mbedtls_strerror( int ret, char *buf, size_t buflen )
{
size_t len;