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 <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
David Benjamin 2016-10-10 14:41:44 -04:00 committed by CQ bot account: commit-bot@chromium.org
parent 53a2dfcb1f
commit 8404bdb9a6

View File

@ -60,6 +60,11 @@
#include <stdint.h> #include <stdint.h>
#include <sys/types.h> #include <sys/types.h>
#if defined(__MINGW32__)
/* stdio.h is needed on MinGW for __MINGW_PRINTF_FORMAT. */
#include <stdio.h>
#endif
#include <openssl/opensslconf.h> #include <openssl/opensslconf.h>
#if defined(BORINGSSL_PREFIX) #if defined(BORINGSSL_PREFIX)
@ -158,8 +163,17 @@ extern "C" {
#if defined(__GNUC__) #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__(__MINGW_PRINTF_FORMAT, string_index, first_to_check)))
#else
#define OPENSSL_PRINTF_FORMAT_FUNC(string_index, first_to_check) \ #define OPENSSL_PRINTF_FORMAT_FUNC(string_index, first_to_check) \
__attribute__((__format__(__printf__, string_index, first_to_check))) __attribute__((__format__(__printf__, string_index, first_to_check)))
#endif
#else #else
#define OPENSSL_PRINTF_FORMAT_FUNC(string_index, first_to_check) #define OPENSSL_PRINTF_FORMAT_FUNC(string_index, first_to_check)
#endif #endif