From a81c3f1dac2771b77e4d55012bb09a24279fb695 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Fri, 1 Nov 2019 15:18:22 -0400 Subject: bftw: Avoid shadowing a variable --- bftw.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bftw.c b/bftw.c index 2347b00..9804853 100644 --- a/bftw.c +++ b/bftw.c @@ -1028,11 +1028,8 @@ static void bftw_init_ftwbuf(struct bftw_state *state, enum bftw_visit visit) { } if (ftwbuf->typeflag == BFTW_DIR && (state->flags & BFTW_DETECT_CYCLES)) { - for (const struct bftw_file *parent = file; parent; parent = parent->parent) { - if (parent->depth == ftwbuf->depth) { - continue; - } - if (parent->dev == statbuf->dev && parent->ino == statbuf->ino) { + for (const struct bftw_file *ancestor = parent; ancestor; ancestor = ancestor->parent) { + if (ancestor->dev == statbuf->dev && ancestor->ino == statbuf->ino) { ftwbuf->typeflag = BFTW_ERROR; ftwbuf->error = ELOOP; return; -- cgit v1.2.3