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

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