From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:41315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rb8Qm-0003DR-Ge for qemu-devel@nongnu.org; Thu, 15 Dec 2011 05:20:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rb8Qg-0004rQ-Uj for qemu-devel@nongnu.org; Thu, 15 Dec 2011 05:20:52 -0500 Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:42847) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rb8Qg-0004r8-LQ for qemu-devel@nongnu.org; Thu, 15 Dec 2011 05:20:46 -0500 Received: from /spool/local by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 Dec 2011 10:20:45 -0000 Received: from d06av12.portsmouth.uk.ibm.com (d06av12.portsmouth.uk.ibm.com [9.149.37.247]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pBFAKhG82089152 for ; Thu, 15 Dec 2011 10:20:43 GMT Received: from d06av12.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av12.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pBFAKgoJ024568 for ; Thu, 15 Dec 2011 03:20:43 -0700 Date: Thu, 15 Dec 2011 10:19:39 +0000 From: Stefan Hajnoczi Message-ID: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4EE9C5BF.1070400@redhat.com> Subject: Re: [Qemu-devel] some questions about g_malloc in qemu List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: Stefan Hajnoczi , Zhi Hui Li , zhihuili@cn.ibm.com, =?utf-8?B?6Zmz6Z+L5Lu7?= , QEMU-devel 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, 陳韋任 wrote: > >> I found this in HACKING: > >> > >> Please note that NULL check for the g_malloc result is redundant and > >> 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. 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". :) Stefan