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

Optimize error translation code size

Introducing an intermediate function
saves code size that's otherwise taken by excessive,
repeated arguments in each place that
was translating errors.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
This commit is contained in:
Andrzej Kurek
2023-05-30 05:45:00 -04:00
parent 14f65a47c8
commit 0064484a70
12 changed files with 116 additions and 40 deletions

View File

@ -51,12 +51,23 @@
#endif
#if defined(MBEDTLS_USE_PSA_CRYPTO)
#define PSA_TO_MBEDTLS_ERR(status) PSA_TO_MBEDTLS_ERR_LIST(status, \
psa_to_ssl_errors, \
psa_generic_status_to_mbedtls)
#define PSA_TO_MD_ERR(status) PSA_TO_MBEDTLS_ERR_LIST(status, \
psa_to_md_errors, \
psa_generic_status_to_mbedtls)
/* Define local translating functions to save code size by not using too many
* arguments in each translating place. */
static int local_err_translation(psa_status_t status)
{
return psa_status_to_mbedtls(status, psa_to_ssl_errors,
sizeof(psa_to_ssl_errors),
psa_generic_status_to_mbedtls);
}
#define PSA_TO_MBEDTLS_ERR(status) local_err_translation(status)
static int local_md_translation(psa_status_t status)
{
return psa_status_to_mbedtls(status, psa_to_md_errors,
sizeof(psa_to_md_errors),
psa_generic_status_to_mbedtls);
}
#define PSA_TO_MD_ERR(status) local_md_translation(status)
#endif
#if defined(MBEDTLS_TEST_HOOKS)