From: Collin Funk Date: Sun, 7 Dec 2025 23:03:00 +0000 (-0800) Subject: maint: whoami: reduce variable scope X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8abde0fe4a4be7d987cf56c4d5ff594e2dad3c2;p=thirdparty%2Fcoreutils.git maint: whoami: reduce variable scope * src/whoami.c (main): Declare variables where they are used instead of at the start of the function. --- diff --git a/src/whoami.c b/src/whoami.c index 9313eaf3e4..47c7c55b8a 100644 --- a/src/whoami.c +++ b/src/whoami.c @@ -55,8 +55,6 @@ Same as id -un.\n\ int main (int argc, char **argv) { - struct passwd *pw; - uid_t uid; uid_t NO_UID = -1; initialize_main (&argc, &argv); @@ -78,8 +76,8 @@ main (int argc, char **argv) } errno = 0; - uid = geteuid (); - pw = uid == NO_UID && errno ? nullptr : getpwuid (uid); + uid_t uid = geteuid (); + struct passwd *pw = uid == NO_UID && errno ? nullptr : getpwuid (uid); if (!pw) error (EXIT_FAILURE, errno, _("cannot find name for user ID %ju"), (uintmax_t) uid);