Remove h_errno container from struct getnamaddr
Test: built, flashed, booted
system/netd/tests/runtests.sh pass
Change-Id: I9fd8735b2ea7565342b899715afef13b1c0692f6
diff --git a/sethostent.cpp b/sethostent.cpp
index cfe4d28..49cc236 100644
--- a/sethostent.cpp
+++ b/sethostent.cpp
@@ -72,13 +72,11 @@
sethostent_r(&hf);
if (hf == NULL) {
errno = EINVAL;
- *info->he = NETDB_INTERNAL;
// TODO: Consider to remap error code without relying on errno.
return EAI_SYSTEM;
}
if ((ptr = buf = (char*) malloc(len = info->buflen)) == NULL) {
- *info->he = NETDB_INTERNAL;
return EAI_MEMORY;
}
@@ -91,9 +89,10 @@
info->hp->h_addrtype = af;
info->hp->h_length = 0;
- hp = netbsd_gethostent_r(hf, info->hp, info->buf, info->buflen, info->he);
+ int herrno;
+ hp = netbsd_gethostent_r(hf, info->hp, info->buf, info->buflen, &herrno);
if (hp == NULL) {
- if (*info->he == NETDB_INTERNAL && errno == ENOSPC) {
+ if (herrno == NETDB_INTERNAL && errno == ENOSPC) {
goto nospc; // glibc compatibility.
}
break;
@@ -128,9 +127,10 @@
endhostent_r(&hf);
if (num == 0) {
- *info->he = HOST_NOT_FOUND;
free(buf);
- // TODO: Perhaps convert HOST_NOT_FOUND to EAI_NONAME instead
+ // TODO: Perhaps convert HOST_NOT_FOUND to EAI_NONAME instead.
+ // The original return error number is h_errno HOST_NOT_FOUND which was converted to
+ // EAI_NODATA.
return EAI_NODATA;
}
@@ -164,7 +164,6 @@
free(buf);
return 0;
nospc:
- *info->he = NETDB_INTERNAL;
free(buf);
errno = ENOSPC;
return EAI_MEMORY;
@@ -177,19 +176,20 @@
FILE* hf = NULL;
sethostent_r(&hf);
if (hf == NULL) {
- *info->he = NETDB_INTERNAL;
// TODO: Consider to remap error code without relying on errno.
return EAI_SYSTEM;
}
struct hostent* hp;
- while ((hp = netbsd_gethostent_r(hf, info->hp, info->buf, info->buflen, info->he)) != NULL)
+ int herrno;
+ while ((hp = netbsd_gethostent_r(hf, info->hp, info->buf, info->buflen, &herrno)) != NULL)
if (!memcmp(hp->h_addr_list[0], uaddr, (size_t) hp->h_length)) break;
endhostent_r(&hf);
if (hp == NULL) {
if (errno == ENOSPC) return EAI_MEMORY; // glibc compatibility.
- *info->he = HOST_NOT_FOUND;
- // TODO: Perhaps convert HOST_NOT_FOUND to EAI_NONAME instead
+ // TODO: Perhaps convert HOST_NOT_FOUND to EAI_NONAME instead.
+ // The original return error number is h_errno HOST_NOT_FOUND which was converted to
+ // EAI_NODATA.
return EAI_NODATA;
}
return 0;