Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
consdiff: adapt to c99, format and style fixes
  • Loading branch information
mvdan committed Mar 7, 2015
1 parent f775664 commit d0a9f85ead92895c524203e13c6ff9af8f9282e7
Showing with 292 additions and 215 deletions.
  1. +21 −12 src/common/util.c
  2. +158 −109 src/or/consdiff.c
  3. +29 −29 src/or/directory.c
  4. +83 −63 src/or/dirserv.c
  5. +1 −2 src/or/main.c
@@ -3411,46 +3411,55 @@ int
tor_rmdir(const char *dirname)
{
int r=0;
smartlist_t *elements;
struct stat st;

r = lstat(dirname, &st);

if (r<0) {
if (r < 0) {
// Dir doesn't exist, nothing to do
if (errno&ENOENT) return 0;
if (errno & ENOENT) {
return 0;
}
log_warn(LD_FS, "Error lstat()ing dir '%s': %s", dirname,
strerror(errno));
return -1;
}
if (!(st.st_mode&S_IFDIR)) {
if (!(st.st_mode & S_IFDIR)) {
log_warn(LD_FS, "Path doesn't correspond to a directory: '%s'",
dirname);
return -1;
}

elements = tor_listdir(dirname);
if (!elements) return -1;
smartlist_t *elements = tor_listdir(dirname);
if (!elements) {
return -1;
}

SMARTLIST_FOREACH_BEGIN(elements, const char *, cp) {
char *tmp = NULL;
tor_asprintf(&tmp, "%s"PATH_SEPARATOR"%s", dirname, cp);
if (0 == lstat(tmp,&st) && (st.st_mode & S_IFDIR)) {
if ((r=tor_rmdir(tmp))<0)
if (0 == lstat(tmp, &st) && (st.st_mode & S_IFDIR)) {
if ((r=tor_rmdir(tmp)) < 0) {
log_warn(LD_FS, "Error removing directory '%s': %s", tmp,
strerror(errno));
}
} else {
if ((r=unlink(tmp))<0)
if ((r=unlink(tmp)) < 0) {
log_warn(LD_FS, "Error removing file '%s': %s", tmp,
strerror(errno));
}
}
tor_free(tmp);
if (r<0) break;
if (r < 0) {
break;
}
} SMARTLIST_FOREACH_END(cp);
SMARTLIST_FOREACH(elements, char *, cp, tor_free(cp));
smartlist_free(elements);
if (r<0) return r;
if ((r=rmdir(dirname))<0) {
if (r < 0) {
return r;
}
if ((r=rmdir(dirname)) < 0) {
log_warn(LD_FS, "Error removing directory '%s': %s", dirname,
strerror(errno));
}

0 comments on commit d0a9f85

Please sign in to comment.