X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=inline;f=src%2Fnetwork%2Fgethostbyname2_r.c;h=27eb080f8502128179fcaa92a9bf15c8b66ea4f9;hb=73871ee3f21b13b88f2f20a39a1d9bc751bcc1df;hp=c2ed75b4de77063da8cfa63b7b9b0a40b9eefbc5;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01;p=musl diff --git a/src/network/gethostbyname2_r.c b/src/network/gethostbyname2_r.c index c2ed75b4..27eb080f 100644 --- a/src/network/gethostbyname2_r.c +++ b/src/network/gethostbyname2_r.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include int gethostbyname2_r(const char *name, int af, struct hostent *h, char *buf, size_t buflen, @@ -25,28 +25,24 @@ 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; } - getaddrinfo(name, 0, &hint, &ai); 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 +59,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;