summaryrefslogtreecommitdiffstats
path: root/bftw.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2016-11-03 23:54:27 -0400
committerTavian Barnes <tavianator@tavianator.com>2016-11-03 23:54:27 -0400
commit892c033de018c86951bcbe57a93e462962b019f8 (patch)
tree85d67997646cc04abcb63ab13db467bb9cdb3eac /bftw.c
parent8da7838c867937cadc5609f6914fd2d3bbd053f1 (diff)
downloadbfs-892c033de018c86951bcbe57a93e462962b019f8.tar.xz
bftw: Don't fail just because we couldn't open/read a directory.
With BFTW_RECOVER set, we're not supposed to fail just because a single measly directory couldn't be handled. But using state.error as scratch space made us fail in this case. The end result is that #7 resurfaced, so fix it again.
Diffstat (limited to 'bftw.c')
-rw-r--r--bftw.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/bftw.c b/bftw.c
index f48d3f8..1feeeed 100644
--- a/bftw.c
+++ b/bftw.c
@@ -955,7 +955,7 @@ static void bftw_state_free(struct bftw_state *state) {
}
int bftw(const char *path, bftw_fn *fn, int nopenfd, enum bftw_flags flags, void *ptr) {
- int ret = -1;
+ int ret = -1, error;
struct bftw_state state;
if (bftw_state_init(&state, fn, nopenfd, flags, ptr) != 0) {
@@ -1076,7 +1076,7 @@ int bftw(const char *path, bftw_fn *fn, int nopenfd, enum bftw_flags flags, void
continue;
dir_error:
- state.error = errno;
+ error = errno;
if (dir) {
closedir(dir);
@@ -1084,7 +1084,7 @@ int bftw(const char *path, bftw_fn *fn, int nopenfd, enum bftw_flags flags, void
bftw_path_trim(&state);
bftw_init_buffers(&state, NULL);
- bftw_set_error(&state, state.error);
+ bftw_set_error(&state, error);
switch (bftw_handle_path(&state)) {
case BFTW_CONTINUE: