]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/, src/: Reduce scope of local variables
authorAlejandro Colomar <alx@kernel.org>
Tue, 10 Dec 2024 02:23:30 +0000 (03:23 +0100)
committerSerge Hallyn <serge@hallyn.com>
Mon, 26 May 2025 16:29:26 +0000 (11:29 -0500)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/prefix_flag.c
lib/root_flag.c
src/chpasswd.c

index c09b8d082633fc3851f3f3b45cc44c27acbe50d3..bcf5d504fbd34c969ef9c513d3a2158a9e8f13c2 100644 (file)
@@ -53,13 +53,11 @@ static FILE* fp_grent = NULL;
  */
 extern const char* process_prefix_flag (const char* short_opt, int argc, char **argv)
 {
-       /*
-        * Parse the command line options.
-        */
-       int i;
-       const char *prefix = NULL, *val;
+       const char *prefix = NULL;
+
+       for (int i = 0; i < argc; i++) {
+               const char  *val;
 
-       for (i = 0; i < argc; i++) {
                val = NULL;
                if (   streq(argv[i], "--prefix")
                    || ((strncmp (argv[i], "--prefix=", 9) == 0)
index f63aa6496a8336042e487ebde5a6e5a1381c8b27..84a659807aafd49ab8fe82d4a5ce24f2721d263e 100644 (file)
@@ -34,13 +34,11 @@ static void change_root (const char* newroot);
  */
 extern void process_root_flag (const char* short_opt, int argc, char **argv)
 {
-       /*
-        * Parse the command line options.
-        */
-       int i;
-       const char *newroot = NULL, *val;
+       const char *newroot = NULL;
+
+       for (int i = 0; i < argc; i++) {
+               const char  *val;
 
-       for (i = 0; i < argc; i++) {
                val = NULL;
                if (   streq(argv[i], "--root")
                    || ((strncmp (argv[i], "--root=", 7) == 0)
index 5d9c42c1012f80197abb4ebf2d6b141a881273e9..edab544ecbaf16f384d45ca90647ab1b8fb52fd6 100644 (file)
@@ -446,7 +446,6 @@ int main (int argc, char **argv)
        char buf[BUFSIZ];
        char *name;
        char *newpwd;
-       char *cp;
        const char *salt;
 
 #ifdef USE_PAM
@@ -503,6 +502,8 @@ int main (int argc, char **argv)
         * present.
         */
        while (fgets (buf, sizeof buf, stdin) != NULL) {
+               char  *cp;
+
                line++;
                if (stpsep(buf, "\n") == NULL) {
                        if (feof (stdin) == 0) {