From 892c033de018c86951bcbe57a93e462962b019f8 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 3 Nov 2016 23:54:27 -0400 Subject: 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. --- bftw.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bftw.c') 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: -- cgit v1.2.3