Mercurial > hg > toybox
changeset 464:9e1fe8e287a2
Minor cleanups to hostname.
author | Rob Landley <rob@landley.net> |
---|---|
date | Wed, 15 Feb 2012 05:55:38 -0600 |
parents | dc88e450288c |
children | ab6c0adfcc10 |
files | toys/hostname.c |
diffstat | 1 files changed, 4 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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); } }