From a02b36886cdc97f7e1615380cddafcbe273616de Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Fri, 14 Jul 2023 13:43:39 +0100 Subject: [PATCH] Fix gcc warnings when -Wredundant-decls set Signed-off-by: Dave Rodgman --- include/mbedtls/constant_time.h | 8 ++++++++ library/constant_time_internal.h | 13 ++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/mbedtls/constant_time.h b/include/mbedtls/constant_time.h index 91a9e7fc3..2d33adc88 100644 --- a/include/mbedtls/constant_time.h +++ b/include/mbedtls/constant_time.h @@ -23,6 +23,10 @@ #include +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wredundant-decls" +#endif /** Constant-time buffer comparison without branches. * @@ -43,4 +47,8 @@ int mbedtls_ct_memcmp(const void *a, const void *b, size_t n); +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif + #endif /* MBEDTLS_CONSTANT_TIME_H */ diff --git a/library/constant_time_internal.h b/library/constant_time_internal.h index 966075816..f0fde6a71 100644 --- a/library/constant_time_internal.h +++ b/library/constant_time_internal.h @@ -92,9 +92,16 @@ typedef int32_t mbedtls_ct_int_t; /* constant_time_impl.h contains all the static inline implementations, * so that constant_time_internal.h is more readable. + * + * gcc generates warnings about duplicate declarations, so disable this + * warning. */ -#include "constant_time_impl.h" +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wredundant-decls" +#endif +#include "constant_time_impl.h" /* ============================================================================ * Boolean operations @@ -473,4 +480,8 @@ int mbedtls_ct_memcmp(const void *a, const void *b, size_t n); +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif + #endif /* MBEDTLS_CONSTANT_TIME_INTERNAL_H */