From bdb276a0c5a38202e19bb08597a89ae4df00e09c Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Tue, 9 Dec 2025 21:43:11 -0800 Subject: [PATCH] maint: rmdir: reduce variable scope * src/rmdir.c (remove_parents, main): Declare variables where they are used instead of at the start of a block. --- src/rmdir.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/rmdir.c b/src/rmdir.c index 9ca3f7ed15..1b2e7e4a55 100644 --- a/src/rmdir.c +++ b/src/rmdir.c @@ -112,13 +112,12 @@ ignorable_failure (int error_number, char const *dir) static bool remove_parents (char *dir) { - char *slash; bool ok = true; strip_trailing_slashes (dir); while (true) { - slash = strrchr (dir, '/'); + char *slash = strrchr (dir, '/'); if (slash == nullptr) break; /* Remove any characters after the slash, skipping any extra @@ -197,9 +196,6 @@ Remove the DIRECTORY(ies), if they are empty.\n\ int main (int argc, char **argv) { - bool ok = true; - int optc; - initialize_main (&argc, &argv); set_program_name (argv[0]); setlocale (LC_ALL, ""); @@ -210,6 +206,7 @@ main (int argc, char **argv) remove_empty_parents = false; + int optc; while ((optc = getopt_long (argc, argv, "pv", longopts, nullptr)) != -1) { switch (optc) @@ -236,6 +233,7 @@ main (int argc, char **argv) usage (EXIT_FAILURE); } + bool ok = true; for (; optind < argc; ++optind) { char *dir = argv[optind]; -- 2.47.3