Re: [PATCH rdma-core] librdmacm: Store error code from getaddrinfo in errno

Jason Gunthorpe
2017-11-07T15:56:02Z

On Tue, Nov 07, 2017 at 11:50:38AM +0200, Yuval Shaia wrote:
> +++ b/librdmacm/addrinfo.c
> @@ -227,7 +227,7 @@ static int ucma_getaddrinfo(const char *node, const char *service,
> ret = getaddrinfo(node, service, NULL, &ai);
> }
> if (ret)
> - return ret;
> + return ERR(ret);

No, you cannot assign the return value from getaddrinfo directly errno, they
are not the same number space.

> diff --git a/librdmacm/examples/cmatose.c b/librdmacm/examples/cmatose.c
> index b1c9dd13..625849ce 100644
> +++ b/librdmacm/examples/cmatose.c
> @@ -507,7 +507,7 @@ static int run_server(void)
>
> ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai);
> if (ret) {
> - printf("cmatose: getrdmaaddr error: %s\n", gai_strerror(ret));
> + printf("cmatose: getrdmaaddr error: %s\n", gai_strerror(errno));

Also nope, gai_strerror does not process errnos.

Jason