linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH] Btrfs-progs: Fix compiler warnings on PPC64.
@ 2012-09-12 23:21 clinew
  2012-09-14 13:59 ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: clinew @ 2012-09-12 23:21 UTC (permalink / raw)
  To: linux-btrfs; +Cc: cmm, Wade Cline

From: Wade Cline <clinew@linux.vnet.ibm.com>

The kernel uses unsigned long long for u64, but PPC64 uses unsigned
long by default. This results in print warnings such as:

print-tree.c:333: warning: format ‘%llu’ expects type ‘long long
unsigned int’, but argument 4 has type ‘u64’

Defining __KERNEL__ before the file <asm/types.h>, or any file that
includes this file, will let PPC64 know to use unsigned long long
for u64 instead. This patch adds the defines and fixes the print
warnings on PPC64.

Signed-off-by: Wade Cline <clinew@linux.vnet.ibm.com>
---
 cmds-receive.c |    1 +
 cmds-scrub.c   |    2 ++
 convert.c      |    1 +
 kerncompat.h   |    6 ++++++
 mkfs.c         |    1 +
 5 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/cmds-receive.c b/cmds-receive.c
index a8be6fa..6cb51fe 100644
--- a/cmds-receive.c
+++ b/cmds-receive.c
@@ -20,6 +20,7 @@
 #define _POSIX_C_SOURCE 200809
 #define _XOPEN_SOURCE 700
 #define _BSD_SOURCE
+#define __KERNEL__
 
 #include <unistd.h>
 #include <stdint.h>
diff --git a/cmds-scrub.c b/cmds-scrub.c
index 24be20f..7f6aa68 100644
--- a/cmds-scrub.c
+++ b/cmds-scrub.c
@@ -16,6 +16,8 @@
  * Boston, MA 021110-1307, USA.
  */
 
+#define __KERNEL__
+
 #include <sys/ioctl.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
diff --git a/convert.c b/convert.c
index fa7bf8c..74ffceb 100644
--- a/convert.c
+++ b/convert.c
@@ -18,6 +18,7 @@
 
 #define _XOPEN_SOURCE 600
 #define _GNU_SOURCE 1
+#define __KERNEL__
 #ifndef __CHECKER__
 #include <sys/ioctl.h>
 #include <sys/mount.h>
diff --git a/kerncompat.h b/kerncompat.h
index 46236cd..2e571b8 100644
--- a/kerncompat.h
+++ b/kerncompat.h
@@ -57,11 +57,17 @@
 #endif
 
 #ifndef __CHECKER__
+/*
+ * PPC64 uses unsigned long for u64 while the kernel uses unsigned long long;
+ * Specifying this will let PPC64 know to use unsigned long long instead.
+ */
+#define __KERNEL__
 #include <asm/types.h>
 typedef __u32 u32;
 typedef __u64 u64;
 typedef __u16 u16;
 typedef __u8 u8;
+#undef __KERNEL__
 #else
 typedef unsigned int u32;
 typedef unsigned int __u32;
diff --git a/mkfs.c b/mkfs.c
index dff5eb8..1c88804 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -18,6 +18,7 @@
 
 #define _XOPEN_SOURCE 500
 #define _GNU_SOURCE
+#define __KERNEL__
 
 #ifndef __CHECKER__
 #include <sys/ioctl.h>
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-09-20 14:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-12 23:21 [RFC][PATCH] Btrfs-progs: Fix compiler warnings on PPC64 clinew
2012-09-14 13:59 ` David Sterba
2012-09-14 17:13   ` Wade Cline
2012-09-20 14:15     ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).