From patchwork Sun Sep 16 00:05:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 184108 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0474F2C0080 for ; Sun, 16 Sep 2012 10:05:19 +1000 (EST) Received: from localhost ([::1]:38620 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TD2MO-00049u-MO for incoming@patchwork.ozlabs.org; Sat, 15 Sep 2012 20:05:16 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54756) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TD2MH-00049p-2N for qemu-devel@nongnu.org; Sat, 15 Sep 2012 20:05:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TD2MG-0003gj-1h for qemu-devel@nongnu.org; Sat, 15 Sep 2012 20:05:08 -0400 Received: from smtp.gentoo.org ([140.211.166.183]:52788) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TD2MF-0003fo-SD for qemu-devel@nongnu.org; Sat, 15 Sep 2012 20:05:07 -0400 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id A63B333C6B6 for ; Sun, 16 Sep 2012 00:05:06 +0000 (UTC) From: Mike Frysinger To: qemu-devel@nongnu.org Date: Sat, 15 Sep 2012 20:05:06 -0400 Message-Id: <1347753906-5261-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.7.9.7 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 140.211.166.183 Subject: [Qemu-devel] [PATCH] fix gcc warnings when RESERVED_VA is 0 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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