Blame SOURCES/0045-fix-Mingw-W64-32-cross-compile-failure-due-to-printf.patch

f731ee
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
f731ee
From: Andrey Borzenkov <arvidjaar@gmail.com>
f731ee
Date: Sat, 25 Jan 2014 21:49:41 +0400
f731ee
Subject: [PATCH] fix Mingw W64-32 cross compile failure due to printf
f731ee
 redefinition in libintl.h
f731ee
f731ee
In file included from util/misc.c:36:0:
f731ee
./include/grub/emu/misc.h:56:1: error: 'libintl_printf' is an unrecognized format function type [-Werror=format=]
f731ee
 char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))) WARN_UNUSED_RESULT;
f731ee
 ^
f731ee
./include/grub/emu/misc.h:58:1: error: 'libintl_printf' is an unrecognized format function type [-Werror=format=]
f731ee
f731ee
The reason is libintl.h which redefines printf as libintl_printf. The problem
f731ee
is not present in native MinGW build which avoids redefinition.  Use
f731ee
(format (__printf__) instead which is valid replacement in GCC.
f731ee
f731ee
v2: add grub-core/lib/libgcrypt/src/g10lib.h
f731ee
v3: modify g10lib.h during import
f731ee
---
f731ee
 include/grub/crypto.h   | 2 +-
f731ee
 include/grub/emu/misc.h | 8 ++++----
f731ee
 include/grub/err.h      | 2 +-
f731ee
 ChangeLog               | 9 +++++++++
f731ee
 util/import_gcry.py     | 6 ++++++
f731ee
 5 files changed, 21 insertions(+), 6 deletions(-)
f731ee
f731ee
diff --git a/include/grub/crypto.h b/include/grub/crypto.h
f731ee
index ec1b980d2ec..a24e89dd9cd 100644
f731ee
--- a/include/grub/crypto.h
f731ee
+++ b/include/grub/crypto.h
f731ee
@@ -408,7 +408,7 @@ void _gcry_assert_failed (const char *expr, const char *file, int line,
f731ee
                           const char *func) __attribute__ ((noreturn));
f731ee
 
f731ee
 void _gcry_burn_stack (int bytes);
f731ee
-void _gcry_log_error( const char *fmt, ... )  __attribute__ ((format (printf, 1, 2)));
f731ee
+void _gcry_log_error( const char *fmt, ... )  __attribute__ ((format (__printf__, 1, 2)));
f731ee
 
f731ee
 
f731ee
 #ifdef GRUB_UTIL
f731ee
diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h
f731ee
index dde48c192d3..a588ba21da2 100644
f731ee
--- a/include/grub/emu/misc.h
f731ee
+++ b/include/grub/emu/misc.h
f731ee
@@ -53,11 +53,11 @@ grub_util_device_is_mapped (const char *dev);
f731ee
 void * EXPORT_FUNC(xmalloc) (grub_size_t size) WARN_UNUSED_RESULT;
f731ee
 void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size) WARN_UNUSED_RESULT;
f731ee
 char * EXPORT_FUNC(xstrdup) (const char *str) WARN_UNUSED_RESULT;
f731ee
-char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))) WARN_UNUSED_RESULT;
f731ee
+char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2))) WARN_UNUSED_RESULT;
f731ee
 
f731ee
-void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
f731ee
-void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
f731ee
-void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2), noreturn));
f731ee
+void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2)));
f731ee
+void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2)));
f731ee
+void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2), noreturn));
f731ee
 
f731ee
 grub_uint64_t EXPORT_FUNC (grub_util_get_cpu_time_ms) (void);
f731ee
 
f731ee
diff --git a/include/grub/err.h b/include/grub/err.h
f731ee
index 9896fccf98a..1590c688e1d 100644
f731ee
--- a/include/grub/err.h
f731ee
+++ b/include/grub/err.h
f731ee
@@ -91,6 +91,6 @@ int EXPORT_FUNC(grub_error_pop) (void);
f731ee
 void EXPORT_FUNC(grub_print_error) (void);
f731ee
 extern int EXPORT_VAR(grub_err_printed_errors);
f731ee
 int grub_err_printf (const char *fmt, ...)
f731ee
-     __attribute__ ((format (printf, 1, 2)));
f731ee
+     __attribute__ ((format (__printf__, 1, 2)));
f731ee
 
f731ee
 #endif /* ! GRUB_ERR_HEADER */
f731ee
diff --git a/ChangeLog b/ChangeLog
f731ee
index b405b7ee5bd..c93f11fbb20 100644
f731ee
--- a/ChangeLog
f731ee
+++ b/ChangeLog
f731ee
@@ -1,3 +1,12 @@
f731ee
+
f731ee
+2014-01-25  Andrey Borzenkov <arvidjaar@gmail.com>
f731ee
+
f731ee
+	* include/grub/crypto.h: Replace __attribute__ ((format (printf)) with
f731ee
+	__attribute__ ((format (__printf__)) to fix compilation under MinGW-w64.
f731ee
+	* include/grub/emu/misc.h: ... and here.
f731ee
+	* include/grub/err.h: ... and here.
f731ee
+	* util/import_gcry.py: ... and here (in files g10lib.h).
f731ee
+
f731ee
 2014-01-25  Andrey Borzenkov <arvidjaar@gmail.com>
f731ee
 
f731ee
 	* util/grub-mkimage.c: Make prefix argument mandatory.
f731ee
diff --git a/util/import_gcry.py b/util/import_gcry.py
f731ee
index 63ebb90f1fe..2b3322d3a12 100644
f731ee
--- a/util/import_gcry.py
f731ee
+++ b/util/import_gcry.py
f731ee
@@ -534,6 +534,12 @@ for src in sorted (os.listdir (os.path.join (indir, "src"))):
f731ee
         fw.close ()
f731ee
         continue
f731ee
 
f731ee
+    if src == "g10lib.h":
f731ee
+        fw.write (f.read ().replace ("(printf,f,a)", "(__printf__,f,a)"))
f731ee
+        f.close ()
f731ee
+        fw.close ()
f731ee
+        continue
f731ee
+
f731ee
     fw.write (f.read ())
f731ee
     f.close ()
f731ee
     fw.close ()