diff options
author | Yang Tse <yangsita@gmail.com> | 2007-02-16 15:04:44 +0000 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2007-02-16 15:04:44 +0000 |
commit | 059b57677c14ac832249193042f0cf61e9c15ff2 (patch) | |
tree | 677f58ef1e078e03ff26d6fc977b3296fcb2163b /ares/inet_ntop.c | |
parent | 9896421586996265e8320fbe253da004215c8a12 (diff) |
use macros ERRNO, SET_ERRNO(), SOCKERRNO and SET_SOCKERRNO() for errno handling
Diffstat (limited to 'ares/inet_ntop.c')
-rw-r--r-- | ares/inet_ntop.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ares/inet_ntop.c b/ares/inet_ntop.c index 097e7764e..f076e0665 100644 --- a/ares/inet_ntop.c +++ b/ares/inet_ntop.c @@ -68,6 +68,11 @@ static const char *inet_ntop6(const unsigned char *src, char *dst, size_t size); * convert a network format address to presentation format. * return: * pointer to presentation format address (`dst'), or NULL (see errno). + * note: + * On Windows we store the error in the thread errno, not + * in the winsock error code. This is to avoid loosing the + * actual last winsock error. So use macro ERRNO to fetch the + * errno this funtion sets when returning NULL, not SOCKERRNO. * author: * Paul Vixie, 1996. */ @@ -81,7 +86,7 @@ ares_inet_ntop(int af, const void *src, char *dst, size_t size) case AF_INET6: return (inet_ntop6(src, dst, size)); default: - errno = EAFNOSUPPORT; + SET_ERRNO(EAFNOSUPPORT); return (NULL); } /* NOTREACHED */ @@ -106,7 +111,7 @@ inet_ntop4(const unsigned char *src, char *dst, size_t size) if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) > size) { - errno = ENOSPC; + SET_ERRNO(ENOSPC); return (NULL); } strcpy(dst, tmp); @@ -218,7 +223,7 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size) */ if ((size_t)(tp - tmp) > size) { - errno = ENOSPC; + SET_ERRNO(ENOSPC); return (NULL); } strcpy(dst, tmp); |