Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NFT5P-0000U2-Hb for qemu-devel@nongnu.org; Tue, 01 Dec 2009 08:48:11 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NFT5K-0000RB-Kl for qemu-devel@nongnu.org; Tue, 01 Dec 2009 08:48:10 -0500 Received: from [199.232.76.173] (port=46994 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFT5I-0000QU-NC for qemu-devel@nongnu.org; Tue, 01 Dec 2009 08:48:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:1025) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NFT5H-0002e0-SX for qemu-devel@nongnu.org; Tue, 01 Dec 2009 08:48:04 -0500 Date: Tue, 1 Dec 2009 11:47:49 -0200 From: Glauber Costa Subject: Re: [Qemu-devel] [PATCH] Permit zero-sized qemu_malloc() & friends Message-ID: <20091201134749.GA23375@mothafucka.localdomain> References: <4B150EAD.4050502@redhat.com> <200912011257.28121.paul@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200912011257.28121.paul@codesourcery.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paul Brook Cc: Markus Armbruster , qemu-devel@nongnu.org, Gerd Hoffmann On Tue, Dec 01, 2009 at 12:57:27PM +0000, Paul Brook wrote: > > You might want to have a 'static uint8_t zero_length_malloc[0]' and > > return that instead of the magic cookie '1'. Makes the code more > > readable IMHO and you'll also have symbol in gdb when debugging qemu. > > Having multiple malloc return the same pointer sounds like a really bad idea. And why's that? Keep in mind that *any* dereference over that address is a bug. Actually, I very much like Gerd's idea to unmap that address, so the bug won't hide from us in any circumnstances.