Skip to content

Commit c498706

Browse files
authored
Merge pull request #11028 from hoopoepg/topic/fixed-coverity-issues
OSC/UCX: suppressed some coverity issues
2 parents 4dae142 + 670b16f commit c498706

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

ompi/mca/osc/ucx/osc_ucx_comm.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,17 +269,22 @@ static inline int get_dynamic_win_info(uint64_t remote_addr,
269269
uint64_t win_count;
270270
int insert = -1;
271271
int ret;
272+
int ret_unlock;
272273

273274
/* We need to lock dyn-lock even if the process has an exclusive lock.
274275
* Remote process protects its window attach/detach operations with a
275276
* dynamic lock */
276277
ret = ompi_osc_ucx_dynamic_lock(module, target);
277278
if (ret != OPAL_SUCCESS) {
278-
ret = OMPI_ERROR;
279-
goto cleanup;
279+
return OMPI_ERROR;
280280
}
281281

282282
temp_buf = calloc(remote_state_len, 1);
283+
if (NULL == temp_buf) {
284+
ret = OMPI_ERR_OUT_OF_RESOURCE;
285+
goto cleanup;
286+
}
287+
283288
ret = opal_common_ucx_wpmem_putget(module->state_mem, OPAL_COMMON_UCX_GET, target,
284289
(void *)((intptr_t)temp_buf),
285290
remote_state_len, remote_state_addr, ep);
@@ -316,17 +321,20 @@ static inline int get_dynamic_win_info(uint64_t remote_addr,
316321
_mem_record_t *mem_rec = NULL;
317322
ret = opal_tsd_tracked_key_get(&module->mem->tls_key, (void **) &mem_rec);
318323
if (OPAL_SUCCESS != ret) {
324+
ret = OMPI_ERROR;
319325
goto cleanup;
320326
}
321327

322328
if (mem_rec == NULL) {
323329
OSC_UCX_GET_DEFAULT_EP(ep, module, target);
324330
ret = opal_common_ucx_tlocal_fetch_spath(module->mem, target, ep);
325331
if (OPAL_SUCCESS != ret) {
332+
ret = OMPI_ERROR;
326333
goto cleanup;
327334
}
328335
ret = opal_tsd_tracked_key_get(&module->mem->tls_key, (void **) &mem_rec);
329336
if (OPAL_SUCCESS != ret) {
337+
ret = OMPI_ERROR;
330338
goto cleanup;
331339
}
332340

@@ -361,9 +369,9 @@ static inline int get_dynamic_win_info(uint64_t remote_addr,
361369
free(temp_buf);
362370

363371
/* unlock the dynamic lock */
364-
ompi_osc_ucx_dynamic_unlock(module, target);
365-
366-
return ret;
372+
ret_unlock = ompi_osc_ucx_dynamic_unlock(module, target);
373+
/* ignore unlock result in case of error */
374+
return (OMPI_SUCCESS != ret) ? ret : ret_unlock;
367375
}
368376

369377
static inline
@@ -1615,7 +1623,7 @@ void ompi_osc_ucx_req_completion(void *request) {
16151623
assert(req->phase != ACC_INIT);
16161624
void *free_addr = NULL;
16171625
bool release_lock = false;
1618-
ptrdiff_t temp_lb, temp_extent;
1626+
ptrdiff_t temp_extent, temp_lb;
16191627
const void *origin_addr = req->origin_addr;
16201628
int origin_count = req->origin_count;
16211629
struct ompi_datatype_t *origin_dt = req->origin_dt;
@@ -1786,7 +1794,7 @@ void ompi_osc_ucx_req_completion(void *request) {
17861794
module->state_mem->skip_periodic_flush = false;
17871795
}
17881796
}
1797+
assert(module->ctx->num_incomplete_req_ops > 0);
17891798
OSC_UCX_DECREMENT_OUTSTANDING_NB_OPS(module);
17901799
ompi_request_complete(&(ucx_req->super.super), true);
1791-
assert(module->ctx->num_incomplete_req_ops >= 0);
17921800
}

ompi/mca/osc/ucx/osc_ucx_component.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,9 @@ static int component_select(struct ompi_win_t *win, void **base, size_t size, in
784784
case MPI_WIN_FLAVOR_SHARED:
785785
mem_type = OPAL_COMMON_UCX_MEM_MAP;
786786
break;
787+
default:
788+
ret = OMPI_ERR_BAD_PARAM;
789+
goto error;
787790
}
788791
ret = opal_common_ucx_wpmem_create(module->ctx, mem_base, module->size,
789792
mem_type, &exchange_len_info,
@@ -942,14 +945,14 @@ int ompi_osc_ucx_dynamic_lock(ompi_osc_ucx_module_t *module, int target) {
942945
uint64_t remote_addr = (module->state_addrs)[target] + OSC_UCX_STATE_DYNAMIC_LOCK_OFFSET;
943946
ucp_ep_h *ep;
944947
OSC_UCX_GET_DEFAULT_EP(ep, module, target);
945-
int ret = OMPI_SUCCESS;
948+
int ret;
946949

947950
for (;;) {
948951
ret = opal_common_ucx_wpmem_cmpswp(module->state_mem,
949952
TARGET_LOCK_UNLOCKED, TARGET_LOCK_EXCLUSIVE,
950953
target, &result_value, sizeof(result_value),
951954
remote_addr, ep);
952-
if (ret != OMPI_SUCCESS) {
955+
if (OPAL_SUCCESS != ret) {
953956
OSC_UCX_VERBOSE(1, "opal_common_ucx_mem_cmpswp failed: %d", ret);
954957
return OMPI_ERROR;
955958
}
@@ -960,18 +963,18 @@ int ompi_osc_ucx_dynamic_lock(ompi_osc_ucx_module_t *module, int target) {
960963
opal_common_ucx_wpool_progress(mca_osc_ucx_component.wpool);
961964
}
962965

963-
return ret;
966+
return OMPI_SUCCESS;
964967
}
965968

966969
int ompi_osc_ucx_dynamic_unlock(ompi_osc_ucx_module_t *module, int target) {
967970
uint64_t result_value = -1;
968971
uint64_t remote_addr = (module->state_addrs)[target] + OSC_UCX_STATE_DYNAMIC_LOCK_OFFSET;
969972
ucp_ep_h *ep;
970973
OSC_UCX_GET_DEFAULT_EP(ep, module, target);
971-
int ret = OMPI_SUCCESS;
974+
int ret;
972975

973976
ret = opal_common_ucx_wpmem_fence(module->mem);
974-
if (ret != OMPI_SUCCESS) {
977+
if (OPAL_SUCCESS != ret) {
975978
OSC_UCX_VERBOSE(1, "opal_common_ucx_mem_fence failed: %d", ret);
976979
return OMPI_ERROR;
977980
}
@@ -980,8 +983,12 @@ int ompi_osc_ucx_dynamic_unlock(ompi_osc_ucx_module_t *module, int target) {
980983
UCP_ATOMIC_FETCH_OP_SWAP, TARGET_LOCK_UNLOCKED,
981984
target, &result_value, sizeof(result_value),
982985
remote_addr, ep);
986+
if (OPAL_SUCCESS != ret) {
987+
return OMPI_ERROR;
988+
}
989+
983990
assert(result_value == TARGET_LOCK_EXCLUSIVE);
984-
return ret;
991+
return OMPI_SUCCESS;
985992
}
986993

987994
int ompi_osc_ucx_win_attach(struct ompi_win_t *win, void *base, size_t len) {

opal/mca/common/ucx/common_ucx_wpool.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ OPAL_DECLSPEC int opal_common_ucx_wpool_init(opal_common_ucx_wpool_t *wpool)
198198
OBJ_DESTRUCT(&wpool->idle_workers);
199199
OBJ_DESTRUCT(&wpool->active_workers);
200200
ucp_cleanup(wpool->ucp_ctx);
201-
err_ucp_init:
202201
return rc;
203202
}
204203

0 commit comments

Comments
 (0)