From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH] Handles the error returned by the xc_dom_allocate function Date: Mon, 2 Nov 2015 12:02:07 +0000 Message-ID: <1446465727.3088.20.camel@citrix.com> References: <1445767344-7780-1-git-send-email-comethalley61@gmail.com> <1445767344-7780-2-git-send-email-comethalley61@gmail.com> <20151026104018.GQ5060@zion.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZtDoY-00032U-DT for xen-devel@lists.xenproject.org; Mon, 02 Nov 2015 12:02:18 +0000 In-Reply-To: <20151026104018.GQ5060@zion.uk.xensource.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 , Lasya Venneti Cc: xen-devel@lists.xenproject.org, dario.faggioli@citrix.com, stefano.stebellini@eu.citrix.com, george.dunlap@citrix.com, lars.kurth@citrix.com List-Id: xen-devel@lists.xenproject.org On Mon, 2015-10-26 at 10:40 +0000, Wei Liu wrote: > > + return -1; > > And, please set rv to a proper error code (presumably ENOMEM) Please don't, xc_* functions should return -1 or NULL and set errno on failure. (libxc error reporting is a bit of a mess, but this is the intention). So the caller here can assume that errno has already been set to something appropriate (probably ENOMEM) and it is fine to translate the NULL into a -1 since the overall function returns an int not a pointer. > and use goto err, otherwise you're leaking xs_fd. This is good advise and implies that rv should be set to -1 before the goto.