From: Michael Poole Date: Sun, 15 Jun 2008 13:23:22 +0000 (-0400) Subject: Use correct error string for getaddrinfo() and getnameinfo() failures. X-Git-Tag: v1.4.0-rc3~12 X-Git-Url: http://git.pk910.de/?p=srvx.git;a=commitdiff_plain;h=b4caaa6cd7399af3254d80f6f82f33b28cbec029 Use correct error string for getaddrinfo() and getnameinfo() failures. src/ioset.c (ioset_connect): Include the error string when getaddrinfo() fails. src/mail-smtp.c (smtp_fill_name): Use gai_strerror() rather than strerror(). --- diff --git a/src/ioset.c b/src/ioset.c index ced561f..30eb359 100644 --- a/src/ioset.c +++ b/src/ioset.c @@ -267,8 +267,9 @@ ioset_connect(struct sockaddr *local, unsigned int sa_size, const char *peer, un hints.ai_family = local ? local->sa_family : 0; hints.ai_socktype = SOCK_STREAM; snprintf(portnum, sizeof(portnum), "%u", port); - if (getaddrinfo(peer, portnum, &hints, &ai)) { - log_module(MAIN_LOG, LOG_ERROR, "getaddrinfo(%s, %s) failed.", peer, portnum); + res = getaddrinfo(peer, portnum, &hints, &ai); + if (res != 0) { + log_module(MAIN_LOG, LOG_ERROR, "getaddrinfo(%s, %s) failed: %s.", peer, portnum, gai_strerror(res)); return NULL; } diff --git a/src/mail-smtp.c b/src/mail-smtp.c index 9ec083d..b1b5095 100644 --- a/src/mail-smtp.c +++ b/src/mail-smtp.c @@ -138,7 +138,7 @@ static void smtp_fill_name(char *namebuf, size_t buflen) } res = getnameinfo(sa, sa_len, namebuf, buflen, NULL, 0, NI_NUMERICHOST); if (res != 0) { - log_module(MAIL_LOG, LOG_ERROR, "Unable to get text form of socket name: %s", strerror(errno)); + log_module(MAIL_LOG, LOG_ERROR, "Unable to get text form of socket name: %s", gai_strerror(res)); } }