From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH for-4.6 02/13] libxl: properly clean up array in libxl_list_cpupool failure path Date: Thu, 23 Jul 2015 10:22:02 +0100 Message-ID: <1437643322.19412.64.camel@citrix.com> References: <1437638354-14216-1-git-send-email-wei.liu2@citrix.com> <1437638354-14216-3-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZIChb-0006Du-Td for xen-devel@lists.xenproject.org; Thu, 23 Jul 2015 09:22:08 +0000 In-Reply-To: <1437638354-14216-3-git-send-email-wei.liu2@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wei Liu , Xen-devel Cc: Dario Faggioli , Ian Jackson List-Id: xen-devel@lists.xenproject.org On Thu, 2015-07-23 at 08:59 +0100, Wei Liu wrote: > Document how cpupool_info works. Distinguish success (ERROR_FAIL + > ENOENT) vs failure in libxl_list_cpupool and properly clean up the > array > in failure path. > > Also switch to libxl__realloc and call libxl_cpupool_{init,dispose} > where appropriate. > > There is change of behaviour. Previously if memory allocation fails > the > said function returns NULL. Now memory allocation failure is fatal. > This > is in line with how we deal with memory allocation failure in other > places in libxl though. I think this function would benefit from making the out: label be the error path and the success case just a return ptr (just before the label). Then your error handling for cpupool_info would become libxl_cpupoolinfo_dispose(&info); if (errno != ENOENT) goto out; break; and the "if (failed)" block would be at the out label (without the iff). Such splitting of the success/failure case is allowed if the only shared code would be the GC_FREE, which is the case here. Ian.