qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH] fix gcc warnings when RESERVED_VA is 0


From: Mike Frysinger
Subject: [Qemu-devel] [PATCH] fix gcc warnings when RESERVED_VA is 0
Date: Sat, 15 Sep 2012 20:05:06 -0400

The current code, while correct, triggers a bunch of gcc warnings when
RESERVED_VA is 0 like so:
linux-user/syscall.c: In function 'do_shmat':
linux-user/syscall.c:3058: warning: comparison of unsigned expression < 0 is 
always false
linux-user/syscall.c: In function 'open_self_maps':
linux-user/syscall.c:4960: warning: comparison of unsigned expression < 0 is 
always false
linux-user/syscall.c:4960: warning: comparison of unsigned expression < 0 is 
always false

Signed-off-by: Mike Frysinger <address@hidden>
---
 cpu-all.h |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/cpu-all.h b/cpu-all.h
index 5e07d28..0e5dcf0 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -202,10 +202,16 @@ extern unsigned long reserved_va;
 #if HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS
 #define h2g_valid(x) 1
 #else
+/* Gcc likes to warn about comparing unsigned longs to < 0, so cpp it away.  */
+# if RESERVED_VA
+#  define _h2g_reserved_va(x) ((x) < RESERVED_VA)
+# else
+#  define _h2g_reserved_va(x) 1
+# endif
 #define h2g_valid(x) ({ \
     unsigned long __guest = (unsigned long)(x) - GUEST_BASE; \
     (__guest < (1ul << TARGET_VIRT_ADDR_SPACE_BITS)) && \
-    (!RESERVED_VA || (__guest < RESERVED_VA)); \
+    _h2g_reserved_va(__guest); \
 })
 #endif
 
-- 
1.7.9.7




reply via email to

[Prev in Thread] Current Thread [Next in Thread]