Commit f6866117 authored by Tomasz Zawadzki's avatar Tomasz Zawadzki Committed by Jim Harris
Browse files

freebsd: return negated error from getaddrinfo()



On FreeBSD getaddrinfo() report positive error code
values, meanwhile Linux does it with negative ones.

Make sure that regardless of the system used,
error codes with same sign are reported.
This can be observed in the log reported in #2936.

Besides the above, in some instances replaced EINVAL
with the actual return value.

Change-Id: I7f88c314bdf5c3a03f8661c2213e33b2fc276ef7
Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17097


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent 7b56cc45
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ iscsi_parse_redirect_addr(struct sockaddr_storage *sa,
	rc = getaddrinfo(host, port, &hints, &res);
	if (rc != 0) {
		SPDK_ERRLOG("getaddinrfo failed: %s (%d)\n", gai_strerror(rc), rc);
		return -EINVAL;
		return -(abs(rc));
	}

	if (res->ai_addrlen > sizeof(*sa)) {
+1 −1
Original line number Diff line number Diff line
@@ -282,7 +282,7 @@ spdk_jsonrpc_client_connect(const char *addr, int addr_family)
		rc = getaddrinfo(host, port, &hints, &res);
		if (rc != 0) {
			SPDK_ERRLOG("Unable to look up RPC connect address '%s' (%d): %s\n", addr, rc, gai_strerror(rc));
			rc = -EINVAL;
			rc = -(abs(rc));
			goto err;
		}

+1 −1
Original line number Diff line number Diff line
@@ -1256,7 +1256,7 @@ nvme_rdma_parse_addr(struct sockaddr_storage *sa, int family, const char *addr,
	ret = getaddrinfo(addr, service, &hints, &res);
	if (ret) {
		SPDK_ERRLOG("getaddrinfo failed: %s (%d)\n", gai_strerror(ret), ret);
		return ret;
		return -(abs(ret));
	}

	if (res->ai_addrlen > sizeof(*sa)) {
+1 −1
Original line number Diff line number Diff line
@@ -225,7 +225,7 @@ nvme_tcp_parse_addr(struct sockaddr_storage *sa, int family, const char *addr, c
	ret = getaddrinfo(addr, service, &hints, &res);
	if (ret) {
		SPDK_ERRLOG("getaddrinfo failed: %s (%d)\n", gai_strerror(ret), ret);
		return ret;
		return -(abs(ret));
	}

	if (res->ai_addrlen > sizeof(*sa)) {
+1 −1
Original line number Diff line number Diff line
@@ -2856,7 +2856,7 @@ nvmf_rdma_listen(struct spdk_nvmf_transport *transport, const struct spdk_nvme_t
	if (rc) {
		SPDK_ERRLOG("getaddrinfo failed: %s (%d)\n", gai_strerror(rc), rc);
		free(port);
		return -EINVAL;
		return -(abs(rc));
	}

	rc = rdma_create_id(rtransport->event_channel, &port->id, port, RDMA_PS_TCP);