From e9b55929dc80d5b45292e9a715111505f454a267 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 15 Sep 2022 20:09:07 +0200 Subject: [PATCH] Remove useless platform macro redefinitions: automatic part Some source files had code to set mbedtls_xxx aliases when MBEDTLS_PLATFORM_C is not defined. These aliases are defined unconditionally by mbedtls/platform.h, so these macro definitions were redundant. Remove them. This commit used the following code: ``` perl -i -0777 -pe 's~#if !defined\(MBEDTLS_PLATFORM_C\)\n(#define (mbedtls|MBEDTLS)_.*\n|#include <(stdarg|stddef|stdio|stdlib|string|time)\.h>\n)*#endif.*\n~~mg' $(git grep -l -F '#if !defined(MBEDTLS_PLATFORM_C)') ``` Signed-off-by: Gilles Peskine --- library/gcm.c | 4 ---- library/psa_crypto.c | 4 ---- library/psa_crypto_aead.c | 4 ---- library/psa_crypto_client.c | 4 ---- library/psa_crypto_ecp.c | 4 ---- library/psa_crypto_rsa.c | 4 ---- library/psa_crypto_se.c | 4 ---- programs/test/benchmark.c | 7 ------- 8 files changed, 35 deletions(-) diff --git a/library/gcm.c b/library/gcm.c index 6d07f8787..fca0c6129 100644 --- a/library/gcm.c +++ b/library/gcm.c @@ -44,10 +44,6 @@ #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C) #include "mbedtls/aes.h" #include "mbedtls/platform.h" -#if !defined(MBEDTLS_PLATFORM_C) -#include -#define mbedtls_printf printf -#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */ #if !defined(MBEDTLS_GCM_ALT) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index b0116ddfb..954abea59 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -52,10 +52,6 @@ #include #include #include "mbedtls/platform.h" -#if !defined(MBEDTLS_PLATFORM_C) -#define mbedtls_calloc calloc -#define mbedtls_free free -#endif #include "mbedtls/aes.h" #include "mbedtls/asn1.h" diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 714d950a1..76d95bcc6 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -27,10 +27,6 @@ #include #include "mbedtls/platform.h" -#if !defined(MBEDTLS_PLATFORM_C) -#define mbedtls_calloc calloc -#define mbedtls_free free -#endif #include "mbedtls/ccm.h" #include "mbedtls/chachapoly.h" diff --git a/library/psa_crypto_client.c b/library/psa_crypto_client.c index 629feb7df..ab7908634 100644 --- a/library/psa_crypto_client.c +++ b/library/psa_crypto_client.c @@ -25,10 +25,6 @@ #include #include "mbedtls/platform.h" -#if !defined(MBEDTLS_PLATFORM_C) -#define mbedtls_calloc calloc -#define mbedtls_free free -#endif void psa_reset_key_attributes( psa_key_attributes_t *attributes ) { diff --git a/library/psa_crypto_ecp.c b/library/psa_crypto_ecp.c index 59c3a0e9a..29f53b96e 100644 --- a/library/psa_crypto_ecp.c +++ b/library/psa_crypto_ecp.c @@ -31,10 +31,6 @@ #include #include #include "mbedtls/platform.h" -#if !defined(MBEDTLS_PLATFORM_C) -#define mbedtls_calloc calloc -#define mbedtls_free free -#endif #include #include diff --git a/library/psa_crypto_rsa.c b/library/psa_crypto_rsa.c index 7d4718daf..f1b9809d8 100644 --- a/library/psa_crypto_rsa.c +++ b/library/psa_crypto_rsa.c @@ -32,10 +32,6 @@ #include #include #include "mbedtls/platform.h" -#if !defined(MBEDTLS_PLATFORM_C) -#define mbedtls_calloc calloc -#define mbedtls_free free -#endif #include #include diff --git a/library/psa_crypto_se.c b/library/psa_crypto_se.c index 56678d6a9..87d2634e7 100644 --- a/library/psa_crypto_se.c +++ b/library/psa_crypto_se.c @@ -38,10 +38,6 @@ #endif #include "mbedtls/platform.h" -#if !defined(MBEDTLS_PLATFORM_C) -#define mbedtls_calloc calloc -#define mbedtls_free free -#endif diff --git a/programs/test/benchmark.c b/programs/test/benchmark.c index a6d83e75b..920a473c6 100644 --- a/programs/test/benchmark.c +++ b/programs/test/benchmark.c @@ -22,13 +22,6 @@ #include "mbedtls/build_info.h" #include "mbedtls/platform.h" -#if !defined(MBEDTLS_PLATFORM_C) -#include -#include -#define mbedtls_exit exit -#define mbedtls_printf printf -#define mbedtls_free free -#endif #if !defined(MBEDTLS_HAVE_TIME) int main( void )