[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 20/21] libxc: check return values from malloc



Andrew Cooper writes ("Re: [PATCH 20/21] libxc: check return values from 
malloc"):
> On 06/06/13 19:52, Ian Jackson wrote:
> >      if (!ctx->hvm && ctx->superpages)
> > +    {
> >          ctx->p2m_saved_batch =
> >              malloc(ROUNDUP(MAX_BATCH_SIZE * sizeof(xen_pfn_t), 
> > PAGE_SHIFT));
> > +        if ( ctx->p2m_saved_batch == NULL )
> > +        {
> > +            ERROR("saved batch memory alloc failed");
> > +            errno = ENOMEM;
> > +            goto out;
> > +        }
> > +    }
> 
> Can you not merge this NULL test into the if statement immediatly below
> which does all the other NULL pointer checks?
> 
> something like (!ctx->hvm && ctx->superpages && ctx->p2m_saved_batch == NULL

I thought it better to duplicate the formulaic and entirely obvious
error handling code than the non-obvious and semantically relevant
test for whether to allocate.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.