1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-02-11 01:42:17 +02:00

maint: hostid: reduce variable scope

* src/hostid.c (main): Declare variables where they are used instead of
at the start of the function.
This commit is contained in:
Collin Funk
2025-12-07 15:11:55 -08:00
parent dd2a113f5f
commit 2880332ada

View File

@@ -52,8 +52,6 @@ Print the numeric identifier (in hexadecimal) for the current host.\n\
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
unsigned int id;
initialize_main (&argc, &argv); initialize_main (&argc, &argv);
set_program_name (argv[0]); set_program_name (argv[0]);
setlocale (LC_ALL, ""); setlocale (LC_ALL, "");
@@ -72,12 +70,10 @@ main (int argc, char **argv)
usage (EXIT_FAILURE); usage (EXIT_FAILURE);
} }
id = gethostid ();
/* POSIX says gethostid returns a "32-bit identifier" but is silent /* POSIX says gethostid returns a "32-bit identifier" but is silent
whether it's sign-extended. Turn off any sign-extension. This whether it's sign-extended. Turn off any sign-extension. This
is a no-op unless unsigned int is wider than 32 bits. */ is a no-op unless unsigned int is wider than 32 bits. */
id &= 0xffffffff; unsigned int id = gethostid () & 0xffffffff;
printf ("%08x\n", id); printf ("%08x\n", id);