summaryrefslogtreecommitdiff
path: root/src/network/gethostbyname2_r.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2013-02-02 01:31:10 -0500
committerRich Felker <dalias@aerifal.cx>2013-02-02 01:31:10 -0500
commit70b584bc9467ce939c73898212c17be1ab7e39af (patch)
treec9b94f2bcf2f0f5e41edb5cccbe07680d644e5a2 /src/network/gethostbyname2_r.c
parent74025c80ce1eb4cda110ab2e3ac11718d3c6f2ff (diff)
downloadmusl-70b584bc9467ce939c73898212c17be1ab7e39af.tar.gz
fix error returns in gethostby*_r functions
they're supposed to return an error code rather than using errno.
Diffstat (limited to 'src/network/gethostbyname2_r.c')
-rw-r--r--src/network/gethostbyname2_r.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/network/gethostbyname2_r.c b/src/network/gethostbyname2_r.c
index c2ed75b4..49e4e531 100644
--- a/src/network/gethostbyname2_r.c
+++ b/src/network/gethostbyname2_r.c
@@ -25,10 +25,7 @@ int gethostbyname2_r(const char *name, int af,
/* Align buffer */
i = (uintptr_t)buf & sizeof(char *)-1;
if (i) {
- if (buflen < sizeof(char *)-i) {
- errno = ERANGE;
- return -1;
- }
+ if (buflen < sizeof(char *)-i) return ERANGE;
buf += sizeof(char *)-i;
buflen -= sizeof(char *)-i;
}
@@ -37,16 +34,16 @@ int gethostbyname2_r(const char *name, int af,
switch (getaddrinfo(name, 0, &hint, &ai)) {
case EAI_NONAME:
*err = HOST_NOT_FOUND;
- return -1;
+ return errno;
case EAI_AGAIN:
*err = TRY_AGAIN;
- return -1;
+ return errno;
default:
case EAI_MEMORY:
case EAI_SYSTEM:
case EAI_FAIL:
*err = NO_RECOVERY;
- return -1;
+ return errno;
case 0:
break;
}
@@ -63,8 +60,7 @@ int gethostbyname2_r(const char *name, int af,
if (need > buflen) {
freeaddrinfo(ai);
- errno = ERANGE;
- return -1;
+ return ERANGE;
}
h->h_aliases = (void *)buf;