aboutsummaryrefslogtreecommitdiff
path: root/toys/hostname.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-02-15 05:55:38 -0600
committerRob Landley <rob@landley.net>2012-02-15 05:55:38 -0600
commit7bc392fa6298fd3aa0bc2b6d4e4956d205d42e7e (patch)
tree22df9e1330dd3b7d28280a32790504841ef3a134 /toys/hostname.c
parentb083b8c048c365eb3db031532c353be7a76c379e (diff)
downloadtoybox-7bc392fa6298fd3aa0bc2b6d4e4956d205d42e7e.tar.gz
Minor cleanups to hostname.
Diffstat (limited to 'toys/hostname.c')
-rw-r--r--toys/hostname.c10
1 files 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);
}
}