summaryrefslogtreecommitdiff
path: root/lib/xgethostname.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1994-05-20 13:50:43 +0000
committerJim Meyering <jim@meyering.net>1994-05-20 13:50:43 +0000
commitb98b0e107f67055d20db6005b6dee676a79c06a7 (patch)
treec8c093359626907c5ed207d60fc5d6811da8e11b /lib/xgethostname.c
parenta0f30b3f2c9254411cce3cde1639980b623bcb75 (diff)
downloadcoreutils-b98b0e107f67055d20db6005b6dee676a79c06a7.tar.xz
merge with 1.10 + local build mods
Diffstat (limited to 'lib/xgethostname.c')
-rw-r--r--lib/xgethostname.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/xgethostname.c b/lib/xgethostname.c
index 86408e775..9973b45be 100644
--- a/lib/xgethostname.c
+++ b/lib/xgethostname.c
@@ -46,12 +46,12 @@ xgethostname ()
int err;
size = INITIAL_HOSTNAME_LENGTH;
+ hostname = xmalloc (size);
while (1)
{
- hostname = xmalloc (size);
hostname[size - 1] = '\0';
err = gethostname (hostname, size);
- if (err || hostname[size - 1] == '\0')
+ if (err == 0 && hostname[size - 1] == '\0')
break;
size *= 2;
hostname = xrealloc (hostname, size);