From: Alejandro Colomar Date: Mon, 13 May 2024 21:24:38 +0000 (+0200) Subject: lib/, src/: Reduce scope of local variables X-Git-Tag: 4.17.0-rc1~201 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5e11e89fd9876793c6106c7a4485c2dc7c32778f;p=thirdparty%2Fshadow.git lib/, src/: Reduce scope of local variables Signed-off-by: Alejandro Colomar --- diff --git a/lib/commonio.c b/lib/commonio.c index f1723c808..aa6d8c872 100644 --- a/lib/commonio.c +++ b/lib/commonio.c @@ -574,9 +574,7 @@ static void add_one_entry_nis (struct commonio_db *db, int commonio_open (struct commonio_db *db, int mode) { char *buf; - char *cp; char *line; - struct commonio_entry *p; void *eptr = NULL; int flags = mode; size_t buflen; @@ -642,6 +640,9 @@ int commonio_open (struct commonio_db *db, int mode) } while (db->ops->fgets (buf, buflen, db->fp) == buf) { + char *cp; + struct commonio_entry *p; + while ( (strrchr (buf, '\n') == NULL) && (feof (db->fp) == 0)) { size_t len; diff --git a/src/logoutd.c b/src/logoutd.c index d1b30897f..eb4c6fe20 100644 --- a/src/logoutd.c +++ b/src/logoutd.c @@ -120,14 +120,8 @@ static void send_mesg_to_tty (int tty_fd) int main(int argc, char **argv) { - int i; pid_t pid; - struct utmpx *ut; - char user[sizeof (ut->ut_user) + 1]; /* terminating NUL */ - char tty_name[sizeof (ut->ut_line) + 6]; /* /dev/ + NUL */ - int tty_fd; - if (1 != argc) { (void) fputs (_("Usage: logoutd\n"), stderr); } @@ -137,7 +131,7 @@ main(int argc, char **argv) (void) textdomain (PACKAGE); #ifndef DEBUG - for (i = 0; close (i) == 0; i++); + for (int i = 0; close(i) == 0; i++); setpgrp (); @@ -168,6 +162,7 @@ main(int argc, char **argv) * are not supposed to still be logged in. */ while (true) { + struct utmpx *ut; /* * Attempt to re-open the utmp file. The file is only @@ -181,6 +176,10 @@ main(int argc, char **argv) * is permitted to be signed on at this time. */ while ((ut = getutxent()) != NULL) { + int tty_fd; + char user[sizeof(ut->ut_user) + 1]; // NUL + char tty_name[sizeof(ut->ut_line) + 6]; // /dev/ + NUL + if (ut->ut_type != USER_PROCESS) { continue; }