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

Re: [Xen-devel] [PATCH 24/31] libxl: provide libxl__remove_file et al.



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.

> > +    for (;;) {
> > +        int r = rmdir(dirpath);
> > +        if (!r) break;
> > +        if (errno == ENOENT) return 0;
> 
> This misses the closedir() at out?

Well spotted, fixed.

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®.