iscsi: remove errno lookups for allocations

The only errno value that can usefully be returned from malloc(),
calloc(), realloc(), strdup(), etc. is ENOMEM, so there's no need to
translate the errno value to a string for the error message.

Change-Id: I8e8bd4f12ec4f3b99649760e397e1bc71cca7eff
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/392985
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Daniel Verkamp 2017-12-26 13:59:09 -07:00
parent 591c31f717
commit 026dd8c6b5
5 changed files with 33 additions and 107 deletions

View File

@ -46,7 +46,6 @@ static struct spdk_iscsi_init_grp *
spdk_iscsi_init_grp_create(int tag) spdk_iscsi_init_grp_create(int tag)
{ {
struct spdk_iscsi_init_grp *ig; struct spdk_iscsi_init_grp *ig;
char buf[64];
if (spdk_iscsi_init_grp_find_by_tag(tag)) { if (spdk_iscsi_init_grp_find_by_tag(tag)) {
SPDK_ERRLOG("duplicate initiator group tag (%d)\n", tag); SPDK_ERRLOG("duplicate initiator group tag (%d)\n", tag);
@ -55,9 +54,7 @@ spdk_iscsi_init_grp_create(int tag)
ig = calloc(1, sizeof(*ig)); ig = calloc(1, sizeof(*ig));
if (ig == NULL) { if (ig == NULL) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("calloc() failed for initiator group\n");
SPDK_ERRLOG("calloc() failed for initiator group (tag=%d), errno %d: %s\n",
tag, errno, buf);
return NULL; return NULL;
} }
@ -85,7 +82,6 @@ spdk_iscsi_init_grp_add_initiator(struct spdk_iscsi_init_grp *ig, char *name)
{ {
struct spdk_iscsi_initiator_name *iname; struct spdk_iscsi_initiator_name *iname;
char *p; char *p;
char buf[64];
if (ig->ninitiators >= MAX_INITIATOR) { if (ig->ninitiators >= MAX_INITIATOR) {
SPDK_ERRLOG("> MAX_INITIATOR(=%d) is not allowed\n", MAX_INITIATOR); SPDK_ERRLOG("> MAX_INITIATOR(=%d) is not allowed\n", MAX_INITIATOR);
@ -99,17 +95,13 @@ spdk_iscsi_init_grp_add_initiator(struct spdk_iscsi_init_grp *ig, char *name)
iname = malloc(sizeof(*iname)); iname = malloc(sizeof(*iname));
if (iname == NULL) { if (iname == NULL) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for initiator name str\n");
SPDK_ERRLOG("malloc() failed for initiator name str, errno %d: %s\n",
errno, buf);
return -ENOMEM; return -ENOMEM;
} }
iname->name = strdup(name); iname->name = strdup(name);
if (iname->name == NULL) { if (iname->name == NULL) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("strdup() failed for initiator name\n");
SPDK_ERRLOG("strdup() failed for initiator name, errno %d: %s\n",
errno, buf);
free(iname); free(iname);
return -ENOMEM; return -ENOMEM;
} }
@ -198,7 +190,6 @@ spdk_iscsi_init_grp_add_netmask(struct spdk_iscsi_init_grp *ig, char *mask)
{ {
struct spdk_iscsi_initiator_netmask *imask; struct spdk_iscsi_initiator_netmask *imask;
char *p; char *p;
char buf[64];
if (ig->nnetmasks >= MAX_NETMASK) { if (ig->nnetmasks >= MAX_NETMASK) {
SPDK_ERRLOG("> MAX_NETMASK(=%d) is not allowed\n", MAX_NETMASK); SPDK_ERRLOG("> MAX_NETMASK(=%d) is not allowed\n", MAX_NETMASK);
@ -212,17 +203,13 @@ spdk_iscsi_init_grp_add_netmask(struct spdk_iscsi_init_grp *ig, char *mask)
imask = malloc(sizeof(*imask)); imask = malloc(sizeof(*imask));
if (imask == NULL) { if (imask == NULL) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for inititator mask str\n");
SPDK_ERRLOG("malloc() failed for inititator mask str, errno %d: %s\n",
errno, buf);
return -ENOMEM; return -ENOMEM;
} }
imask->mask = strdup(mask); imask->mask = strdup(mask);
if (imask->mask == NULL) { if (imask->mask == NULL) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("strdup() failed for initiator mask\n");
SPDK_ERRLOG("strdup() failed for initiator mask, errno %d: %s\n",
errno, buf);
free(imask); free(imask);
return -ENOMEM; return -ENOMEM;
} }
@ -304,7 +291,6 @@ spdk_iscsi_init_grp_create_from_configfile(struct spdk_conf_section *sp)
int num_initiator_masks; int num_initiator_masks;
char **initiators = NULL, **netmasks = NULL; char **initiators = NULL, **netmasks = NULL;
int tag = spdk_conf_section_get_num(sp); int tag = spdk_conf_section_get_num(sp);
char buf[64];
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "add initiator group %d\n", tag); SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "add initiator group %d\n", tag);
@ -347,9 +333,7 @@ spdk_iscsi_init_grp_create_from_configfile(struct spdk_conf_section *sp)
initiators = calloc(num_initiator_names, sizeof(char *)); initiators = calloc(num_initiator_names, sizeof(char *));
if (!initiators) { if (!initiators) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("calloc() failed for temp initiator name array\n");
SPDK_ERRLOG("calloc() failed for temp initiator name array, errno %d: %s\n",
errno, buf);
return -ENOMEM; return -ENOMEM;
} }
for (i = 0; i < num_initiator_names; i++) { for (i = 0; i < num_initiator_names; i++) {
@ -362,18 +346,14 @@ spdk_iscsi_init_grp_create_from_configfile(struct spdk_conf_section *sp)
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "InitiatorName %s\n", val); SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "InitiatorName %s\n", val);
initiators[i] = strdup(val); initiators[i] = strdup(val);
if (!initiators[i]) { if (!initiators[i]) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("strdup() failed for temp initiator name\n");
SPDK_ERRLOG("strdup() failed for temp initiator name, errno %d: %s\n",
errno, buf);
rc = -ENOMEM; rc = -ENOMEM;
goto cleanup; goto cleanup;
} }
} }
netmasks = calloc(num_initiator_masks, sizeof(char *)); netmasks = calloc(num_initiator_masks, sizeof(char *));
if (!netmasks) { if (!netmasks) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for portal group\n");
SPDK_ERRLOG("malloc() failed for portal group (tag=%d), errno %d: %s\n",
tag, errno, buf);
rc = -ENOMEM; rc = -ENOMEM;
goto cleanup; goto cleanup;
} }
@ -387,9 +367,7 @@ spdk_iscsi_init_grp_create_from_configfile(struct spdk_conf_section *sp)
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "Netmask %s\n", val); SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "Netmask %s\n", val);
netmasks[i] = strdup(val); netmasks[i] = strdup(val);
if (!netmasks[i]) { if (!netmasks[i]) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("strdup() failed for temp initiator mask\n");
SPDK_ERRLOG("strdup() failed for temp initiator mask, errno %d: %s\n",
errno, buf);
rc = -ENOMEM; rc = -ENOMEM;
goto cleanup; goto cleanup;
} }

View File

@ -774,7 +774,6 @@ spdk_iscsi_get_authinfo(struct spdk_iscsi_conn *conn, const char *authuser)
char *authfile = NULL; char *authfile = NULL;
int ag_tag; int ag_tag;
int rc; int rc;
char buf[64];
if (conn->sess->target != NULL) { if (conn->sess->target != NULL) {
ag_tag = conn->sess->target->auth_group; ag_tag = conn->sess->target->auth_group;
@ -792,9 +791,7 @@ spdk_iscsi_get_authinfo(struct spdk_iscsi_conn *conn, const char *authuser)
authfile = strdup(g_spdk_iscsi.authfile); authfile = strdup(g_spdk_iscsi.authfile);
pthread_mutex_unlock(&g_spdk_iscsi.mutex); pthread_mutex_unlock(&g_spdk_iscsi.mutex);
if (!authfile) { if (!authfile) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("strdup() failed for authfile\n");
SPDK_ERRLOG("strdup() failed from %s to authfile, errno %d: %s\n",
g_spdk_iscsi.authfile, errno, buf);
return -ENOMEM; return -ENOMEM;
} }
@ -822,7 +819,6 @@ spdk_iscsi_auth_params(struct spdk_iscsi_conn *conn,
const char *challenge; const char *challenge;
int total; int total;
int rc; int rc;
char buf[64];
if (conn == NULL || params == NULL || method == NULL) { if (conn == NULL || params == NULL || method == NULL) {
return -1; return -1;
@ -847,9 +843,7 @@ spdk_iscsi_auth_params(struct spdk_iscsi_conn *conn,
/* for temporary store */ /* for temporary store */
in_val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1); in_val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1);
if (!in_val) { if (!in_val) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for temporary store\n");
SPDK_ERRLOG("malloc() failed for temporary store, errno %d: %s\n",
errno, buf);
return -ENOMEM; return -ENOMEM;
} }
@ -1049,7 +1043,6 @@ spdk_iscsi_reject(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu,
int total_ahs_len; int total_ahs_len;
int data_len; int data_len;
int alloc_len; int alloc_len;
char buf[64];
total_ahs_len = pdu->bhs.total_ahs_len; total_ahs_len = pdu->bhs.total_ahs_len;
data_len = 0; data_len = 0;
@ -1061,9 +1054,7 @@ spdk_iscsi_reject(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu,
data = malloc(alloc_len); data = malloc(alloc_len);
if (!data) { if (!data) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for data segment\n");
SPDK_ERRLOG("malloc() failed for data segment, errno %d: %s\n",
errno, buf);
return -ENOMEM; return -ENOMEM;
} }
@ -1839,7 +1830,6 @@ spdk_iscsi_op_login_rsp_init(struct spdk_iscsi_conn *conn,
struct iscsi_bhs_login_req *reqh; struct iscsi_bhs_login_req *reqh;
struct iscsi_bhs_login_rsp *rsph; struct iscsi_bhs_login_rsp *rsph;
int rc; int rc;
char buf[64];
rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs; rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
rsph->opcode = ISCSI_OP_LOGIN_RSP; rsph->opcode = ISCSI_OP_LOGIN_RSP;
@ -1856,9 +1846,7 @@ spdk_iscsi_op_login_rsp_init(struct spdk_iscsi_conn *conn,
rsp_pdu->data = malloc(*alloc_len); rsp_pdu->data = malloc(*alloc_len);
if (!rsp_pdu->data) { if (!rsp_pdu->data) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for data segment\n");
SPDK_ERRLOG("malloc() failed for data segment, errno %d: %s\n",
errno, buf);
return -ENOMEM; return -ENOMEM;
} }
@ -2277,7 +2265,6 @@ spdk_iscsi_op_text(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
int rc; int rc;
struct iscsi_bhs_text_req *reqh; struct iscsi_bhs_text_req *reqh;
struct iscsi_bhs_text_resp *rsph; struct iscsi_bhs_text_resp *rsph;
char buf[64];
data_len = 0; data_len = 0;
alloc_len = conn->MaxRecvDataSegmentLength; alloc_len = conn->MaxRecvDataSegmentLength;
@ -2341,8 +2328,7 @@ spdk_iscsi_op_text(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
data = malloc(alloc_len); data = malloc(alloc_len);
if (!data) { if (!data) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for data segment\n");
SPDK_ERRLOG("malloc() failed for data segment, errno %d: %s\n", errno, buf);
spdk_iscsi_param_free(params); spdk_iscsi_param_free(params);
return -ENOMEM; return -ENOMEM;
} }
@ -3450,7 +3436,6 @@ spdk_iscsi_op_nopout(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
uint32_t CmdSN; uint32_t CmdSN;
int I_bit; int I_bit;
int data_len; int data_len;
char buf[64];
if (conn->sess->session_type == SESSION_TYPE_DISCOVERY) { if (conn->sess->session_type == SESSION_TYPE_DISCOVERY) {
SPDK_ERRLOG("ISCSI_OP_NOPOUT not allowed in discovery session\n"); SPDK_ERRLOG("ISCSI_OP_NOPOUT not allowed in discovery session\n");
@ -3508,9 +3493,7 @@ spdk_iscsi_op_nopout(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
data = malloc(data_len); data = malloc(data_len);
if (!data) { if (!data) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for ping data\n");
SPDK_ERRLOG("malloc() failed for ping data, errno %d: %s\n",
errno, buf);
return SPDK_ISCSI_CONNECTION_FATAL; return SPDK_ISCSI_CONNECTION_FATAL;
} }
memset(data, 0, data_len); memset(data, 0, data_len);
@ -4550,7 +4533,6 @@ spdk_create_iscsi_sess(struct spdk_iscsi_conn *conn,
{ {
struct spdk_iscsi_sess *sess; struct spdk_iscsi_sess *sess;
int rc; int rc;
char buf[64];
sess = spdk_mempool_get(g_spdk_iscsi.session_pool); sess = spdk_mempool_get(g_spdk_iscsi.session_pool);
if (!sess) { if (!sess) {
@ -4589,9 +4571,7 @@ spdk_create_iscsi_sess(struct spdk_iscsi_conn *conn,
sess->conns = malloc(sizeof(*sess->conns) * sess->MaxConnections); sess->conns = malloc(sizeof(*sess->conns) * sess->MaxConnections);
if (!sess->conns) { if (!sess->conns) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for connection array\n");
SPDK_ERRLOG("malloc() failed for connection array, errno %d: %s\n",
errno, buf);
return -ENOMEM; return -ENOMEM;
} }

View File

@ -751,7 +751,6 @@ spdk_iscsi_app_read_parameters(void)
{ {
struct spdk_conf_section *sp; struct spdk_conf_section *sp;
int rc; int rc;
char buf[64];
g_spdk_iscsi.MaxSessions = DEFAULT_MAX_SESSIONS; g_spdk_iscsi.MaxSessions = DEFAULT_MAX_SESSIONS;
g_spdk_iscsi.MaxConnectionsPerSession = DEFAULT_MAX_CONNECTIONS_PER_SESSION; g_spdk_iscsi.MaxConnectionsPerSession = DEFAULT_MAX_CONNECTIONS_PER_SESSION;
@ -788,9 +787,7 @@ spdk_iscsi_app_read_parameters(void)
g_spdk_iscsi.session = spdk_dma_zmalloc(sizeof(void *) * g_spdk_iscsi.MaxSessions, 0, NULL); g_spdk_iscsi.session = spdk_dma_zmalloc(sizeof(void *) * g_spdk_iscsi.MaxSessions, 0, NULL);
if (!g_spdk_iscsi.session) { if (!g_spdk_iscsi.session) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("spdk_dma_zmalloc() failed for session array\n");
SPDK_ERRLOG("spdk_dma_zmalloc() failed for session array, errno %d: %s\n",
errno, buf);
return -1; return -1;
} }

View File

@ -131,7 +131,6 @@ spdk_iscsi_param_add(struct iscsi_param **params, const char *key,
const char *val, const char *list, int type) const char *val, const char *list, int type)
{ {
struct iscsi_param *param, *last_param; struct iscsi_param *param, *last_param;
char buf[64];
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "add %s=%s, list=[%s], type=%d\n", SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "add %s=%s, list=[%s], type=%d\n",
key, val, list, type); key, val, list, type);
@ -144,14 +143,13 @@ spdk_iscsi_param_add(struct iscsi_param **params, const char *key,
spdk_iscsi_param_del(params, key); spdk_iscsi_param_del(params, key);
} }
param = malloc(sizeof * param); param = malloc(sizeof(*param));
if (!param) { if (!param) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for parameter\n");
SPDK_ERRLOG("malloc() failed for parameter, errno %d: %s\n", errno, buf);
return -ENOMEM; return -ENOMEM;
} }
memset(param, 0, sizeof * param); memset(param, 0, sizeof(*param));
param->next = NULL; param->next = NULL;
param->key = xstrdup(key); param->key = xstrdup(key);
param->val = xstrdup(val); param->val = xstrdup(val);
@ -225,7 +223,6 @@ spdk_iscsi_parse_param(struct iscsi_param **params, const uint8_t *data)
const uint8_t *key_end, *val; const uint8_t *key_end, *val;
int key_len, val_len; int key_len, val_len;
int max_len; int max_len;
char buf[64];
key_end = strchr(data, '='); key_end = strchr(data, '=');
if (!key_end) { if (!key_end) {
@ -248,8 +245,7 @@ spdk_iscsi_parse_param(struct iscsi_param **params, const uint8_t *data)
key_copy = malloc(key_len + 1); key_copy = malloc(key_len + 1);
if (!key_copy) { if (!key_copy) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for key_copy\n");
SPDK_ERRLOG("malloc() failed for key_copy, errno %d: %s\n", errno, buf);
return -ENOMEM; return -ENOMEM;
} }
@ -524,12 +520,10 @@ spdk_iscsi_special_param_construction(struct spdk_iscsi_conn *conn,
uint32_t FirstBurstLength; uint32_t FirstBurstLength;
uint32_t MaxBurstLength; uint32_t MaxBurstLength;
char *val; char *val;
char buf[64];
val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1); val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1);
if (!val) { if (!val) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for temporary buffer\n");
SPDK_ERRLOG("malloc() failed for temporary buffer, errno %d: %s\n", errno, buf);
return -ENOMEM; return -ENOMEM;
} }
@ -891,7 +885,6 @@ spdk_iscsi_negotiate_params(struct spdk_iscsi_conn *conn,
uint32_t MaxBurstLength; uint32_t MaxBurstLength;
bool FirstBurstLength_flag = false; bool FirstBurstLength_flag = false;
int type; int type;
char buf[64];
total = data_len; total = data_len;
if (alloc_len < 1) { if (alloc_len < 1) {
@ -929,23 +922,20 @@ spdk_iscsi_negotiate_params(struct spdk_iscsi_conn *conn,
/* for temporary store */ /* for temporary store */
valid_list = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1); valid_list = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1);
if (!valid_list) { if (!valid_list) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for valid_list\n");
SPDK_ERRLOG("malloc() failed for valid_list, errno %d: %s\n", errno, buf);
return -ENOMEM; return -ENOMEM;
} }
in_val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1); in_val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1);
if (!in_val) { if (!in_val) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for in_val\n");
SPDK_ERRLOG("malloc() failed for in_val, errno %d: %s\n", errno, buf);
free(valid_list); free(valid_list);
return -ENOMEM; return -ENOMEM;
} }
cur_val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1); cur_val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1);
if (!cur_val) { if (!cur_val) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for cur_val\n");
SPDK_ERRLOG("malloc() failed for cur_val, errno %d: %s\n", errno, buf);
free(valid_list); free(valid_list);
free(in_val); free(in_val);
return -ENOMEM; return -ENOMEM;

View File

@ -70,7 +70,6 @@ struct spdk_iscsi_portal *
spdk_iscsi_portal_create(const char *host, const char *port, uint64_t cpumask) spdk_iscsi_portal_create(const char *host, const char *port, uint64_t cpumask)
{ {
struct spdk_iscsi_portal *p = NULL; struct spdk_iscsi_portal *p = NULL;
char buf[64];
assert(host != NULL); assert(host != NULL);
assert(port != NULL); assert(port != NULL);
@ -83,9 +82,7 @@ spdk_iscsi_portal_create(const char *host, const char *port, uint64_t cpumask)
p = malloc(sizeof(*p)); p = malloc(sizeof(*p));
if (!p) { if (!p) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for portal\n");
SPDK_ERRLOG("malloc() failed for portal (%s, %s), errno %d: %s\n",
host, port, errno, buf);
return NULL; return NULL;
} }
@ -174,7 +171,6 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring,
uint64_t cpumask = 0; uint64_t cpumask = 0;
int n, len, rc = -1; int n, len, rc = -1;
const char *p, *q; const char *p, *q;
char buf[64];
if (portalstring == NULL) { if (portalstring == NULL) {
SPDK_ERRLOG("portal error\n"); SPDK_ERRLOG("portal error\n");
@ -193,9 +189,7 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring,
if (!dry_run) { if (!dry_run) {
host = malloc(n + 1); host = malloc(n + 1);
if (!host) { if (!host) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for host\n");
SPDK_ERRLOG("malloc() failed for host, errno %d: %s\n",
errno, buf);
goto error_out; goto error_out;
} }
memcpy(host, portalstring, n); memcpy(host, portalstring, n);
@ -205,9 +199,7 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring,
if (!dry_run) { if (!dry_run) {
port = malloc(PORTNUMSTRLEN); port = malloc(PORTNUMSTRLEN);
if (!port) { if (!port) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for port\n");
SPDK_ERRLOG("malloc() failed for port, errno %d: %s\n",
errno, buf);
goto error_out; goto error_out;
} }
snprintf(port, PORTNUMSTRLEN, "%d", DEFAULT_PORT); snprintf(port, PORTNUMSTRLEN, "%d", DEFAULT_PORT);
@ -226,9 +218,7 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring,
port = malloc(len + 1); port = malloc(len + 1);
if (!port) { if (!port) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for port\n");
SPDK_ERRLOG("malloc() failed for port, errno %d: %s\n",
errno, buf);
goto error_out; goto error_out;
} }
memset(port, 0, len + 1); memset(port, 0, len + 1);
@ -245,9 +235,7 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring,
if (!dry_run) { if (!dry_run) {
host = malloc(n + 1); host = malloc(n + 1);
if (!host) { if (!host) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for host\n");
SPDK_ERRLOG("malloc() failed for host, errno %d: %s\n",
errno, buf);
goto error_out; goto error_out;
} }
memcpy(host, portalstring, n); memcpy(host, portalstring, n);
@ -257,9 +245,7 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring,
if (!dry_run) { if (!dry_run) {
port = malloc(PORTNUMSTRLEN); port = malloc(PORTNUMSTRLEN);
if (!port) { if (!port) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for port\n");
SPDK_ERRLOG("malloc() failed for port, errno %d: %s\n",
errno, buf);
goto error_out; goto error_out;
} }
snprintf(port, PORTNUMSTRLEN, "%d", DEFAULT_PORT); snprintf(port, PORTNUMSTRLEN, "%d", DEFAULT_PORT);
@ -283,9 +269,7 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring,
len = q - p - 1; len = q - p - 1;
port = malloc(len + 1); port = malloc(len + 1);
if (!port) { if (!port) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for port\n");
SPDK_ERRLOG("malloc() failed for port, errno %d: %s\n",
errno, buf);
goto error_out; goto error_out;
} }
memset(port, 0, len + 1); memset(port, 0, len + 1);
@ -333,13 +317,10 @@ error_out:
static struct spdk_iscsi_portal_grp * static struct spdk_iscsi_portal_grp *
spdk_iscsi_portal_grp_create(int tag) spdk_iscsi_portal_grp_create(int tag)
{ {
char buf[64];
struct spdk_iscsi_portal_grp *pg = malloc(sizeof(*pg)); struct spdk_iscsi_portal_grp *pg = malloc(sizeof(*pg));
if (!pg) { if (!pg) {
spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("malloc() failed for portal group\n");
SPDK_ERRLOG("malloc() failed for portal group (tag=%d), errno %d: %s\n",
tag, errno, buf);
return NULL; return NULL;
} }