From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:54369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rb7vd-0002tt-Iq for qemu-devel@nongnu.org; Thu, 15 Dec 2011 04:48:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rb7vX-0005gu-VH for qemu-devel@nongnu.org; Thu, 15 Dec 2011 04:48:41 -0500 Received: from e23smtp01.au.ibm.com ([202.81.31.143]:37978) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rb7vX-0005gk-EL for qemu-devel@nongnu.org; Thu, 15 Dec 2011 04:48:35 -0500 Received: from /spool/local by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 Dec 2011 09:43:49 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pBF9iURn3461356 for ; Thu, 15 Dec 2011 20:44:32 +1100 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pBF9mIbU026001 for ; Thu, 15 Dec 2011 20:48:18 +1100 Message-ID: <4EE9C260.20305@linux.vnet.ibm.com> Date: Thu, 15 Dec 2011 17:48:16 +0800 From: Zhi Hui Li MIME-Version: 1.0 References: <4EE9AB5A.4080306@linux.vnet.ibm.com> <20111215082828.GA33201@cs.nctu.edu.tw> <20111215093637.GA387@stefanha-thinkpad.localdomain> In-Reply-To: <20111215093637.GA387@stefanha-thinkpad.localdomain> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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: QEMU-devel On 2011年12月15日 17:36, Stefan Hajnoczi wrote: > 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(). > 2. g_malloc() does not return NULL (if you follow rule #1). > > There is no need to check for NULL return. > > Stefan > > Maybe there is insufficient memory, the return is error, Do we need to check the return ? Thank you very much for your feedback!