Bug 1331349 Fix printf formatting errors in MinGW compilation r=froydnj

MozReview-Commit-ID: A4PMABfxzez

--HG--
extra : rebase_source : d0c40a495ad390aeb71ddc81c33daa081f6e0ba7
This commit is contained in:
Tom Ritter 2017-03-31 00:14:43 -05:00
Родитель 3cf49afb27
Коммит fcb35c70f7
4 изменённых файлов: 21 добавлений и 6 удалений

Просмотреть файл

@ -852,7 +852,7 @@ ProtectPages(void* p, size_t size)
#if defined(XP_WIN)
DWORD oldProtect;
if (!VirtualProtect(p, size, PAGE_NOACCESS, &oldProtect)) {
MOZ_CRASH_UNSAFE_PRINTF("VirtualProtect(PAGE_NOACCESS) failed! Error code: %u",
MOZ_CRASH_UNSAFE_PRINTF("VirtualProtect(PAGE_NOACCESS) failed! Error code: %lu",
GetLastError());
}
MOZ_ASSERT(oldProtect == PAGE_READWRITE);
@ -871,7 +871,7 @@ MakePagesReadOnly(void* p, size_t size)
#if defined(XP_WIN)
DWORD oldProtect;
if (!VirtualProtect(p, size, PAGE_READONLY, &oldProtect)) {
MOZ_CRASH_UNSAFE_PRINTF("VirtualProtect(PAGE_READONLY) failed! Error code: %u",
MOZ_CRASH_UNSAFE_PRINTF("VirtualProtect(PAGE_READONLY) failed! Error code: %lu",
GetLastError());
}
MOZ_ASSERT(oldProtect == PAGE_READWRITE);
@ -890,7 +890,7 @@ UnprotectPages(void* p, size_t size)
#if defined(XP_WIN)
DWORD oldProtect;
if (!VirtualProtect(p, size, PAGE_READWRITE, &oldProtect)) {
MOZ_CRASH_UNSAFE_PRINTF("VirtualProtect(PAGE_READWRITE) failed! Error code: %u",
MOZ_CRASH_UNSAFE_PRINTF("VirtualProtect(PAGE_READWRITE) failed! Error code: %lu",
GetLastError());
}
MOZ_ASSERT(oldProtect == PAGE_NOACCESS || oldProtect == PAGE_READONLY);

Просмотреть файл

@ -97,7 +97,9 @@ int __android_log_write(int prio, const char *tag, const char *text);
* Send a formatted string to the log, used like printf(fmt,...)
*/
int __android_log_print(int prio, const char *tag, const char *fmt, ...)
#if defined(__GNUC__)
#if defined(__MINGW32__)
__attribute__ ((format(__MINGW_PRINTF_FORMAT, 3, 4)))
#elif defined(__GNUC__)
__attribute__ ((format(printf, 3, 4)))
#endif
;

Просмотреть файл

@ -64,7 +64,12 @@ public:
static inline const String8 empty();
static String8 format(const char* fmt, ...) __attribute__((format (printf, 1, 2)));
static String8 format(const char* fmt, ...)
#ifdef __MINGW32__
__attribute__((format (__MINGW_PRINTF_FORMAT, 1, 2)));
#else
__attribute__((format (printf, 1, 2)));
#endif
static String8 formatV(const char* fmt, va_list args);
inline const char* string() const;

Просмотреть файл

@ -631,8 +631,16 @@
* printf-likes, and in particular this should not be used for
* PR_snprintf and friends, which are "printf-like" but which assign
* different meanings to the various formats.
*
* MinGW requires special handling due to different format specifiers
* on different platforms. The macro __MINGW_PRINTF_FORMAT maps to
* either gnu_printf or ms_printf depending on where we are compiling
* to avoid warnings on format specifiers that are legal.
*/
#ifdef __GNUC__
#ifdef __MINGW32__
#define MOZ_FORMAT_PRINTF(stringIndex, firstToCheck) \
__attribute__ ((format (__MINGW_PRINTF_FORMAT, stringIndex, firstToCheck)))
#elif __GNUC__
#define MOZ_FORMAT_PRINTF(stringIndex, firstToCheck) \
__attribute__ ((format (printf, stringIndex, firstToCheck)))
#else