From 15a7420d3c317604a937c3fe954f69ef73e10cc1 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 5 Aug 2021 13:56:48 +0200 Subject: [PATCH] Silence warnings about unused return value This macro is introduced here for use in deprecated functions. It may also be useful in user code, so it is in a public header. Signed-off-by: Mateusz Starzyk Signed-off-by: Gilles Peskine --- include/mbedtls/platform_util.h | 7 +++++++ library/aes.c | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/mbedtls/platform_util.h b/include/mbedtls/platform_util.h index 7e04c4f22..a90c10a4a 100644 --- a/include/mbedtls/platform_util.h +++ b/include/mbedtls/platform_util.h @@ -201,6 +201,13 @@ MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t; */ #define MBEDTLS_CHECK_RETURN_OPTIONAL +/** \def MBEDTLS_IGNORE_RETURN + * + * Silences warning about unused return value given by functions + * with \c MBEDTLS_CHECK_RETURN attribute. + */ +#define MBEDTLS_IGNORE_RETURN(result) if( result ) {} + /** * \brief Securely zeroize a buffer * diff --git a/library/aes.c b/library/aes.c index e4bcfa023..609f852d5 100644 --- a/library/aes.c +++ b/library/aes.c @@ -926,7 +926,7 @@ void mbedtls_aes_encrypt( mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16] ) { - mbedtls_internal_aes_encrypt( ctx, input, output ); + MBEDTLS_IGNORE_RETURN( mbedtls_internal_aes_encrypt( ctx, input, output ) ); } #endif /* !MBEDTLS_DEPRECATED_REMOVED */ @@ -999,7 +999,7 @@ void mbedtls_aes_decrypt( mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16] ) { - mbedtls_internal_aes_decrypt( ctx, input, output ); + MBEDTLS_IGNORE_RETURN( mbedtls_internal_aes_decrypt( ctx, input, output ) ); } #endif /* !MBEDTLS_DEPRECATED_REMOVED */