From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH 24/31] libxl: provide libxl__remove_file et al. Date: Wed, 11 Apr 2012 12:03:25 +0100 Message-ID: <1334142205.5394.115.camel@zakaz.uk.xensource.com> References: <1334084885-14474-1-git-send-email-ian.jackson@eu.citrix.com> <1334084885-14474-25-git-send-email-ian.jackson@eu.citrix.com> <1334138063.5394.97.camel@zakaz.uk.xensource.com> <20357.25423.953494.600764@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20357.25423.953494.600764@mariner.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: Ian Jackson Cc: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On Wed, 2012-04-11 at 11:56 +0100, Ian Jackson wrote: > Ian Campbell writes ("Re: [Xen-devel] [PATCH 24/31] libxl: provide libxl__remove_file et al."): > > On Tue, 2012-04-10 at 20:07 +0100, Ian Jackson wrote: > > > +int libxl__remove_file_or_directory(libxl__gc *gc, const char *path) > > > +{ > > > + for (;;) { > > > + int r = rmdir(path); > > > + if (!r) return 0; > > > + if (errno == ENOENT) return 0; > > > + if (errno == ENOTEMPTY) return libxl__remove_directory(gc, path); > > > + if (errno == ENOTDIR) return libxl__remove_file(gc, path); > > > + if (errno == EINTR) continue; > > > > starting to look a bit like a switch statement... > > Perhaps. I'm not sure I want to obscure the similarity with (and the > differences from) the other analogous error-handling code, and those > other sites typically have only a couple of errno cases making a > switch overkill. Also of course a switch would switch only on errno > whereas the branching is on r too, so it would add another level of > nesting. Sounds reasonable to leave it as is then. > > > > + for (;;) { > > > + int r = rmdir(dirpath); > > > + if (!r) break; > > > + if (errno == ENOENT) return 0; > > > > This misses the closedir() at out? > > Well spotted, fixed. > > Ian.