diff options
author | Jakob Kaivo <jkk@ung.org> | 2019-08-03 08:11:17 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2019-08-03 08:11:17 -0400 |
commit | d50106289b3b0f2e5d1fdaa42cef9ce36ff71515 (patch) | |
tree | 1579b45325bc630f2ad4806c885516cc46379f2f | |
parent | 17a6074c3ce52752afd8a367498610224fb4930d (diff) |
chain conditionals to trip use of continue statements
-rw-r--r-- | rm.c | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -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; |