about summary refs log tree commit diff
path: root/src/network/gethostbyaddr_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/gethostbyaddr_r.c
parent74025c80ce1eb4cda110ab2e3ac11718d3c6f2ff (diff)
downloadmusl-70b584bc9467ce939c73898212c17be1ab7e39af.tar.gz
musl-70b584bc9467ce939c73898212c17be1ab7e39af.tar.xz
musl-70b584bc9467ce939c73898212c17be1ab7e39af.zip
fix error returns in gethostby*_r functions
they're supposed to return an error code rather than using errno.
Diffstat (limited to 'src/network/gethostbyaddr_r.c')
-rw-r--r--src/network/gethostbyaddr_r.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/network/gethostbyaddr_r.c b/src/network/gethostbyaddr_r.c
index cdb1d503..73e76447 100644
--- a/src/network/gethostbyaddr_r.c
+++ b/src/network/gethostbyaddr_r.c
@@ -23,16 +23,13 @@ int gethostbyaddr_r(const void *a, socklen_t l, int af,
 	else if (af==AF_INET && l==4) memcpy(&sa.sin.sin_addr, a, 4);
 	else {
 		*err = NO_RECOVERY;
-		return -1;
+		return EINVAL;
 	}
 
 	/* Align buffer and check for space for pointers and ip address */
 	i = (uintptr_t)buf & sizeof(char *)-1;
 	if (!i) i = sizeof(char *);
-	if (buflen <= 5*sizeof(char *)-i + l) {
-		errno = ERANGE;
-		return -1;
-	}
+	if (buflen <= 5*sizeof(char *)-i + l) return ERANGE;
 	buf += sizeof(char *)-i;
 	buflen -= 5*sizeof(char *)-i + l;
 
@@ -51,15 +48,15 @@ int gethostbyaddr_r(const void *a, socklen_t l, int af,
 	switch (getnameinfo((void *)&sa, sl, buf, buflen, 0, 0, 0)) {
 	case EAI_AGAIN:
 		*err = TRY_AGAIN;
-		return -1;
+		return EAGAIN;
 	case EAI_OVERFLOW:
-		errno = ERANGE;
+		return ERANGE;
 	default:
 	case EAI_MEMORY:
 	case EAI_SYSTEM:
 	case EAI_FAIL:
 		*err = NO_RECOVERY;
-		return -1;
+		return errno;
 	case 0:
 		break;
 	}