diff --git a/lib/iscsi/init_grp.c b/lib/iscsi/init_grp.c index 0b1d8f74e..f1ec86312 100644 --- a/lib/iscsi/init_grp.c +++ b/lib/iscsi/init_grp.c @@ -46,7 +46,6 @@ static struct spdk_iscsi_init_grp * spdk_iscsi_init_grp_create(int tag) { struct spdk_iscsi_init_grp *ig; - char buf[64]; if (spdk_iscsi_init_grp_find_by_tag(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)); if (ig == NULL) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("calloc() failed for initiator group (tag=%d), errno %d: %s\n", - tag, errno, buf); + SPDK_ERRLOG("calloc() failed for initiator group\n"); 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; char *p; - char buf[64]; if (ig->ninitiators >= 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)); if (iname == NULL) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for initiator name str, errno %d: %s\n", - errno, buf); + SPDK_ERRLOG("malloc() failed for initiator name str\n"); return -ENOMEM; } iname->name = strdup(name); if (iname->name == NULL) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("strdup() failed for initiator name, errno %d: %s\n", - errno, buf); + SPDK_ERRLOG("strdup() failed for initiator name\n"); free(iname); 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; char *p; - char buf[64]; if (ig->nnetmasks >= 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)); if (imask == NULL) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for inititator mask str, errno %d: %s\n", - errno, buf); + SPDK_ERRLOG("malloc() failed for inititator mask str\n"); return -ENOMEM; } imask->mask = strdup(mask); if (imask->mask == NULL) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("strdup() failed for initiator mask, errno %d: %s\n", - errno, buf); + SPDK_ERRLOG("strdup() failed for initiator mask\n"); free(imask); return -ENOMEM; } @@ -304,7 +291,6 @@ spdk_iscsi_init_grp_create_from_configfile(struct spdk_conf_section *sp) int num_initiator_masks; char **initiators = NULL, **netmasks = NULL; int tag = spdk_conf_section_get_num(sp); - char buf[64]; 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 *)); if (!initiators) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("calloc() failed for temp initiator name array, errno %d: %s\n", - errno, buf); + SPDK_ERRLOG("calloc() failed for temp initiator name array\n"); return -ENOMEM; } 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); initiators[i] = strdup(val); if (!initiators[i]) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("strdup() failed for temp initiator name, errno %d: %s\n", - errno, buf); + SPDK_ERRLOG("strdup() failed for temp initiator name\n"); rc = -ENOMEM; goto cleanup; } } netmasks = calloc(num_initiator_masks, sizeof(char *)); if (!netmasks) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for portal group (tag=%d), errno %d: %s\n", - tag, errno, buf); + SPDK_ERRLOG("malloc() failed for portal group\n"); rc = -ENOMEM; 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); netmasks[i] = strdup(val); if (!netmasks[i]) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("strdup() failed for temp initiator mask, errno %d: %s\n", - errno, buf); + SPDK_ERRLOG("strdup() failed for temp initiator mask\n"); rc = -ENOMEM; goto cleanup; } diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index 42bf94d04..b8274ede0 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -774,7 +774,6 @@ spdk_iscsi_get_authinfo(struct spdk_iscsi_conn *conn, const char *authuser) char *authfile = NULL; int ag_tag; int rc; - char buf[64]; if (conn->sess->target != NULL) { 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); pthread_mutex_unlock(&g_spdk_iscsi.mutex); if (!authfile) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("strdup() failed from %s to authfile, errno %d: %s\n", - g_spdk_iscsi.authfile, errno, buf); + SPDK_ERRLOG("strdup() failed for authfile\n"); return -ENOMEM; } @@ -822,7 +819,6 @@ spdk_iscsi_auth_params(struct spdk_iscsi_conn *conn, const char *challenge; int total; int rc; - char buf[64]; if (conn == NULL || params == NULL || method == NULL) { return -1; @@ -847,9 +843,7 @@ spdk_iscsi_auth_params(struct spdk_iscsi_conn *conn, /* for temporary store */ in_val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1); if (!in_val) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for temporary store, errno %d: %s\n", - errno, buf); + SPDK_ERRLOG("malloc() failed for temporary store\n"); return -ENOMEM; } @@ -1049,7 +1043,6 @@ spdk_iscsi_reject(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu, int total_ahs_len; int data_len; int alloc_len; - char buf[64]; total_ahs_len = pdu->bhs.total_ahs_len; data_len = 0; @@ -1061,9 +1054,7 @@ spdk_iscsi_reject(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu, data = malloc(alloc_len); if (!data) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for data segment, errno %d: %s\n", - errno, buf); + SPDK_ERRLOG("malloc() failed for data segment\n"); 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_rsp *rsph; int rc; - char buf[64]; rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs; 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); if (!rsp_pdu->data) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for data segment, errno %d: %s\n", - errno, buf); + SPDK_ERRLOG("malloc() failed for data segment\n"); return -ENOMEM; } @@ -2277,7 +2265,6 @@ spdk_iscsi_op_text(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu) int rc; struct iscsi_bhs_text_req *reqh; struct iscsi_bhs_text_resp *rsph; - char buf[64]; data_len = 0; 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); if (!data) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for data segment, errno %d: %s\n", errno, buf); + SPDK_ERRLOG("malloc() failed for data segment\n"); spdk_iscsi_param_free(params); return -ENOMEM; } @@ -3450,7 +3436,6 @@ spdk_iscsi_op_nopout(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu) uint32_t CmdSN; int I_bit; int data_len; - char buf[64]; if (conn->sess->session_type == SESSION_TYPE_DISCOVERY) { 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); if (!data) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for ping data, errno %d: %s\n", - errno, buf); + SPDK_ERRLOG("malloc() failed for ping data\n"); return SPDK_ISCSI_CONNECTION_FATAL; } memset(data, 0, data_len); @@ -4550,7 +4533,6 @@ spdk_create_iscsi_sess(struct spdk_iscsi_conn *conn, { struct spdk_iscsi_sess *sess; int rc; - char buf[64]; sess = spdk_mempool_get(g_spdk_iscsi.session_pool); if (!sess) { @@ -4589,9 +4571,7 @@ spdk_create_iscsi_sess(struct spdk_iscsi_conn *conn, sess->conns = malloc(sizeof(*sess->conns) * sess->MaxConnections); if (!sess->conns) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for connection array, errno %d: %s\n", - errno, buf); + SPDK_ERRLOG("malloc() failed for connection array\n"); return -ENOMEM; } diff --git a/lib/iscsi/iscsi_subsystem.c b/lib/iscsi/iscsi_subsystem.c index d481e3767..98c3c87e3 100644 --- a/lib/iscsi/iscsi_subsystem.c +++ b/lib/iscsi/iscsi_subsystem.c @@ -751,7 +751,6 @@ spdk_iscsi_app_read_parameters(void) { struct spdk_conf_section *sp; int rc; - char buf[64]; g_spdk_iscsi.MaxSessions = DEFAULT_MAX_SESSIONS; 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); if (!g_spdk_iscsi.session) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("spdk_dma_zmalloc() failed for session array, errno %d: %s\n", - errno, buf); + SPDK_ERRLOG("spdk_dma_zmalloc() failed for session array\n"); return -1; } diff --git a/lib/iscsi/param.c b/lib/iscsi/param.c index 96c07c6eb..740e7cf3b 100644 --- a/lib/iscsi/param.c +++ b/lib/iscsi/param.c @@ -131,7 +131,6 @@ spdk_iscsi_param_add(struct iscsi_param **params, const char *key, const char *val, const char *list, int type) { struct iscsi_param *param, *last_param; - char buf[64]; SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "add %s=%s, list=[%s], type=%d\n", 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); } - param = malloc(sizeof * param); + param = malloc(sizeof(*param)); if (!param) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for parameter, errno %d: %s\n", errno, buf); + SPDK_ERRLOG("malloc() failed for parameter\n"); return -ENOMEM; } - memset(param, 0, sizeof * param); + memset(param, 0, sizeof(*param)); param->next = NULL; param->key = xstrdup(key); 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; int key_len, val_len; int max_len; - char buf[64]; key_end = strchr(data, '='); 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); if (!key_copy) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for key_copy, errno %d: %s\n", errno, buf); + SPDK_ERRLOG("malloc() failed for key_copy\n"); return -ENOMEM; } @@ -524,12 +520,10 @@ spdk_iscsi_special_param_construction(struct spdk_iscsi_conn *conn, uint32_t FirstBurstLength; uint32_t MaxBurstLength; char *val; - char buf[64]; val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1); if (!val) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for temporary buffer, errno %d: %s\n", errno, buf); + SPDK_ERRLOG("malloc() failed for temporary buffer\n"); return -ENOMEM; } @@ -891,7 +885,6 @@ spdk_iscsi_negotiate_params(struct spdk_iscsi_conn *conn, uint32_t MaxBurstLength; bool FirstBurstLength_flag = false; int type; - char buf[64]; total = data_len; if (alloc_len < 1) { @@ -929,23 +922,20 @@ spdk_iscsi_negotiate_params(struct spdk_iscsi_conn *conn, /* for temporary store */ valid_list = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1); if (!valid_list) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for valid_list, errno %d: %s\n", errno, buf); + SPDK_ERRLOG("malloc() failed for valid_list\n"); return -ENOMEM; } in_val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1); if (!in_val) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for in_val, errno %d: %s\n", errno, buf); + SPDK_ERRLOG("malloc() failed for in_val\n"); free(valid_list); return -ENOMEM; } cur_val = malloc(ISCSI_TEXT_MAX_VAL_LEN + 1); if (!cur_val) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for cur_val, errno %d: %s\n", errno, buf); + SPDK_ERRLOG("malloc() failed for cur_val\n"); free(valid_list); free(in_val); return -ENOMEM; diff --git a/lib/iscsi/portal_grp.c b/lib/iscsi/portal_grp.c index 34a4017e9..fceed3949 100644 --- a/lib/iscsi/portal_grp.c +++ b/lib/iscsi/portal_grp.c @@ -70,7 +70,6 @@ struct spdk_iscsi_portal * spdk_iscsi_portal_create(const char *host, const char *port, uint64_t cpumask) { struct spdk_iscsi_portal *p = NULL; - char buf[64]; assert(host != 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)); if (!p) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for portal (%s, %s), errno %d: %s\n", - host, port, errno, buf); + SPDK_ERRLOG("malloc() failed for portal\n"); return NULL; } @@ -174,7 +171,6 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring, uint64_t cpumask = 0; int n, len, rc = -1; const char *p, *q; - char buf[64]; if (portalstring == NULL) { SPDK_ERRLOG("portal error\n"); @@ -193,9 +189,7 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring, if (!dry_run) { host = malloc(n + 1); if (!host) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for host, errno %d: %s\n", - errno, buf); + SPDK_ERRLOG("malloc() failed for host\n"); goto error_out; } memcpy(host, portalstring, n); @@ -205,9 +199,7 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring, if (!dry_run) { port = malloc(PORTNUMSTRLEN); if (!port) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for port, errno %d: %s\n", - errno, buf); + SPDK_ERRLOG("malloc() failed for port\n"); goto error_out; } snprintf(port, PORTNUMSTRLEN, "%d", DEFAULT_PORT); @@ -226,9 +218,7 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring, port = malloc(len + 1); if (!port) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for port, errno %d: %s\n", - errno, buf); + SPDK_ERRLOG("malloc() failed for port\n"); goto error_out; } memset(port, 0, len + 1); @@ -245,9 +235,7 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring, if (!dry_run) { host = malloc(n + 1); if (!host) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for host, errno %d: %s\n", - errno, buf); + SPDK_ERRLOG("malloc() failed for host\n"); goto error_out; } memcpy(host, portalstring, n); @@ -257,9 +245,7 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring, if (!dry_run) { port = malloc(PORTNUMSTRLEN); if (!port) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for port, errno %d: %s\n", - errno, buf); + SPDK_ERRLOG("malloc() failed for port\n"); goto error_out; } snprintf(port, PORTNUMSTRLEN, "%d", DEFAULT_PORT); @@ -283,9 +269,7 @@ spdk_iscsi_portal_create_from_configline(const char *portalstring, len = q - p - 1; port = malloc(len + 1); if (!port) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for port, errno %d: %s\n", - errno, buf); + SPDK_ERRLOG("malloc() failed for port\n"); goto error_out; } memset(port, 0, len + 1); @@ -333,13 +317,10 @@ error_out: static struct spdk_iscsi_portal_grp * spdk_iscsi_portal_grp_create(int tag) { - char buf[64]; struct spdk_iscsi_portal_grp *pg = malloc(sizeof(*pg)); if (!pg) { - spdk_strerror_r(errno, buf, sizeof(buf)); - SPDK_ERRLOG("malloc() failed for portal group (tag=%d), errno %d: %s\n", - tag, errno, buf); + SPDK_ERRLOG("malloc() failed for portal group\n"); return NULL; }