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