From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:36608) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rb8gd-0002yr-2D for qemu-devel@nongnu.org; Thu, 15 Dec 2011 05:37:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rb8gc-0000CU-8B for qemu-devel@nongnu.org; Thu, 15 Dec 2011 05:37:15 -0500 Received: from mail-gx0-f173.google.com ([209.85.161.173]:64928) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rb8gc-0000CQ-54 for qemu-devel@nongnu.org; Thu, 15 Dec 2011 05:37:14 -0500 Received: by ggnk1 with SMTP id k1so1826364ggn.4 for ; Thu, 15 Dec 2011 02:37:13 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20111215101939.GA7666@stefanha-thinkpad.localdomain> References: <4EE9AB5A.4080306@linux.vnet.ibm.com> <20111215082828.GA33201@cs.nctu.edu.tw> <20111215093637.GA387@stefanha-thinkpad.localdomain> <4EE9C5BF.1070400@redhat.com> <20111215101939.GA7666@stefanha-thinkpad.localdomain> Date: Thu, 15 Dec 2011 13:37:13 +0300 Message-ID: From: Max Filippov Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] some questions about g_malloc in qemu List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Zhi Hui Li , =?UTF-8?B?6Zmz6Z+L5Lu7?= , Stefan Hajnoczi , QEMU-devel , zhihuili@cn.ibm.com >> >> =A0I found this in HACKING: >> >> >> >> =A0 Please note that NULL check for the g_malloc result is redundant = and >> >> =A0 that g_malloc() call with zero size is not allowed. >> > >> > So we have: >> > >> > 1. You should not request 0 bytes from g_malloc(). >> >> I think this was related to qemu_malloc() and Anthony's sed run made it >> refer to g_malloc(), even though it works just fine with 0 bytes. We >> should probably remove this sentence. > > If you remove it then you can't interpret it the way I did. =A0It's not > longer possible to say that g_malloc() never returns NULL. =A0You always > have to qualify that with "unless you ask for 0 bytes". :) I have a number of ELFs that result in ELF loader making zero-size malloc. Previously I had to enable CONFIG_ZERO_MALLOC, now it just works. --=20 Thanks. -- Max