aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDotan Barak <dotanb@mellanox.co.il>2007-01-17 13:59:21 -0800
committerRoland Dreier <rolandd@cisco.com>2007-01-17 13:59:50 -0800
commit58668e3d297c92e1610c3e28b5b6476c181cd21d (patch)
tree79bd10e34d03a73ac5892c48b0af69c712c70b6d
parent596803fbae8ff5e2e50b5a99b3e84ee6b3603779 (diff)
downloadlibibverbs-58668e3d297c92e1610c3e28b5b6476c181cd21d.tar.gz
Check asprintf() return in pingpong examples
Handle asprintf() allocation failures in pingpong examples. Signed-off-by: Dotan Barak <dotanb@mellanox.co.il> Signed-off-by: Roland Dreier <rolandd@cisco.com> (cherry picked from commit db39573253488a800ad3a57bf8846902c090450f)
-rw-r--r--examples/rc_pingpong.c8
-rw-r--r--examples/srq_pingpong.c8
-rw-r--r--examples/uc_pingpong.c8
-rw-r--r--examples/ud_pingpong.c8
4 files changed, 24 insertions, 8 deletions
diff --git a/examples/rc_pingpong.c b/examples/rc_pingpong.c
index 82a0b5b..0e17cfb 100644
--- a/examples/rc_pingpong.c
+++ b/examples/rc_pingpong.c
@@ -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) {
diff --git a/examples/srq_pingpong.c b/examples/srq_pingpong.c
index 212b3c2..30dad47 100644
--- a/examples/srq_pingpong.c
+++ b/examples/srq_pingpong.c
@@ -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) {
diff --git a/examples/uc_pingpong.c b/examples/uc_pingpong.c
index aa4659c..55460d7 100644
--- a/examples/uc_pingpong.c
+++ b/examples/uc_pingpong.c
@@ -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) {
diff --git a/examples/ud_pingpong.c b/examples/ud_pingpong.c
index 15f2879..50a91df 100644
--- a/examples/ud_pingpong.c
+++ b/examples/ud_pingpong.c
@@ -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) {