From e92b2004e20e1c8e6bc56f97bf4a45c6da4a630c Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Fri, 31 May 2013 17:23:00 +0200 Subject: [PATCH] Use strerror() instead of gai_strerror() when err == EAI_SYSTEM. --- src/net_setup.c | 3 +-- src/netutl.c | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/net_setup.c b/src/net_setup.c index 747dbd89..c61a9012 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -938,8 +938,7 @@ static bool setup_myself(void) { free(address); if(err || !ai) { - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "getaddrinfo", - gai_strerror(err)); + logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "getaddrinfo", err == EAI_SYSTEM ? strerror(err) : gai_strerror(err)); return false; } diff --git a/src/netutl.c b/src/netutl.c index a55eaea2..66834697 100644 --- a/src/netutl.c +++ b/src/netutl.c @@ -42,8 +42,7 @@ struct addrinfo *str2addrinfo(const char *address, const char *service, int sock err = getaddrinfo(address, service, &hint, &ai); if(err) { - logger(DEBUG_ALWAYS, LOG_WARNING, "Error looking up %s port %s: %s", address, - service, gai_strerror(err)); + logger(DEBUG_ALWAYS, LOG_WARNING, "Error looking up %s port %s: %s", address, service, err == EAI_SYSTEM ? strerror(errno) : gai_strerror(err)); return NULL; } @@ -92,8 +91,7 @@ void sockaddr2str(const sockaddr_t *sa, char **addrstr, char **portstr) { err = getnameinfo(&sa->sa, SALEN(sa->sa), address, sizeof address, port, sizeof port, NI_NUMERICHOST | NI_NUMERICSERV); if(err) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while translating addresses: %s", - gai_strerror(err)); + logger(DEBUG_ALWAYS, LOG_ERR, "Error while translating addresses: %s", err == EAI_SYSTEM ? strerror(errno) : gai_strerror(err)); abort(); } @@ -122,8 +120,7 @@ char *sockaddr2hostname(const sockaddr_t *sa) { err = getnameinfo(&sa->sa, SALEN(sa->sa), address, sizeof address, port, sizeof port, hostnames ? 0 : (NI_NUMERICHOST | NI_NUMERICSERV)); if(err) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while looking up hostname: %s", - gai_strerror(err)); + logger(DEBUG_ALWAYS, LOG_ERR, "Error while looking up hostname: %s", err == EAI_SYSTEM ? strerror(errno) : gai_strerror(err)); } xasprintf(&str, "%s port %s", address, port); -- 2.39.5