Added checks to memory allocation failure when using asprintf in pingpong tests.
Signed-off-by: Dotan Barak <[EMAIL PROTECTED]>
---
Index: gen2_devel_user/src/userspace/libibverbs/examples/rc_pingpong.c
===================================================================
--- gen2_devel_user.orig/src/userspace/libibverbs/examples/rc_pingpong.c
2007-01-15 17:02:23.000000000 +0200
+++ gen2_devel_user/src/userspace/libibverbs/examples/rc_pingpong.c
2007-01-16 09:56:52.000000000 +0200
@@ -139,7 +139,9 @@ static struct pingpong_dest *pp_client_e
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_e
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: gen2_devel_user/src/userspace/libibverbs/examples/srq_pingpong.c
===================================================================
--- gen2_devel_user.orig/src/userspace/libibverbs/examples/srq_pingpong.c
2007-01-15 17:02:23.000000000 +0200
+++ gen2_devel_user/src/userspace/libibverbs/examples/srq_pingpong.c
2007-01-16 09:57:25.000000000 +0200
@@ -150,7 +150,9 @@ static struct pingpong_dest *pp_client_e
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_e
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: gen2_devel_user/src/userspace/libibverbs/examples/uc_pingpong.c
===================================================================
--- gen2_devel_user.orig/src/userspace/libibverbs/examples/uc_pingpong.c
2007-01-15 17:02:23.000000000 +0200
+++ gen2_devel_user/src/userspace/libibverbs/examples/uc_pingpong.c
2007-01-16 09:57:54.000000000 +0200
@@ -127,7 +127,9 @@ static struct pingpong_dest *pp_client_e
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_e
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: gen2_devel_user/src/userspace/libibverbs/examples/ud_pingpong.c
===================================================================
--- gen2_devel_user.orig/src/userspace/libibverbs/examples/ud_pingpong.c
2007-01-15 17:02:23.000000000 +0200
+++ gen2_devel_user/src/userspace/libibverbs/examples/ud_pingpong.c
2007-01-16 09:58:22.000000000 +0200
@@ -128,7 +128,9 @@ static struct pingpong_dest *pp_client_e
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_e
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) {
_______________________________________________
openib-general mailing list
[email protected]
http://openib.org/mailman/listinfo/openib-general
To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general