[tip:tools/kvm] kvm tools: Fix build of util.c on 32bit machines

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  a9fcc1f4b3f4f021c86e9e2f4cdd4f6f5ffa77f4
Gitweb:     http://git.kernel.org/tip/a9fcc1f4b3f4f021c86e9e2f4cdd4f6f5ffa77f4
Author:     Matt Evans <matt@xxxxxxxxxx>
AuthorDate: Wed, 14 Dec 2011 12:10:03 +1100
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Wed, 14 Dec 2011 08:30:14 +0200

kvm tools: Fix build of util.c on 32bit machines

commit 378ee7e6dd301347c6bf2c740cb1fb40174bcb8b broke the -Werror build
on 32bit targets due to some variable typing in struct statfs:

On 14/12/11 11:03, David Evensky wrote:
> On an x86 32bit system (and using the 32bit CodeSourcery toolchain on
> a x86_64 system) I get:
>
> evensky@machine:~/.../linux-kvm/tools/kvm$ make
>   CC       util/util.o
> util/util.c: In function 'mmap_hugetlbfs':
> util/util.c:93:17: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
> util/util.c:99:7: error: format '%ld' expects argument of type 'long int', but argument 2 has type 'int' [-Werror=format]
> cc1: all warnings being treated as errors
>
> make: *** [util/util.o] Error 1

Fixes the build.

Reported-by: David Evensky <evensky@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Matt Evans <matt@xxxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/util/util.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/kvm/util/util.c b/tools/kvm/util/util.c
index ad5418e..00f7315 100644
--- a/tools/kvm/util/util.c
+++ b/tools/kvm/util/util.c
@@ -86,17 +86,19 @@ void *mmap_hugetlbfs(const char *htlbfs_path, u64 size)
 	int fd;
 	struct statfs sfs;
 	void *addr;
+	unsigned long blk_size;
 
 	if (statfs(htlbfs_path, &sfs) < 0)
 		die("Can't stat %s\n", htlbfs_path);
 
-	if (sfs.f_type != HUGETLBFS_MAGIC) {
+	if ((unsigned int)sfs.f_type != HUGETLBFS_MAGIC) {
 		die("%s is not hugetlbfs!\n", htlbfs_path);
 	}
 
-	if (sfs.f_bsize == 0 || (unsigned long)sfs.f_bsize > size) {
+	blk_size = (unsigned long)sfs.f_bsize;
+	if (sfs.f_bsize == 0 || blk_size > size) {
 		die("Can't use hugetlbfs pagesize %ld for mem size %lld\n",
-		    sfs.f_bsize, size);
+		    blk_size, size);
 	}
 
 	snprintf(mpath, PATH_MAX, "%s/kvmtoolXXXXXX", htlbfs_path);
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux