From: Alejandro Colomar Date: Tue, 10 Dec 2024 02:23:30 +0000 (+0100) Subject: lib/, src/: Reduce scope of local variables X-Git-Tag: 4.18.0-rc1~81 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=959cbaa71e1c249968ccb6da3764dfe01c6d8a1f;p=thirdparty%2Fshadow.git lib/, src/: Reduce scope of local variables Signed-off-by: Alejandro Colomar --- diff --git a/lib/prefix_flag.c b/lib/prefix_flag.c index c09b8d082..bcf5d504f 100644 --- a/lib/prefix_flag.c +++ b/lib/prefix_flag.c @@ -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) diff --git a/lib/root_flag.c b/lib/root_flag.c index f63aa6496..84a659807 100644 --- a/lib/root_flag.c +++ b/lib/root_flag.c @@ -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) diff --git a/src/chpasswd.c b/src/chpasswd.c index 5d9c42c10..edab544ec 100644 --- a/src/chpasswd.c +++ b/src/chpasswd.c @@ -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) {