]> git.openfabrics.org - ~shefty/libibverbs.git/commitdiff
Check asprintf() return in pingpong examples
authorDotan Barak <dotanb@mellanox.co.il>
Wed, 17 Jan 2007 21:59:21 +0000 (13:59 -0800)
committerRoland Dreier <rolandd@cisco.com>
Wed, 17 Jan 2007 21:59:21 +0000 (13:59 -0800)
Handle asprintf() allocation failures in pingpong examples.

Signed-off-by: Dotan Barak <dotanb@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
examples/rc_pingpong.c
examples/srq_pingpong.c
examples/uc_pingpong.c
examples/ud_pingpong.c

index 82a0b5b0db8ccad9e5f8c4abda65bf88e72eefce..0e17cfb04b310ef1272af31ff39b4f5daf0af976 100644 (file)
@@ -139,7 +139,9 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por
        int sockfd = -1;
        struct pingpong_dest *rem_dest = NULL;
 
-       asprintf(&service, "%d", port);
+       if (asprintf(&service, "%d", port) < 0)
+               return NULL;
+
        n = getaddrinfo(servername, service, &hints, &res);
 
        if (n < 0) {
@@ -205,7 +207,9 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
        int sockfd = -1, connfd;
        struct pingpong_dest *rem_dest = NULL;
 
-       asprintf(&service, "%d", port);
+       if (asprintf(&service, "%d", port) < 0)
+               return NULL;
+
        n = getaddrinfo(NULL, service, &hints, &res);
 
        if (n < 0) {
index 212b3c2245dd39eb1e7812c89081a44e21459838..30dad47dd042ab9f97bbb5cc17f3550d7c70ea72 100644 (file)
@@ -150,7 +150,9 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por
        int sockfd = -1;
        struct pingpong_dest *rem_dest = NULL;
 
-       asprintf(&service, "%d", port);
+       if (asprintf(&service, "%d", port) < 0)
+               return NULL;
+
        n = getaddrinfo(servername, service, &hints, &res);
 
        if (n < 0) {
@@ -229,7 +231,9 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
        int sockfd = -1, connfd;
        struct pingpong_dest *rem_dest = NULL;
 
-       asprintf(&service, "%d", port);
+       if (asprintf(&service, "%d", port) < 0)
+               return NULL;
+
        n = getaddrinfo(NULL, service, &hints, &res);
 
        if (n < 0) {
index aa4659c6db4abda465b9955465d6c03a96ed6fd8..55460d73506336c9b8eab7339d259214000b2ee9 100644 (file)
@@ -127,7 +127,9 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por
        int sockfd = -1;
        struct pingpong_dest *rem_dest = NULL;
 
-       asprintf(&service, "%d", port);
+       if (asprintf(&service, "%d", port) < 0)
+               return NULL;
+
        n = getaddrinfo(servername, service, &hints, &res);
 
        if (n < 0) {
@@ -193,7 +195,9 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
        int sockfd = -1, connfd;
        struct pingpong_dest *rem_dest = NULL;
 
-       asprintf(&service, "%d", port);
+       if (asprintf(&service, "%d", port) < 0)
+               return NULL;
+
        n = getaddrinfo(NULL, service, &hints, &res);
 
        if (n < 0) {
index 15f28794b0d632f44fcd29ee3de8d45f699fc030..50a91dfb3b3e32609643cda2d57ec176586054aa 100644 (file)
@@ -128,7 +128,9 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por
        int sockfd = -1;
        struct pingpong_dest *rem_dest = NULL;
 
-       asprintf(&service, "%d", port);
+       if (asprintf(&service, "%d", port) < 0)
+               return NULL;
+
        n = getaddrinfo(servername, service, &hints, &res);
 
        if (n < 0) {
@@ -194,7 +196,9 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
        int sockfd = -1, connfd;
        struct pingpong_dest *rem_dest = NULL;
 
-       asprintf(&service, "%d", port);
+       if (asprintf(&service, "%d", port) < 0)
+               return NULL;
+
        n = getaddrinfo(NULL, service, &hints, &res);
 
        if (n < 0) {