Btrfs-progs: Fix compiler warnings on PPC64

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

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

To fix this, the macro __KERNEL__ needs to be defined before including
the file <asm/types.h>. This can be done by defining the macro in
"kerncompat.h" and making it the first included file in the relevant
header files; this fixes the compiler warnings on PPC64.

Reviewed-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Wade Cline <clinew@linux.vnet.ibm.com>
This commit is contained in:
Wade Cline 2012-09-20 14:26:28 -07:00 committed by David Sterba
parent 91d9eec1ff
commit 0d5cfddc2c
7 changed files with 28 additions and 3 deletions

View File

@ -21,6 +21,8 @@
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
#define _BSD_SOURCE #define _BSD_SOURCE
#include "kerncompat.h"
#include <unistd.h> #include <unistd.h>
#include <stdint.h> #include <stdint.h>
#include <dirent.h> #include <dirent.h>

View File

@ -16,6 +16,8 @@
* Boston, MA 021110-1307, USA. * Boston, MA 021110-1307, USA.
*/ */
#include "kerncompat.h"
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/stat.h> #include <sys/stat.h>

View File

@ -18,6 +18,8 @@
#define _GNU_SOURCE #define _GNU_SOURCE
#include "kerncompat.h"
#include <unistd.h> #include <unistd.h>
#include <stdint.h> #include <stdint.h>
#include <dirent.h> #include <dirent.h>

View File

@ -18,6 +18,9 @@
#define _XOPEN_SOURCE 600 #define _XOPEN_SOURCE 600
#define _GNU_SOURCE 1 #define _GNU_SOURCE 1
#include "kerncompat.h"
#ifndef __CHECKER__ #ifndef __CHECKER__
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/mount.h> #include <sys/mount.h>
@ -31,7 +34,7 @@
#include <unistd.h> #include <unistd.h>
#include <uuid/uuid.h> #include <uuid/uuid.h>
#include <linux/fs.h> #include <linux/fs.h>
#include "kerncompat.h"
#include "ctree.h" #include "ctree.h"
#include "disk-io.h" #include "disk-io.h"
#include "volumes.h" #include "volumes.h"

View File

@ -18,6 +18,7 @@
#ifndef __KERNCOMPAT #ifndef __KERNCOMPAT
#define __KERNCOMPAT #define __KERNCOMPAT
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
@ -57,11 +58,22 @@
#endif #endif
#ifndef __CHECKER__ #ifndef __CHECKER__
/*
* Since we're using primitive definitions from kernel-space, we need to
* define __KERNEL__ so that system header files know which definitions
* to use.
*/
#define __KERNEL__
#include <asm/types.h> #include <asm/types.h>
typedef __u32 u32; typedef __u32 u32;
typedef __u64 u64; typedef __u64 u64;
typedef __u16 u16; typedef __u16 u16;
typedef __u8 u8; typedef __u8 u8;
/*
* Continuing to define __KERNEL__ breaks others parts of the code, so
* we can just undefine it now that we have the correct headers...
*/
#undef __KERNEL__
#else #else
typedef unsigned int u32; typedef unsigned int u32;
typedef unsigned int __u32; typedef unsigned int __u32;

3
mkfs.c
View File

@ -19,6 +19,8 @@
#define _XOPEN_SOURCE 500 #define _XOPEN_SOURCE 500
#define _GNU_SOURCE #define _GNU_SOURCE
#include "kerncompat.h"
#ifndef __CHECKER__ #ifndef __CHECKER__
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/mount.h> #include <sys/mount.h>
@ -37,7 +39,6 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <ctype.h> #include <ctype.h>
#include <attr/xattr.h> #include <attr/xattr.h>
#include "kerncompat.h"
#include "ctree.h" #include "ctree.h"
#include "disk-io.h" #include "disk-io.h"
#include "volumes.h" #include "volumes.h"

View File

@ -18,6 +18,9 @@
#define _XOPEN_SOURCE 500 #define _XOPEN_SOURCE 500
#define _GNU_SOURCE 1 #define _GNU_SOURCE 1
#include "kerncompat.h"
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -25,7 +28,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <zlib.h> #include <zlib.h>
#include "kerncompat.h"
#include "ctree.h" #include "ctree.h"
#include "disk-io.h" #include "disk-io.h"
#include "print-tree.h" #include "print-tree.h"