From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mg5aQ-0007aG-GE for qemu-devel@nongnu.org; Tue, 25 Aug 2009 19:37:58 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mg5aK-0007SO-Qr for qemu-devel@nongnu.org; Tue, 25 Aug 2009 19:37:58 -0400 Received: from [199.232.76.173] (port=44179 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mg5aK-0007Ry-OA for qemu-devel@nongnu.org; Tue, 25 Aug 2009 19:37:52 -0400 Received: from mail.gmx.net ([213.165.64.20]:40894) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1Mg5aK-0008Vn-05 for qemu-devel@nongnu.org; Tue, 25 Aug 2009 19:37:52 -0400 From: "Jan-Simon =?utf-8?q?M=C3=B6ller?=" Subject: Re: [Qemu-devel] [Patch] linux-user/syscall.c - don't add GUEST_BASE to NULL pointer Date: Wed, 26 Aug 2009 01:37:48 +0200 References: <200908260002.03066.dl9pf@gmx.de> In-Reply-To: <200908260002.03066.dl9pf@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200908260137.48781.dl9pf@gmx.de> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Thinking a bit more about this, I wonder if g2h(x) shouldn't itself always= =20 return NULL on x =3D NULL ?=20 Something like: Signed-off-by: Jan-Simon M=C3=B6ller diff --git a/cpu-all.h b/cpu-all.h index 1a6a812..631f678 100644 =2D-- a/cpu-all.h +++ b/cpu-all.h @@ -633,7 +633,7 @@ extern int have_guest_base; #endif /* All direct uses of g2h and h2g need to go away for usermode softmmu. */ =2D#define g2h(x) ((void *)((unsigned long)(x) + GUEST_BASE)) +#define g2h(x) ( !x ? NULL:((void *)((unsigned long)(x) + GUEST_BASE))) #define h2g(x) ({ \ unsigned long __ret =3D (unsigned long)(x) - GUEST_BASE; \ /* Check if given address fits target address space */ \ I read the comment above, but before replacing it in user-mode (if possible= ),=20 we should fix it ;) . Best, Jan-Simon