From: Ian Campbell Subject: Re: [PATCH 2/2] tools/libxl/libxl_qmp.c: Close fds on error path in qmp_open Date: Wed, 18 Mar 2015 12:13:30 +0000 Message-ID: <1426680810.18247.350.camel@citrix.com> References: <1426661435-23026-1-git-send-email-pramod.devendra@citrix.com> <20150318101528.GF23662@zion.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YYCrF-0005vc-1F for xen-devel@lists.xenproject.org; Wed, 18 Mar 2015 12:13:57 +0000 In-Reply-To: <20150318101528.GF23662@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 Cc: xen-devel@lists.xenproject.org, PRAMOD DEVENDRA , Ian Jackson , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Wed, 2015-03-18 at 10:15 +0000, Wei Liu wrote: > On Wed, Mar 18, 2015 at 06:50:35AM +0000, PRAMOD DEVENDRA wrote: > > From: Pramod Devendra > > > > Signed-off-by: Pramod Devendra > > CC: Ian Jackson > > CC: Stefano Stabellini > > CC: Ian Campbell > > CC: Wei Liu > > Thanks. > > The patch content looks good. Actually I think it should use the goto out error handling style, rather than closing the fd on every single path. i.e. the tail should be: out: if (ret == -1 && qmp->qmp_fd > -1) close(qmp->qmp_fd); return ret; and ret should be initialised to -1 at the top, and each return should be a goto.