From 8404bdb9a6b79afe89de605fbf413b3c774bba2b Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Mon, 10 Oct 2016 14:41:44 -0400 Subject: [PATCH] Use __MINGW_PRINTF_FORMAT for printf attributes. MinGW has two different versions of printf. We want the format string warnings to match. This silences some warnings in the Android build. See: https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/ Note this assumes that, for external calls of these functions, the build configuration of the consumer and BoringSSL match in this regard. (But it doesn't actually matter because the issue is only on XP.) Change-Id: I7f12ad2fc94130edd984feac5914f8ca6c88b8d4 Reviewed-on: https://boringssl-review.googlesource.com/11572 Commit-Queue: David Benjamin Commit-Queue: Adam Langley CQ-Verified: CQ bot account: commit-bot@chromium.org Reviewed-by: Adam Langley --- include/openssl/base.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/include/openssl/base.h b/include/openssl/base.h index 888b594a..10a22ce7 100644 --- a/include/openssl/base.h +++ b/include/openssl/base.h @@ -60,6 +60,11 @@ #include #include +#if defined(__MINGW32__) +/* stdio.h is needed on MinGW for __MINGW_PRINTF_FORMAT. */ +#include +#endif + #include #if defined(BORINGSSL_PREFIX) @@ -158,8 +163,17 @@ extern "C" { #if defined(__GNUC__) +/* MinGW has two different printf implementations. Ensure the format macro + * matches the selected implementation. See + * https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/. */ +#if defined(__MINGW_PRINTF_FORMAT) #define OPENSSL_PRINTF_FORMAT_FUNC(string_index, first_to_check) \ - __attribute__((__format__(__printf__, string_index, first_to_check))) + __attribute__( \ + (__format__(__MINGW_PRINTF_FORMAT, string_index, first_to_check))) +#else +#define OPENSSL_PRINTF_FORMAT_FUNC(string_index, first_to_check) \ + __attribute__((__format__(__printf__, string_index, first_to_check))) +#endif #else #define OPENSSL_PRINTF_FORMAT_FUNC(string_index, first_to_check) #endif