From d50106289b3b0f2e5d1fdaa42cef9ce36ff71515 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Sat, 3 Aug 2019 08:11:17 -0400 Subject: chain conditionals to trip use of continue statements --- rm.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/rm.c b/rm.c index 1602224..21d8e0f 100644 --- a/rm.c +++ b/rm.c @@ -132,27 +132,26 @@ int main(int argc, char **argv) char base[strlen(path) + 1]; strcpy(base, path); char *b = basename(base); + struct stat st; if (!strcmp(b, "/") || !strcmp(b, ".") || !strcmp(b, "..")) { fprintf(stderr, "rm: %s: %s\n", path, strerror(EINVAL)); retval = 1; - continue; - } - struct stat st; - if (lstat(path, &st) != 0) { - if (mode != FORCE) { - fprintf(stderr, "rm: %s: %s\n", path, strerror(errno)); - retval = 1; + } else if (lstat(path, &st) != 0) { + if (mode == FORCE) { + continue; } - continue; - } + fprintf(stderr, "rm: %s: %s\n", path, strerror(errno)); + retval = 1; - if (recursive) { + } else if (recursive) { nftw(path, rm, OPEN_MAX, FTW_DEPTH | FTW_PHYS); + } else { rm(path, &st, 0, NULL); } + } while (++optind < argc); return retval; -- cgit v1.2.1