From: Ian Jackson Subject: Re: [PATCH] libxl: improve error handling when saving device model state Date: Thu, 15 Dec 2011 17:00:41 +0000 Message-ID: <20202.10169.101830.45527@mariner.uk.xensource.com> References: <64e48ae2ef6760db221f.1323796155@cosworth.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <64e48ae2ef6760db221f.1323796155@cosworth.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Campbell Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Ian Campbell writes ("[Xen-devel] [PATCH] libxl: improve error handling when saving device model state"): > libxl: improve error handling when saving device model state. ... > +out_close_fd2: > close(fd2); > +out_unlink: > unlink(filename); This style of error handling is very prone to errors. How about: int fd2 = -1; blah blah maybe goto out blah blah if (fd2 >= 0) close(fd2); And always unlinking the filename is fine, surely ? Ian.