examples: Use gai_strerror rather than perror for [rdma_]getaddrinfo failures
PATCH 1/1 examples: Use gai_strerror rather than perror for [rdma_]getaddrinfo failures
[rdma_]getaddrinfo error codes are decoded by gai_strerror (and not set in errno) so replace perror calls following these failed calls.
---
examples/cmatose.c +2 -2
@@ -509,7 +509,7 @@ static int run_server(void) ret =get_rdma_addr (src_addr, dst_addr, port, &hints, &test.rai);if (ret) { -perror ("cmatose: getrdmaaddr error" ); +printf ("cmatose: getrdmaaddr error: %s\n" ,gai_strerror (ret)); goto out; }
@@ -582,7 +582,7 @@ static int run_client(void) ret =get_rdma_addr (src_addr, dst_addr, port, &hints, &test.rai);if (ret) { -perror ("cmatose: getaddrinfo error" ); +printf ("cmatose: getaddrinfo error: %s\n" ,gai_strerror (ret));return ret; }
examples/cmtime.c +2 -2
@@ -479,7 +479,7 @@ static int run_server(void) ret =get_rdma_addr (src_addr, dst_addr, port, &hints, &rai);if (ret) { -perror ("getrdmaaddr error" ); +printf ("getrdmaaddr error: %s\n" ,gai_strerror (ret)); goto out; }
@@ -508,7 +508,7 @@ static int run_client(void) ret =get_rdma_addr (src_addr, dst_addr, port, &hints, &rai);if (ret) { -perror ("getaddrinfo error" ); +printf ("getaddrinfo error: %s\n" ,gai_strerror (ret));return ret; }
examples/mckey.c +1 -1
@@ -452,7 +452,7 @@ static int get_addr(char *dst, struct sockaddr *addr) ret =getaddrinfo (dst,NULL ,NULL , &res);if (ret) { -printf ("getaddrinfo failed - invalid hostname or IP address\n" ); +printf ("getaddrinfo failed (%s) - invalid hostname or IP address\n" ,gai_strerror (ret));return ret; }
examples/rcopy.c +2 -2
@@ -186,7 +186,7 @@ static int server_listen(void) hints.ai_flags =RAI_PASSIVE ; ret =getaddrinfo (NULL , port, &hints, &res);if (ret) { -perror ("getaddrinfo failed\n" ); +printf ("getaddrinfo failed: %s\n" ,gai_strerror (ret));return ret; }
@@ -396,7 +396,7 @@ static int client_connect(void) ret =getaddrinfo (dst_addr, port,NULL , &res);if (ret) { -perror ("getaddrinfo failed\n" ); +printf ("getaddrinfo failed: %s\n" ,gai_strerror (ret));return ret; }
examples/rdma_client.c +2 -1
@@ -30,6 +30,7 @@#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <netdb.h> #include <errno.h> #include <getopt.h> #include <rdma/rdma_cma.h>
@@ -55,7 +56,7 @@ static int run(void) hints.ai_port_space =RDMA_PS_TCP ; ret =rdma_getaddrinfo (server, port, &hints, &res);if (ret) { -perror ("rdma_getaddrinfo" ); +printf ("rdma_getaddrinfo: %s\n" ,gai_strerror (ret)); goto out; }
examples/rdma_server.c +1 -1
@@ -57,7 +57,7 @@ static int run(void) hints.ai_port_space =RDMA_PS_TCP ; ret =rdma_getaddrinfo (NULL , port, &hints, &res);if (ret) { -perror ("rdma_getaddrinfo" ); +printf ("rdma_getaddrinfo: %s\n" ,gai_strerror (ret));return ret; }
examples/rdma_xclient.c +2 -1
@@ -30,6 +30,7 @@#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <netdb.h> #include <errno.h> #include <getopt.h> #include <ctype.h>
@@ -80,7 +81,7 @@ static int test(void) ret =rdma_getaddrinfo (server, port, &hints, &res);if (ret) { -perror ("rdma_getaddrinfo" ); +printf ("rdma_getaddrinfo: %s\n" ,gai_strerror (ret));return ret; }
examples/rdma_xserver.c +1 -1
@@ -78,7 +78,7 @@ static int test(void) ret =rdma_getaddrinfo (NULL , port, &hints, &res);if (ret) { -perror ("rdma_getaddrinfo" ); +printf ("rdma_getaddrinfo: %s\n" ,gai_strerror (ret));return ret; }
examples/riostream.c +2 -2
@@ -363,7 +363,7 @@ static int server_listen(void) ret =getaddrinfo (src_addr, port, &ai_hints, &ai); }if (ret) { -perror ("getaddrinfo" ); +printf ("getaddrinfo: %s\n" ,gai_strerror (ret));return ret; }
@@ -444,7 +444,7 @@ static int client_connect(void) ret = use_rgai ?rdma_getaddrinfo (dst_addr, port, &rai_hints, &rai) :getaddrinfo (dst_addr, port, &ai_hints, &ai);if (ret) { -perror ("getaddrinfo" ); +printf ("getaddrinfo: %s\n" ,gai_strerror (ret));return ret; }
examples/rping.c +1 -1
@@ -1122,7 +1122,7 @@ static int get_addr(char *dst, struct sockaddr *addr) ret =getaddrinfo (dst,NULL ,NULL , &res);if (ret) { -printf ("getaddrinfo failed - invalid hostname or IP address\n" ); +printf ("getaddrinfo failed (%s) - invalid hostname or IP address\n" ,gai_strerror (ret));return ret; }
examples/rstream.c +3 -3
@@ -327,7 +327,7 @@ static int server_listen(void) ret =getaddrinfo (src_addr, port, &ai_hints, &ai); }if (ret) { -perror ("getaddrinfo" ); +printf ("getaddrinfo: %s\n" ,gai_strerror (ret));return ret; }
@@ -412,7 +412,7 @@ static int client_connect(void)getaddrinfo (dst_addr, port, &ai_hints, &ai);if (ret) { -perror ("getaddrinfo" ); +printf ("getaddrinfo: %s\n" ,gai_strerror (ret));return ret; }
@@ -425,7 +425,7 @@ static int client_connect(void) ret =getaddrinfo (src_addr, port, &ai_hints, &ai_src); }if (ret) { -perror ("getaddrinfo src_addr" ); +printf ("getaddrinfo src_addr: %s\n" ,gai_strerror (ret));return ret; } }
examples/udaddy.c +2 -2
@@ -516,7 +516,7 @@ static int run_server(void) ret =get_rdma_addr (src_addr, dst_addr, port, &hints, &test.rai);if (ret) { -perror ("cmatose: getrdmaaddr error" ); +printf ("udaddy: getrdmaaddr error: %s\n" ,gai_strerror (ret)); goto out; }
@@ -565,7 +565,7 @@ static int run_client(void) ret =get_rdma_addr (src_addr, dst_addr, port, &hints, &test.rai);if (ret) { -perror ("udaddy: getaddrinfo error" ); +printf ("udaddy: getaddrinfo error: %s\n" ,gai_strerror (ret));return ret; }
examples/udpong.c +2 -2
@@ -266,7 +266,7 @@ static int svr_bind(void) hints.ai_socktype =SOCK_DGRAM ; ret =getaddrinfo (src_addr, port, &hints, &res);if (ret) { -perror ("getaddrinfo" ); +printf ("getaddrinfo: %s\n" ,gai_strerror (ret));return ret; }
@@ -411,7 +411,7 @@ static int client_connect(void) hints.ai_socktype =SOCK_DGRAM ; ret =getaddrinfo (dst_addr, port, &hints, &res);if (ret) { -perror ("getaddrinfo" ); +printf ("getaddrinfo: %s\n" ,gai_strerror (ret));return ret; }
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 560BDD4C.8070600-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org
Thanks - merged all 3
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html