From patchwork Wed Sep 30 13:02:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 7297841 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CCEDF9F1D5 for ; Wed, 30 Sep 2015 13:02:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 98FB22062A for ; Wed, 30 Sep 2015 13:02:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8603D2062B for ; Wed, 30 Sep 2015 13:02:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755397AbbI3NCJ (ORCPT ); Wed, 30 Sep 2015 09:02:09 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:33039 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753913AbbI3NCI (ORCPT ); Wed, 30 Sep 2015 09:02:08 -0400 Received: by wiclk2 with SMTP id lk2so197095791wic.0 for ; Wed, 30 Sep 2015 06:02:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type:content-transfer-encoding; bh=yG5R7qj3QkrYjYMgZB+4dMv7tWUgBBZu/bTFTCM7JXk=; b=QWnp2qiBQjAnqRU+FzSawhgQXEUd0jgtSNYcIiDWNDBeMVWrijJfwFTpThb/WcKKVq 7yWEXInCh6xFQRooOuZeCjsxDeUf/dFpUX92AAQddOyJpmXfnjqNzIpHUxwO1RjxEH/W bBWVfFW6TvPaaXs6j1QNwsH/Lj+p3EEVZCS4GnWliO1C6npEZuV90Pl6tApzXUMqe/k6 /2QOaIHr3AXY0rf9+pklssV2xH24Ct4AJS00tqkz9364Kp4LPoF0RvQW1jjvGsdk2wb0 pvgWdV9DQQg/zf2zUXCC/Sngo1+GHZlzTnt07r7+3854GMJ9zEVYDroEvQ70RQ6O3at5 1r1Q== X-Gm-Message-State: ALoCoQmOUtFYxLlhJYSOdKcySBlYLz13P35uloafouORq5eHnf+GJ927bqnKgSKSElvByr7qr3IM X-Received: by 10.194.204.195 with SMTP id la3mr3987044wjc.77.1443618126823; Wed, 30 Sep 2015 06:02:06 -0700 (PDT) Received: from [192.168.1.101] (c-71-234-225-223.hsd1.ct.comcast.net. [71.234.225.223]) by smtp.googlemail.com with ESMTPSA id fv13sm29513297wic.7.2015.09.30.06.02.05 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Sep 2015 06:02:06 -0700 (PDT) Message-ID: <560BDD4C.8070600@dev.mellanox.co.il> Date: Wed, 30 Sep 2015 09:02:04 -0400 From: Hal Rosenstock User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: "Hefty, Sean" CC: "linux-rdma (linux-rdma@vger.kernel.org)" Subject: [PATCH librdmacm] examples: Use gai_strerror rather than perror for [rdma_]getaddrinfo failures Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP [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 --- -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/examples/cmatose.c b/examples/cmatose.c index ab3e746..d7bd92d 100644 --- a/examples/cmatose.c +++ b/examples/cmatose.c @@ -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; } diff --git a/examples/cmtime.c b/examples/cmtime.c index ebc660b..e45980b 100644 --- a/examples/cmtime.c +++ b/examples/cmtime.c @@ -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; } diff --git a/examples/mckey.c b/examples/mckey.c index a6b5c4d..2032aa9 100644 --- a/examples/mckey.c +++ b/examples/mckey.c @@ -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; } diff --git a/examples/rcopy.c b/examples/rcopy.c index 152acef..085b017 100644 --- a/examples/rcopy.c +++ b/examples/rcopy.c @@ -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; } diff --git a/examples/rdma_client.c b/examples/rdma_client.c index f676b70..d7f65f5 100644 --- a/examples/rdma_client.c +++ b/examples/rdma_client.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -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; } diff --git a/examples/rdma_server.c b/examples/rdma_server.c index 129cf42..d98d11a 100644 --- a/examples/rdma_server.c +++ b/examples/rdma_server.c @@ -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; } diff --git a/examples/rdma_xclient.c b/examples/rdma_xclient.c index 6510408..8dba266 100644 --- a/examples/rdma_xclient.c +++ b/examples/rdma_xclient.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -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; } diff --git a/examples/rdma_xserver.c b/examples/rdma_xserver.c index d30c88e..69f170b 100644 --- a/examples/rdma_xserver.c +++ b/examples/rdma_xserver.c @@ -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; } diff --git a/examples/riostream.c b/examples/riostream.c index c12dd0d..82dcd59 100644 --- a/examples/riostream.c +++ b/examples/riostream.c @@ -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; } diff --git a/examples/rping.c b/examples/rping.c index 9486314..a5aa8c5 100644 --- a/examples/rping.c +++ b/examples/rping.c @@ -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; } diff --git a/examples/rstream.c b/examples/rstream.c index d93e9aa..c88b5b7 100644 --- a/examples/rstream.c +++ b/examples/rstream.c @@ -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; } } diff --git a/examples/udaddy.c b/examples/udaddy.c index 6e68944..5e89ca1 100644 --- a/examples/udaddy.c +++ b/examples/udaddy.c @@ -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; } diff --git a/examples/udpong.c b/examples/udpong.c index 7ec11e8..97713a2 100644 --- a/examples/udpong.c +++ b/examples/udpong.c @@ -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; }