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

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