From 7bc392fa6298fd3aa0bc2b6d4e4956d205d42e7e Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 15 Feb 2012 05:55:38 -0600 Subject: Minor cleanups to hostname. --- toys/hostname.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/toys/hostname.c b/toys/hostname.c index b51fd86b..5f1c20e7 100644 --- a/toys/hostname.c +++ b/toys/hostname.c @@ -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 @@ void hostname_main(void) { 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); } } -- cgit v1.2.3