]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
From patchwork Wed Sep 30 13:02:04 2015
authorSean Hefty <sean.hefty@intel.com>
Tue, 6 Oct 2015 20:18:20 +0000 (13:18 -0700)
committerSean Hefty <sean.hefty@intel.com>
Tue, 6 Oct 2015 20:18:20 +0000 (13:18 -0700)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [librdmacm] examples: Use gai_strerror rather than perror for
[rdma_]getaddrinfo failures
From: Hal Rosenstock <hal@dev.mellanox.co.il>
X-Patchwork-Id: 7297841
Message-Id: <560BDD4C.8070600@dev.mellanox.co.il>
To: "Hefty, Sean" <sean.hefty@intel.com>
Cc: "linux-rdma (linux-rdma@vger.kernel.org)" <linux-rdma@vger.kernel.org>
Date: Wed, 30 Sep 2015 09:02:04 -0400

[rdma_]getaddrinfo error codes are decoded by gai_strerror (and not
set in errno) so replace perror calls following these failed calls.

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
13 files changed:
examples/cmatose.c
examples/cmtime.c
examples/mckey.c
examples/rcopy.c
examples/rdma_client.c
examples/rdma_server.c
examples/rdma_xclient.c
examples/rdma_xserver.c
examples/riostream.c
examples/rping.c
examples/rstream.c
examples/udaddy.c
examples/udpong.c

index ab3e7462d20cfa7dd15f4313e8bc2f11a15d8ae8..d7bd92d724681ca4444b18adbd0e7ffb958b1e65 100644 (file)
@@ -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;
        }
 
index ebc660ba56a502b1885202129128783d06b760ed..e45980b9bb043a2fa2cf836ad1025a624d456536 100644 (file)
@@ -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;
        }
 
index a6b5c4d74e19ea80eaf0971daecebc7853cf6b55..2032aa994242340668589a0f8516373c7cb07bb8 100644 (file)
@@ -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;
        }
 
index 152acef235995a594c8f318529178a916b665b3c..085b0171dc46ece06e8eb7b354cdd1a212627220 100644 (file)
@@ -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;
        }
 
index f676b7023f0b8f762ecfcf21ae95a9f9d3cb04bb..d7f65f55f20ba44f6d2859a29bdd53ed62313e44 100644 (file)
@@ -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;
        }
 
index 129cf428f948b4b7150c61ffff447506c9fc121d..d98d11a1cae5006795b49a289d13cf4843adea41 100644 (file)
@@ -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;
        }
 
index 65104083a8d98b9920a7475ae2e3df931d9a5dd2..8dba266ae7f6d1bc5987d7e2c07d66d13845ffcd 100644 (file)
@@ -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;
        }
 
index d30c88e6008ee972dd440748e2f529c45e129e73..69f170bb1f41e47f320e60a84ae200aa88a4013a 100644 (file)
@@ -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;
        }
 
index c12dd0d40f8eef1869a09c7f39e808a3ae096bcb..326028abbe165075bd29f90e83f885b8807f11d1 100644 (file)
@@ -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;
        }
 
@@ -470,8 +470,10 @@ static int client_connect(void)
                fds.fd = rs;
                fds.events = POLLOUT;
                ret = do_poll(&fds, poll_timeout);
-               if (ret)
+               if (ret) {
+                       perror("rpoll");
                        goto close;
+               }
 
                len = sizeof err;
                ret = rgetsockopt(rs, SOL_SOCKET, SO_ERROR, &err, &len);
index 94863143eb45ba50ce7bcc31645d920bdf5f5af5..a5aa8c5f38d6762c6b6672adc7097484f3b99bae 100644 (file)
@@ -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;
        }
 
index d93e9aaf6f1cdaf13fe7b4e8afb0471961316bf9..8e1e73076db1c617c04ad49ffe8d5bb82d814d82 100644 (file)
@@ -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;
        }
 
@@ -421,11 +421,11 @@ static int client_connect(void)
                        rai_hints.ai_flags |= RAI_PASSIVE;
                        ret = rdma_getaddrinfo(src_addr, port, &rai_hints, &rai_src);
                } else {
-                       ai_hints.ai_flags |= RAI_PASSIVE;
+                       ai_hints.ai_flags |= AI_PASSIVE;
                        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;
                }
        }
@@ -469,8 +469,10 @@ static int client_connect(void)
                fds.fd = rs;
                fds.events = POLLOUT;
                ret = do_poll(&fds, poll_timeout);
-               if (ret)
+               if (ret) {
+                       perror("rpoll");
                        goto close;
+               }
 
                len = sizeof err;
                ret = rs_getsockopt(rs, SOL_SOCKET, SO_ERROR, &err, &len);
index 6e6894482830694e26e672014ae1969a96514426..5e89ca1e1d75c25bf338a000ab53998507085b5a 100644 (file)
@@ -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;
        }
 
index 7ec11e85ae50b8082d529dc016082cfe6558d680..97713a297cf9add2a17a943a956f8de0442226f4 100644 (file)
@@ -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;
        }