From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:40610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rb8kt-0003wT-AD for qemu-devel@nongnu.org; Thu, 15 Dec 2011 05:41:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rb8kr-00012u-K3 for qemu-devel@nongnu.org; Thu, 15 Dec 2011 05:41:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45606) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rb8kq-00012n-VR for qemu-devel@nongnu.org; Thu, 15 Dec 2011 05:41:37 -0500 Message-ID: <4EE9CF91.80701@redhat.com> Date: Thu, 15 Dec 2011 11:44:33 +0100 From: Kevin Wolf MIME-Version: 1.0 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> In-Reply-To: <20111215101939.GA7666@stefanha-thinkpad.localdomain> Content-Type: text/plain; charset=UTF-8 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: Stefan Hajnoczi , Zhi Hui Li , zhihuili@cn.ibm.com, =?UTF-8?B?6Zmz6Z+L5Lu7?= , QEMU-devel Am 15.12.2011 11:19, schrieb Stefan Hajnoczi: > On Thu, Dec 15, 2011 at 11:02:39AM +0100, Kevin Wolf wrote: >> Am 15.12.2011 10:36, schrieb Stefan Hajnoczi: >>> On Thu, Dec 15, 2011 at 04:28:28PM +0800, =E9=99=B3=E9=9F=8B=E4=BB=BB= wrote: >>>> I found this in HACKING: >>>> >>>> Please note that NULL check for the g_malloc result is redundant a= nd >>>> 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 i= t >> refer to g_malloc(), even though it works just fine with 0 bytes. We >> should probably remove this sentence. >=20 > If you remove it then you can't interpret it the way I did. It's not > longer possible to say that g_malloc() never returns NULL. You always > have to qualify that with "unless you ask for 0 bytes". :) Try this: "g_malloc() never returns an error". ;-) Kevin