1
1

oshmem: Fix set of coverity issues

List of CIDs (scan.coverity.com):
1269721, 1269725, 1269787, 1269907, 1269909, 1269910, 1269911, 1269912,
1269959, 1269960, 1269984, 1269985, 1270136, 1270157, 1269845, 1269875,
1269876, 1269877, 1269878, 1269884, 1269885, 1270161, 1270162, 1270175,
1269734, 1269739, 1269742, 1269743

Signed-off-by: Igor Ivanov <Igor.Ivanov@itseez.com>
Этот коммит содержится в:
Igor Ivanov 2015-02-19 17:42:01 +04:00
родитель 8b625c2756
Коммит 426d1ce146
8 изменённых файлов: 155 добавлений и 106 удалений

Просмотреть файл

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013 Mellanox Technologies, Inc.
* Copyright (c) 2013-2015 Mellanox Technologies, Inc.
* All rights reserved.
* $COPYRIGHT$
*
@ -391,24 +391,27 @@ static int oshmem_mkey_recv_cb(void)
MEMHEAP_ERROR("not enough memory");
ORTE_ERROR_LOG(0);
return n;
}
memcpy(tmp_buf, (void*)&r->buf, size);
msg = OBJ_NEW(opal_buffer_t);
if (NULL == msg) {
MEMHEAP_ERROR("not enough memory");
ORTE_ERROR_LOG(0);
return n;
}
opal_dss.load(msg, (void*)tmp_buf, size);
} else {
memcpy(tmp_buf, (void*)&r->buf, size);
msg = OBJ_NEW(opal_buffer_t);
if (NULL == msg) {
MEMHEAP_ERROR("not enough memory");
ORTE_ERROR_LOG(0);
free(tmp_buf);
return n;
}
opal_dss.load(msg, (void*)tmp_buf, size);
/*
* send reply before posting the receive request again to limit the recursion size to
* number of receive requests.
* send can call opal_progress which calls this function again. If recv req is started
* stack size will be proportional to number of job ranks.
*/
do_recv(status.MPI_SOURCE, msg);
OBJ_RELEASE(msg);
/*
* send reply before posting the receive request again to limit the recursion size to
* number of receive requests.
* send can call opal_progress which calls this function again. If recv req is started
* stack size will be proportional to number of job ranks.
*/
do_recv(status.MPI_SOURCE, msg);
OBJ_RELEASE(msg);
free(tmp_buf);
}
rc = MPI_Start(&r->recv_req);
if (MPI_SUCCESS != rc) {
@ -422,6 +425,7 @@ static int oshmem_mkey_recv_cb(void)
r = (oob_comm_request_t *)opal_list_get_first(&memheap_oob.req_list);
assert(r);
}
return 1;
}
@ -558,13 +562,15 @@ void mca_memheap_modex_recv_all(void)
int i;
int j;
int nprocs, my_pe;
opal_buffer_t *msg;
void *send_buffer;
char *rcv_buffer;
void *dummy_buffer;
opal_buffer_t *msg = NULL;
void *send_buffer = NULL;
char *rcv_buffer = NULL;
void *dummy_buffer = NULL;
int size, dummy_size;
int *rcv_size, *rcv_n_transports, *rcv_offsets;
int rc;
int *rcv_size = NULL;
int *rcv_n_transports = NULL;
int *rcv_offsets = NULL;
int rc = OSHMEM_SUCCESS;
if (!mca_memheap_base_key_exchange) {
oshmem_shmem_barrier();
@ -580,30 +586,30 @@ void mca_memheap_modex_recv_all(void)
rcv_size = (int *)malloc(nprocs * sizeof(int));
if (NULL == rcv_size) {
MEMHEAP_ERROR("failed to get rcv_size buffer");
oshmem_shmem_abort(-1);
return;
rc = OSHMEM_ERR_OUT_OF_RESOURCE;
goto exit_fatal;
}
rcv_offsets = (int *)malloc(nprocs * sizeof(int));
if (NULL == rcv_offsets) {
MEMHEAP_ERROR("failed to get rcv_offsets buffer");
oshmem_shmem_abort(-1);
return;
rc = OSHMEM_ERR_OUT_OF_RESOURCE;
goto exit_fatal;
}
rcv_n_transports = (int *)malloc(nprocs * sizeof(int));
if (NULL == rcv_offsets) {
MEMHEAP_ERROR("failed to get rcv_offsets buffer");
oshmem_shmem_abort(-1);
return;
rc = OSHMEM_ERR_OUT_OF_RESOURCE;
goto exit_fatal;
}
/* serialize our own mkeys */
msg = OBJ_NEW(opal_buffer_t);
if (NULL == msg) {
MEMHEAP_ERROR("failed to get msg buffer");
oshmem_shmem_abort(-1);
return;
rc = OSHMEM_ERR_OUT_OF_RESOURCE;
goto exit_fatal;
}
for (j = 0; j < memheap_map->n_segments; j++) {
@ -625,13 +631,13 @@ void mca_memheap_modex_recv_all(void)
rc = oshmem_shmem_allgather(&memheap_map->num_transports, rcv_n_transports, sizeof(int));
if (MPI_SUCCESS != rc) {
MEMHEAP_ERROR("allgather failed");
oshmem_shmem_abort(-1);
goto exit_fatal;
}
rc = oshmem_shmem_allgather(&size, rcv_size, sizeof(int));
if (MPI_SUCCESS != rc) {
MEMHEAP_ERROR("allgather failed");
oshmem_shmem_abort(-1);
goto exit_fatal;
}
/* calculating offsets (displacements) for allgatherv */
@ -644,13 +650,14 @@ void mca_memheap_modex_recv_all(void)
rcv_buffer = malloc(rcv_offsets[nprocs - 1] + rcv_size[nprocs - 1]);
if (NULL == rcv_buffer) {
MEMHEAP_ERROR("failed to allocate recieve buffer");
oshmem_shmem_abort(-1);
rc = OSHMEM_ERR_OUT_OF_RESOURCE;
goto exit_fatal;
}
rc = oshmem_shmem_allgatherv(send_buffer, rcv_buffer, size, rcv_size, rcv_offsets);
if (MPI_SUCCESS != rc) {
MEMHEAP_ERROR("allgatherv failed");
oshmem_shmem_abort(-1);
goto exit_fatal;
}
/* deserialize mkeys */
@ -682,12 +689,31 @@ void mca_memheap_modex_recv_all(void)
}
OPAL_THREAD_UNLOCK(&memheap_oob.lck);
free(rcv_size);
free(rcv_offsets);
free(rcv_n_transports);
free(send_buffer);
free(rcv_buffer);
OBJ_RELEASE(msg);
exit_fatal:
if (rcv_size) {
free(rcv_size);
}
if (rcv_offsets) {
free(rcv_offsets);
}
if (rcv_n_transports) {
free(rcv_n_transports);
}
if (send_buffer) {
free(send_buffer);
}
if (rcv_buffer) {
free(rcv_buffer);
}
if (msg) {
OBJ_RELEASE(msg);
}
/* This function requires abort in any error case */
if (OSHMEM_SUCCESS != rc) {
oshmem_shmem_abort(rc);
}
}
static inline void* va2rva(void* va,

Просмотреть файл

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013 Mellanox Technologies, Inc.
* Copyright (c) 2013-2015 Mellanox Technologies, Inc.
* All rights reserved.
* $COPYRIGHT$
*
@ -55,6 +55,8 @@ int mca_memheap_base_select()
context = _memheap_create();
if (!context) {
opal_argv_free(include);
opal_argv_free(exclude);
return OSHMEM_ERROR;
}
@ -119,9 +121,10 @@ int mca_memheap_base_select()
opal_list_remove_item(&oshmem_memheap_base_framework.framework_components, &cli->super);
mca_base_component_close((mca_base_component_t *) component,
oshmem_memheap_base_framework.framework_output);
/* Calculate memheap size in case it was not set during component initialization */
module->memheap_size = context->user_size;
}
/* Calculate memheap size in case it was not set during component initialization */
module->memheap_size = context->user_size;
}
/* Init max priority component */

