From: Ian Campbell Subject: Re: [PATCH] libxl: convert malloc() to libxl__zalloc(NULL, ...) Date: Wed, 6 Jun 2012 12:47:49 +0100 Message-ID: <1338983269.32319.67.camel@zakaz.uk.xensource.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Dario Faggioli Cc: Ian Jackson , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On Wed, 2012-06-06 at 10:22 +0100, Dario Faggioli wrote: > And ditch the error handling in libxl_get_cpu_topology() > > Signed-off-by: Dario Faggioli Could have used libxl__calloc but I've applied this version. I added "#define NOGC NULL" and used it instead of NULL, this will mean that when we come to apply <20424.60793.374823.597252@mariner.uk.xensource.com> we stand less chance of missing an existing NULL introduced in the interim. Hope that's ok. Ian. > > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c > --- a/tools/libxl/libxl.c > +++ b/tools/libxl/libxl.c > @@ -3116,12 +3116,7 @@ libxl_cputopology *libxl_get_cpu_topolog > if (tinfo.max_cpu_index < max_cpus - 1) > max_cpus = tinfo.max_cpu_index + 1; > > - ret = malloc(sizeof(libxl_cputopology) * max_cpus); > - if (ret == NULL) { > - LIBXL__LOG_ERRNOVAL(ctx, XTL_ERROR, ENOMEM, > - "Unable to allocate return value"); > - goto fail; > - } > + ret = libxl__zalloc(NULL, sizeof(libxl_cputopology) * max_cpus); > > for (i = 0; i < max_cpus; i++) { > #define V(map, i) (map[i] == INVALID_TOPOLOGY_ID) ? \