]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: nproc: reduce variable scope
authorCollin Funk <collin.funk1@gmail.com>
Sun, 7 Dec 2025 23:06:24 +0000 (15:06 -0800)
committerCollin Funk <collin.funk1@gmail.com>
Sun, 7 Dec 2025 23:06:24 +0000 (15:06 -0800)
* src/nproc.c (main): Declare variables where they are used instead of
at the start of the function.

src/nproc.c

index ec196297a4ebe7964fe1db1b1ab18594b7c604db..795458aa012985a00ed81b5b348fa0f52ee7dac4 100644 (file)
@@ -74,7 +74,7 @@ which may be less than the number of online processors\n\
 int
 main (int argc, char **argv)
 {
-  unsigned long nproc, ignore = 0;
+  unsigned long ignore = 0;
   initialize_main (&argc, &argv);
   set_program_name (argv[0]);
   setlocale (LC_ALL, "");
@@ -116,7 +116,7 @@ main (int argc, char **argv)
       usage (EXIT_FAILURE);
     }
 
-  nproc = num_processors (mode);
+  unsigned long nproc = num_processors (mode);
 
   if (ignore < nproc)
     nproc -= ignore;