[openib-general] [perftest] [PATCH] Added checks to memory allocation failure when using asprintf
Dotan Barak
dotanb at dev.mellanox.co.il
Tue Jan 16 01:54:19 PST 2007
Added checks to memory allocation failure when using asprintf.
Signed-off-by: Dotan Barak <dotanb at mellanox.co.il>
---
Index: gen2_devel_user/src/userspace/perftest/rdma_bw.c
===================================================================
--- gen2_devel_user.orig/src/userspace/perftest/rdma_bw.c 2007-01-15 19:11:32.000000000 +0200
+++ gen2_devel_user/src/userspace/perftest/rdma_bw.c 2007-01-16 10:17:07.000000000 +0200
@@ -134,7 +134,9 @@ static struct pingpong_context *pp_clien
struct pingpong_context *ctx = NULL;
struct rdma_conn_param conn_param;
- asprintf(&service, "%d", data->port);
+ if (asprintf(&service, "%d", data->port) < 0)
+ goto err4;
+
n = getaddrinfo(data->servername, service, &hints, &res);
if (n < 0) {
@@ -324,7 +326,9 @@ static struct pingpong_context *pp_serve
struct rdma_cm_id *child_cm_id;
struct rdma_conn_param conn_param;
- asprintf(&service, "%d", data->port);
+ if (asprintf(&service, "%d", data->port))
+ goto err5;
+
if ( (n = getaddrinfo(NULL, service, &hints, &res)) < 0 ) {
fprintf(stderr, "%d:%s: %s for port %d\n", pid, __func__,
gai_strerror(n), data->port);
Index: gen2_devel_user/src/userspace/perftest/rdma_lat.c
===================================================================
--- gen2_devel_user.orig/src/userspace/perftest/rdma_lat.c 2007-01-15 19:11:32.000000000 +0200
+++ gen2_devel_user/src/userspace/perftest/rdma_lat.c 2007-01-16 10:17:36.000000000 +0200
@@ -208,7 +208,9 @@ static struct pingpong_context *pp_clien
struct pingpong_context *ctx = NULL;
struct rdma_conn_param conn_param;
- asprintf(&service, "%d", data->port);
+ if (asprintf(&service, "%d", data->port) < 0)
+ goto err4;
+
n = getaddrinfo(data->servername, service, &hints, &res);
if (n < 0) {
@@ -368,7 +370,9 @@ static struct pingpong_context *pp_serve
struct rdma_cm_id *child_cm_id;
struct rdma_conn_param conn_param;
- asprintf(&service, "%d", data->port);
+ if (asprintf(&service, "%d", data->port) < 0)
+ goto err5;
+
if ( (n = getaddrinfo(NULL, service, &hints, &res)) < 0 ) {
fprintf(stderr, "%d:%s: %s for port %d\n", pid, __func__,
gai_strerror(n), data->port);
Index: gen2_devel_user/src/userspace/perftest/read_bw.c
===================================================================
--- gen2_devel_user.orig/src/userspace/perftest/read_bw.c 2007-01-15 17:02:22.000000000 +0200
+++ gen2_devel_user/src/userspace/perftest/read_bw.c 2007-01-16 10:18:26.000000000 +0200
@@ -117,7 +117,9 @@ static int pp_client_connect(const char
int n;
int sockfd = -1;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return -1;
+
n = getaddrinfo(servername, service, &hints, &res);
if (n < 0) {
@@ -195,7 +197,9 @@ int pp_server_connect(int port)
int sockfd = -1, connfd;
int n;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return -1;
+
n = getaddrinfo(NULL, service, &hints, &res);
if (n < 0) {
Index: gen2_devel_user/src/userspace/perftest/read_lat.c
===================================================================
--- gen2_devel_user.orig/src/userspace/perftest/read_lat.c 2007-01-15 17:02:22.000000000 +0200
+++ gen2_devel_user/src/userspace/perftest/read_lat.c 2007-01-16 10:19:03.000000000 +0200
@@ -189,7 +189,9 @@ static int pp_client_connect(const char
int n;
int sockfd = -1;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return -1;
+
n = getaddrinfo(servername, service, &hints, &res);
if (n < 0) {
@@ -237,7 +239,9 @@ static int pp_server_connect(int port)
int sockfd = -1, connfd;
int n;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return -1;
+
n = getaddrinfo(NULL, service, &hints, &res);
if (n < 0) {
Index: gen2_devel_user/src/userspace/perftest/send_bw.c
===================================================================
--- gen2_devel_user.orig/src/userspace/perftest/send_bw.c 2007-01-15 17:02:22.000000000 +0200
+++ gen2_devel_user/src/userspace/perftest/send_bw.c 2007-01-16 10:19:33.000000000 +0200
@@ -127,7 +127,9 @@ static int pp_client_connect(const char
int n;
int sockfd = -1;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return -1;
+
n = getaddrinfo(servername, service, &hints, &res);
if (n < 0) {
@@ -205,7 +207,9 @@ int pp_server_connect(int port)
int sockfd = -1, connfd;
int n;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return -1;
+
n = getaddrinfo(NULL, service, &hints, &res);
if (n < 0) {
Index: gen2_devel_user/src/userspace/perftest/send_lat.c
===================================================================
--- gen2_devel_user.orig/src/userspace/perftest/send_lat.c 2007-01-15 17:02:22.000000000 +0200
+++ gen2_devel_user/src/userspace/perftest/send_lat.c 2007-01-16 10:28:05.000000000 +0200
@@ -198,7 +198,9 @@ static int pp_client_connect(const char
int n;
int sockfd = -1;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return -1;
+
n = getaddrinfo(servername, service, &hints, &res);
if (n < 0) {
@@ -246,7 +248,9 @@ static int pp_server_connect(int port)
int sockfd = -1, connfd;
int n;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return -1;
+
n = getaddrinfo(NULL, service, &hints, &res);
if (n < 0) {
Index: gen2_devel_user/src/userspace/perftest/write_bw.c
===================================================================
--- gen2_devel_user.orig/src/userspace/perftest/write_bw.c 2007-01-15 17:02:22.000000000 +0200
+++ gen2_devel_user/src/userspace/perftest/write_bw.c 2007-01-16 10:26:23.000000000 +0200
@@ -126,7 +126,9 @@ static int pp_client_connect(const char
int n;
int sockfd = -1;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return -1;
+
n = getaddrinfo(servername, service, &hints, &res);
if (n < 0) {
@@ -204,7 +206,9 @@ int pp_server_connect(int port)
int sockfd = -1, connfd;
int n;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return -1;
+
n = getaddrinfo(NULL, service, &hints, &res);
if (n < 0) {
Index: gen2_devel_user/src/userspace/perftest/write_bw_postlist.c
===================================================================
--- gen2_devel_user.orig/src/userspace/perftest/write_bw_postlist.c 2007-01-15 17:02:22.000000000 +0200
+++ gen2_devel_user/src/userspace/perftest/write_bw_postlist.c 2007-01-16 10:26:52.000000000 +0200
@@ -126,7 +126,9 @@ static int pp_client_connect(const char
int n;
int sockfd = -1;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return -1;
+
n = getaddrinfo(servername, service, &hints, &res);
if (n < 0) {
@@ -204,7 +206,9 @@ int pp_server_connect(int port)
int sockfd = -1, connfd;
int n;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return -1;
+
n = getaddrinfo(NULL, service, &hints, &res);
if (n < 0) {
Index: gen2_devel_user/src/userspace/perftest/write_lat.c
===================================================================
--- gen2_devel_user.orig/src/userspace/perftest/write_lat.c 2007-01-15 17:02:21.000000000 +0200
+++ gen2_devel_user/src/userspace/perftest/write_lat.c 2007-01-16 10:27:38.000000000 +0200
@@ -186,7 +186,9 @@ static int pp_client_connect(const char
int n;
int sockfd = -1;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return -1;
+
n = getaddrinfo(servername, service, &hints, &res);
if (n < 0) {
@@ -234,7 +236,9 @@ static int pp_server_connect(int port)
int sockfd = -1, connfd;
int n;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return -1;
+
n = getaddrinfo(NULL, service, &hints, &res);
if (n < 0) {
More information about the general
mailing list