Change in libosmocore[master]: socket: Log proper getaddrinfo() error

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Thu Aug 20 16:28:56 UTC 2020


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/19737 )


Change subject: socket: Log proper getaddrinfo() error
......................................................................

socket: Log proper getaddrinfo() error

Drop one of the two log lines since it would be a duplicated and anyway
it misses context (return code).

Change-Id: I4620bf86f4bcda58ae85209278ac9ae9a0f3012a
---
M src/socket.c
M tests/socket/socket_test.err
2 files changed, 5 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/37/19737/1

diff --git a/src/socket.c b/src/socket.c
index 4d6f389..03c932c 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -85,8 +85,8 @@
 
 	rc = getaddrinfo(host, portbuf, &hints, &result);
 	if (rc != 0) {
-		LOGP(DLGLOBAL, LOGL_ERROR, "getaddrinfo returned NULL: %s:%u: %s\n",
-			host, port, strerror(errno));
+		LOGP(DLGLOBAL, LOGL_ERROR, "getaddrinfo(%s, %u) failed: %s\n",
+			host, port, gai_strerror(rc));
 		return NULL;
 	}
 
@@ -695,11 +695,8 @@
 	}
 
 	result = addrinfo_helper(family, type, proto, host, port, flags & OSMO_SOCK_F_BIND);
-	if (!result) {
-		LOGP(DLGLOBAL, LOGL_ERROR, "getaddrinfo returned NULL: %s:%u: %s\n",
-			host, port, strerror(errno));
+	if (!result)
 		return -EINVAL;
-	}
 
 	for (rp = result; rp != NULL; rp = rp->ai_next) {
 		sfd = socket_helper(rp, flags);
diff --git a/tests/socket/socket_test.err b/tests/socket/socket_test.err
index 3c5dac5..e3d3903 100644
--- a/tests/socket/socket_test.err
+++ b/tests/socket/socket_test.err
@@ -8,5 +8,5 @@
 invalid: you have to specify either BIND or CONNECT flags
 Invalid v4 vs v6 in local vs remote addresses
 Invalid v4 vs v6 in local vs remote addresses
-getaddrinfo returned NULL: ::1:0: Transport endpoint is not connected
-getaddrinfo returned NULL: 127.0.0.1:0: Transport endpoint is not connected
+getaddrinfo(::1, 0) failed: Address family for hostname not supported
+getaddrinfo(127.0.0.1, 0) failed: Address family for hostname not supported

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/19737
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I4620bf86f4bcda58ae85209278ac9ae9a0f3012a
Gerrit-Change-Number: 19737
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200820/3b01fa74/attachment.htm>


More information about the gerrit-log mailing list