# HG changeset patch # User Rob Landley # Date 1329306938 21600 # Node ID 9e1fe8e287a2fd5c845ce2df8ba68cabca54b703 # Parent dc88e450288c42acb7d0f1e2a5245aeb95d4b2a9 Minor cleanups to hostname. diff -r dc88e450288c -r 9e1fe8e287a2 toys/hostname.c --- a/toys/hostname.c Wed Feb 15 05:47:38 2012 -0600 +++ b/toys/hostname.c Wed Feb 15 05:55:38 2012 -0600 @@ -6,7 +6,7 @@ * * Not in SUSv4. -USE_HOSTNAME(NEWTOY(hostname, "", TOYFLAG_BIN)) +USE_HOSTNAME(NEWTOY(hostname, NULL, TOYFLAG_BIN)) config HOSTNAME bool "hostname" @@ -23,13 +23,11 @@ { const char *hostname = toys.optargs[0]; if (hostname) { - int len = strlen(hostname); - if (sethostname(hostname, len)) + if (sethostname(hostname, strlen(hostname))) perror_exit("cannot set hostname to '%s'", hostname); } else { - char buffer[256]; - if (gethostname(buffer, sizeof(buffer))) + if (gethostname(toybuf, sizeof(toybuf))) perror_exit("cannot get hostname"); - xprintf("%s\n", buffer); + xputs(toybuf); } }