Просмотреть файл

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013 Mellanox Technologies, Inc.
* Copyright (c) 2013-2015 Mellanox Technologies, Inc.
* All rights reserved.
* $COPYRIGHT$
*
@ -35,7 +35,7 @@ int mca_scoll_basic_barrier(struct oshmem_group_t *group, long *pSync, int alg)
int rc = OSHMEM_SUCCESS;
/* Arguments validation */
if (!group) {
if (!group || !pSync) {
SCOLL_ERROR("Active set (group) of PE is not defined");
rc = OSHMEM_ERR_BAD_PARAM;
}
@ -184,7 +184,7 @@ static int _algorithm_central_counter(struct oshmem_group_t *group,
SCOLL_VERBOSE(12,
"[#%d] Restore special synchronization array",
group->my_pe);
for (i = 0; pSync && (i < _SHMEM_BARRIER_SYNC_SIZE); i++) {
for (i = 0; i < _SHMEM_BARRIER_SYNC_SIZE; i++) {
pSync[i] = _SHMEM_SYNC_VALUE;
}
@ -273,7 +273,7 @@ static int _algorithm_tournament(struct oshmem_group_t *group, long *pSync)
SCOLL_VERBOSE(12,
"[#%d] Restore special synchronization array",
group->my_pe);
for (i = 0; pSync && (i < _SHMEM_BARRIER_SYNC_SIZE); i++) {
for (i = 0; i < _SHMEM_BARRIER_SYNC_SIZE; i++) {
pSync[i] = _SHMEM_SYNC_VALUE;
}
@ -490,7 +490,7 @@ static int _algorithm_dissemination(struct oshmem_group_t *group, long *pSync)
SCOLL_VERBOSE(12,
"[#%d] Restore special synchronization array",
group->my_pe);
for (i = 0; pSync && (i < _SHMEM_BARRIER_SYNC_SIZE); i++) {
for (i = 0; i < _SHMEM_BARRIER_SYNC_SIZE; i++) {
pSync[i] = _SHMEM_SYNC_VALUE;
}

Просмотреть файл

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013 Mellanox Technologies, Inc.
* Copyright (c) 2013-2015 Mellanox Technologies, Inc.
* All rights reserved.
* $COPYRIGHT$
*
@ -57,7 +57,7 @@ int mca_scoll_basic_collect(struct oshmem_group_t *group,
int rc = OSHMEM_SUCCESS;
/* Arguments validation */
if (!group) {
if (!group || !pSync) {
SCOLL_ERROR("Active set (group) of PE is not defined");
rc = OSHMEM_ERR_BAD_PARAM;
}
@ -127,7 +127,7 @@ int mca_scoll_basic_collect(struct oshmem_group_t *group,
SCOLL_VERBOSE(12,
"[#%d] Restore special synchronization array",
group->my_pe);
for (i = 0; pSync && (i < _SHMEM_COLLECT_SYNC_SIZE); i++) {
for (i = 0; i < _SHMEM_COLLECT_SYNC_SIZE; i++) {
pSync[i] = _SHMEM_SYNC_VALUE;
}
}

Просмотреть файл

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013 Mellanox Technologies, Inc.
* Copyright (c) 2013-2015 Mellanox Technologies, Inc.
* All rights reserved.
* Copyright (c) 2014 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
@ -342,7 +342,6 @@ OBJ_CLASS_INSTANCE( mxm_peer_t,
int mca_spml_ikrit_del_procs(oshmem_proc_t** procs, size_t nprocs)
{
size_t i, n;
opal_list_item_t *item;
int my_rank = oshmem_my_proc_id();
oshmem_shmem_barrier();
@ -352,7 +351,7 @@ int mca_spml_ikrit_del_procs(oshmem_proc_t** procs, size_t nprocs)
}
#endif
while (NULL != (item = opal_list_remove_first(&mca_spml_ikrit.active_peers))) {
while (NULL != opal_list_remove_first(&mca_spml_ikrit.active_peers)) {
};
OBJ_DESTRUCT(&mca_spml_ikrit.active_peers);
@ -526,11 +525,13 @@ int mca_spml_ikrit_add_procs(oshmem_proc_t** procs, size_t nprocs)
mxm_conn_ctx_set(conn_reqs[i].conn, mca_spml_ikrit.mxm_peers[i]);
}
if (ep_info)
free(ep_info);
if (conn_reqs)
free(conn_reqs);
#endif
if (ep_info)
free(ep_info);
if (ep_hw_rdma_info)
free(ep_hw_rdma_info);
#if MXM_API >= MXM_VERSION(2,0)
if (mca_spml_ikrit.bulk_connect) {
@ -559,13 +560,15 @@ int mca_spml_ikrit_add_procs(oshmem_proc_t** procs, size_t nprocs)
SPML_VERBOSE(50, "*** ADDED PROCS ***");
return OSHMEM_SUCCESS;
bail:
#if MXM_API < MXM_VERSION(2,0)
if (conn_reqs)
free(conn_reqs);
if (ep_info)
free(ep_info);
#endif
bail:
#if MXM_API < MXM_VERSION(2,0)
if (conn_reqs)
free(conn_reqs);
#endif
if (ep_info)
free(ep_info);
if (ep_hw_rdma_info)
free(ep_hw_rdma_info);
SPML_ERROR("add procs FAILED rc=%d", rc);
return rc;
@ -661,7 +664,7 @@ sshmem_mkey_t *mca_spml_ikrit_register(void* addr,
error_out:
mca_spml_ikrit_deregister(mkeys);
return NULL ;
return NULL;
}
int mca_spml_ikrit_deregister(sshmem_mkey_t *mkeys)
@ -695,6 +698,8 @@ int mca_spml_ikrit_deregister(sshmem_mkey_t *mkeys)
break;
}
}
free(mkeys);
return OSHMEM_SUCCESS;
}
@ -1363,6 +1368,7 @@ int mca_spml_ikrit_fence(void)
/* blocking receive */
int mca_spml_ikrit_recv(void* buf, size_t size, int src)
{
mxm_error_t ret = MXM_OK;
mxm_recv_req_t req;
char dummy_buf[1];
@ -1386,9 +1392,12 @@ int mca_spml_ikrit_recv(void* buf, size_t size, int src)
req.base.data.buffer.length = size == 0 ? sizeof(dummy_buf) : size;
req.base.data.buffer.memh = NULL;
mxm_req_recv(&req);
ret = mxm_req_recv(&req);
if (MXM_OK != ret) {
return OSHMEM_ERROR;
}
mca_spml_irkit_req_wait(&req.base);
if (req.base.error != MXM_OK) {
if (MXM_OK != req.base.error) {
return OSHMEM_ERROR;
}
SPML_VERBOSE(100,

Просмотреть файл

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013 Mellanox Technologies, Inc.
* Copyright (c) 2013-2015 Mellanox Technologies, Inc.
* All rights reserved.
* $COPYRIGHT$
*
@ -117,13 +117,17 @@ static inline int set_mxm_tls()
static inline int check_mxm_hw_tls(char *v, char *tls)
{
if ((0 == strcmp(tls, "rc") || 0 == strcmp(tls, "dc")))
return OSHMEM_SUCCESS;
if (v && tls) {
if ((0 == strcmp(tls, "rc") || 0 == strcmp(tls, "dc"))) {
return OSHMEM_SUCCESS;
}
if (strstr(tls, "ud") &&
if (strstr(tls, "ud") &&
(NULL == strstr(tls, "rc") && NULL == strstr(tls, "dc") &&
NULL == strstr(tls, "shm")))
return OSHMEM_SUCCESS;
NULL == strstr(tls, "shm"))) {
return OSHMEM_SUCCESS;
}
}
orte_show_help("help-oshmem-spml-ikrit.txt", "mxm tls", true,
v, tls);

Просмотреть файл

@ -1,6 +1,6 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2013 Mellanox Technologies, Inc.
* Copyright (c) 2013-2015 Mellanox Technologies, Inc.
* All rights reserved.
* Copyright (c) 2014 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
@ -438,7 +438,9 @@ sshmem_mkey_t *mca_spml_yoda_register(void* addr,
/* FIXME some cleanup might be needed here
* yoda_context->btl_src_descriptor = NULL;
* *count = ???;
* free(spml_context);
*/
free(mkeys);
return NULL;
}
}
@ -559,12 +561,9 @@ static int create_btl_idx(int dst_pe)
if (0 < size) {
/*Chose SHMEM capable btl from eager array. Not filter now: take the first
(but could appear on demand).*/
for (shmem_index = 0; shmem_index < size; shmem_index++) {
bml_btl = mca_bml_base_btl_array_get_index(btl_array, shmem_index);
_find_btl_id(bml_btl);
size = 1;
break;
}
shmem_index = 0;
bml_btl = mca_bml_base_btl_array_get_index(btl_array, shmem_index);
size = 1;
}
else {
SPML_ERROR("no SHMEM capable transport for dest pe=%d", dst_pe);
@ -677,8 +676,8 @@ static inline mca_bml_base_btl_t *get_next_btl(int dst, int *btl_id)
mca_bml_base_btl_t* bml_btl;
oshmem_proc_t *proc;
mca_bml_base_btl_array_t *btl_array = 0;
int shmem_index = -1;
int size = 0;
int shmem_index = 0;
/* get endpoint and btl */
proc = oshmem_proc_group_all(dst);
@ -708,15 +707,13 @@ static inline mca_bml_base_btl_t *get_next_btl(int dst, int *btl_id)
if (0 < size) {
/*Chose SHMEM capable btl from eager array. Not filter now: take the first
(but could appear on demand).*/
for (shmem_index = 0; shmem_index < size; shmem_index++) {
bml_btl = mca_bml_base_btl_array_get_index(btl_array, shmem_index);
_find_btl_id(bml_btl);
size = 1;
break;
}
shmem_index = 0;
bml_btl = mca_bml_base_btl_array_get_index(btl_array, shmem_index);
size = 1;
}
}
shmem_index = 0;
bml_btl = mca_bml_base_btl_array_get_index(btl_array, shmem_index);
*btl_id = proc->transport_ids[0];
@ -761,7 +758,8 @@ static inline int mca_spml_yoda_put_internal(void *dst_addr,
bml_btl = get_next_btl(dst, &btl_id);
if (!bml_btl) {
SPML_ERROR("cannot reach %d pe: no appropriate btl found", oshmem_my_proc_id());
oshmem_shmem_abort(-1);
rc = OSHMEM_ERR_FATAL;
goto exit_fatal;
}
/* Check if btl has PUT method. If it doesn't - use SEND*/
put_via_send = !(bml_btl->btl->btl_flags & MCA_BTL_FLAGS_PUT);
@ -774,7 +772,8 @@ static inline int mca_spml_yoda_put_internal(void *dst_addr,
if (!r_mkey) {
SPML_ERROR("pe=%d: %p is not address of shared variable",
dst, dst_addr);
oshmem_shmem_abort(-1);
rc = OSHMEM_ERR_FATAL;
goto exit_fatal;
}
#if SPML_YODA_DEBUG == 1
@ -827,7 +826,8 @@ static inline int mca_spml_yoda_put_internal(void *dst_addr,
"internal_oom_error",
true,
"Put", ncopied, mca_spml_yoda.bml_alloc_threshold);
oshmem_shmem_abort(-1);
rc = OSHMEM_ERR_FATAL;
goto exit_fatal;
}
/* copy data to allocated buffer*/
@ -878,14 +878,20 @@ static inline int mca_spml_yoda_put_internal(void *dst_addr,
/* exit with errro */
SPML_ERROR("shmem error: ret = %i, send_pe = %i, dest_pe = %i",
rc, oshmem_my_proc_id(), dst);
oshmem_shmem_abort(-1);
rc = OSHMEM_ERROR;
rc = OSHMEM_ERR_FATAL;
goto exit_fatal;
}
p_src += ncopied;
p_dst += ncopied;
}
return rc;
exit_fatal:
if (OSHMEM_SUCCESS != rc) {
oshmem_shmem_abort(rc);
}
return rc;
}
int mca_spml_yoda_put(void *dst_addr, size_t size, void *src_addr, int dst)
@ -1025,7 +1031,8 @@ int mca_spml_yoda_get(void* src_addr, size_t size, void* dst_addr, int src)
bml_btl = get_next_btl(src, &btl_id);
if (!bml_btl) {
SPML_ERROR("cannot reach %d pe: no appropriate btl found", oshmem_my_proc_id());
oshmem_shmem_abort(-1);
rc = OSHMEM_ERR_FATAL;
goto exit_fatal;
}
/* Check if btl has GET method. If it doesn't - use SEND*/
get_via_send = ! ( (bml_btl->btl->btl_flags & (MCA_BTL_FLAGS_GET)) &&
@ -1039,7 +1046,8 @@ int mca_spml_yoda_get(void* src_addr, size_t size, void* dst_addr, int src)
if (!r_mkey) {
SPML_ERROR("pe=%d: %p is not address of shared variable",
src, src_addr);
oshmem_shmem_abort(-1);
rc = OSHMEM_ERR_FATAL;
goto exit_fatal;
}
#if SPML_YODA_DEBUG == 1
@ -1123,7 +1131,8 @@ int mca_spml_yoda_get(void* src_addr, size_t size, void* dst_addr, int src)
SPML_ERROR("shmem OOM error need %d bytes", ncopied);
SPML_ERROR("src=%p nfrags = %d frag_size=%d",
src_addr, nfrags, frag_size);
oshmem_shmem_abort(-1);
rc = OSHMEM_ERR_FATAL;
goto exit_fatal;
}
segment = des->des_segments;
@ -1186,8 +1195,7 @@ int mca_spml_yoda_get(void* src_addr, size_t size, void* dst_addr, int src)
return OSHMEM_SUCCESS;
} else {
SPML_ERROR("oshmem_get: error %d", rc);
oshmem_shmem_abort(-1);
return rc;
goto exit_fatal;
}
}
p_dst += ncopied;
@ -1204,6 +1212,12 @@ int mca_spml_yoda_get(void* src_addr, size_t size, void* dst_addr, int src)
oshmem_request_wait_completion(&getreq->req_get.req_base.req_oshmem);
return rc;
exit_fatal:
if (OSHMEM_SUCCESS != rc) {
oshmem_shmem_abort(rc);
}
return rc;
}
int mca_spml_yoda_send(void* buf,

Просмотреть файл

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013 Mellanox Technologies, Inc.
* Copyright (c) 2013-2015 Mellanox Technologies, Inc.
* All rights reserved.
* Copyright (c) 2014 Intel, Inc. All rights reserved.
*
@ -62,7 +62,6 @@ int main(int argc, char *argv[])
int ret = 0;
bool acted = false;
bool want_all = false;
char **app_env = NULL, **global_env = NULL;
int i;
opal_cmd_line_t *info_cmd_line;
opal_pointer_array_t mca_types;
@ -174,12 +173,6 @@ int main(int argc, char *argv[])
/* All done */
if (NULL != app_env) {
opal_argv_free(app_env);
}
if (NULL != global_env) {
opal_argv_free(global_env);
}
oshmem_info_close_components();
OBJ_RELEASE(info_cmd_line);
OBJ_DESTRUCT(&mca_types);