From e35f8f6a770f5f994e9ada6b95c5b474331bc6f9 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Wed, 4 Aug 2021 15:38:09 +0200 Subject: [PATCH] Move MBEDTLS_CHECK_RETURN to platform_util. Signed-off-by: Mateusz Starzyk --- include/mbedtls/aes.h | 1 + include/mbedtls/build_info.h | 18 ------------------ include/mbedtls/des.h | 1 + include/mbedtls/platform_util.h | 20 ++++++++++++++++++++ 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/include/mbedtls/aes.h b/include/mbedtls/aes.h index eb75935c1f..5c07b912d9 100644 --- a/include/mbedtls/aes.h +++ b/include/mbedtls/aes.h @@ -42,6 +42,7 @@ #include "mbedtls/private_access.h" #include "mbedtls/build_info.h" +#include "mbedtls/platform_util.h" #include #include diff --git a/include/mbedtls/build_info.h b/include/mbedtls/build_info.h index 46717608be..23f85ba01e 100644 --- a/include/mbedtls/build_info.h +++ b/include/mbedtls/build_info.h @@ -53,24 +53,6 @@ #define _CRT_SECURE_NO_DEPRECATE 1 #endif -/** \def MBEDTLS_CHECK_RETURN - * - * This macro appearing at the beginning of the declaration of a function - * indicates that its return value should be checked. - * - * This should appear before most functions returning an error code - * (as \c int in the \c mbedtls_xxx API or - * as ::psa_status_t in the \c psa_xxx API). - */ -#if defined(__GNUC__) -#define MBEDTLS_CHECK_RETURN __attribute__((warn_unused_result)) -#elif defined(_MSC_VER) && _MSC_VER >= 1700 -#include -#define MBEDTLS_CHECK_RETURN _Check_return_ -#else -#define MBEDTLS_CHECK_RETURN -#endif - #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/mbedtls_config.h" #else diff --git a/include/mbedtls/des.h b/include/mbedtls/des.h index 7bd618c276..d5289d3fc1 100644 --- a/include/mbedtls/des.h +++ b/include/mbedtls/des.h @@ -29,6 +29,7 @@ #include "mbedtls/private_access.h" #include "mbedtls/build_info.h" +#include "mbedtls/platform_util.h" #include #include diff --git a/include/mbedtls/platform_util.h b/include/mbedtls/platform_util.h index 1a0a13513e..9c64cfd162 100644 --- a/include/mbedtls/platform_util.h +++ b/include/mbedtls/platform_util.h @@ -60,6 +60,26 @@ MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t; #endif /* MBEDTLS_DEPRECATED_WARNING */ #endif /* MBEDTLS_DEPRECATED_REMOVED */ +/** \def MBEDTLS_CHECK_RETURN + * + * This macro appearing at the beginning of the declaration of a function + * indicates that its return value should be checked. + * + * This should appear before most functions returning an error code + * (as \c int in the \c mbedtls_xxx API or + * as ::psa_status_t in the \c psa_xxx API). + */ +#if !defined(MBEDTLS_CHECK_RETURN) +#if defined(__GNUC__) +#define MBEDTLS_CHECK_RETURN __attribute__((warn_unused_result)) +#elif defined(_MSC_VER) && _MSC_VER >= 1700 +#include +#define MBEDTLS_CHECK_RETURN _Check_return_ +#else +#define MBEDTLS_CHECK_RETURN +#endif +#endif + /** * \brief Securely zeroize a buffer *