--- src/bin/hostname/hostname.c 2004/11/07 20:54:51 1.12 +++ src/bin/hostname/hostname.c 2005/03/21 16:59:31 1.13 @@ -40,11 +40,9 @@ #include #include #include -#include #include #include - #include #include #include @@ -53,7 +51,6 @@ #include #include - #include #include #include @@ -140,18 +137,17 @@ main(int argc, char **argv) iflag |= HST_IF_V6; break; case 'i': - siflag = strdup(optarg); + siflag = optarg; silen = strlen(siflag); iflag |= HST_IF; break; case 'r': - srflag = strdup(optarg); + srflag = optarg; rflag = 1; break; case 's': sflag = 1; break; - case '?': default: usage(); } @@ -189,11 +185,11 @@ main(int argc, char **argv) needed = 1; if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) - errx(1, "iflist-sysctl-estimate:%i",errno); + err(1, "sysctl: iflist-sysctl-estimate"); if ((buf = malloc(needed)) == NULL) - errx(1, "malloc"); + err(1, "malloc failed"); if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) - errx(1, "actual retrieval of interface table"); + err(1, "sysctl: retrieval of interface table"); lim = buf + needed; @@ -260,11 +256,12 @@ main(int argc, char **argv) if (h_errno == NETDB_SUCCESS) { if (sethostname(hst->h_name, (int)strlen(hst->h_name))) - errx(1, "sethostname"); + err(1, "sethostname"); } else if (h_errno == HOST_NOT_FOUND) { errx(1,"hostname not found"); } else { - errx(1,"gethostbyaddr"); + herror("gethostbyaddr"); + exit(1); } } else if (rflag) { ret = inet_pton(AF_INET, srflag, &ia);