Skip to content

Commit 670b16f

Browse files
hoopoepgjanjust
authored andcommitted
OSC/UCX: suppressed some coverity issues
- fixed return constant values Signed-off-by: Sergey Oblomov <hoopoepg@gmail.com>
1 parent be915ca commit 670b16f

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

ompi/mca/osc/ucx/osc_ucx_comm.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,11 @@ static inline int get_dynamic_win_info(uint64_t remote_addr,
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

@@ -363,7 +371,7 @@ static inline int get_dynamic_win_info(uint64_t remote_addr,
363371
/* unlock the dynamic lock */
364372
ret_unlock = ompi_osc_ucx_dynamic_unlock(module, target);
365373
/* ignore unlock result in case of error */
366-
return (OPAL_SUCCESS != ret) ? ret : ret_unlock;
374+
return (OMPI_SUCCESS != ret) ? ret : ret_unlock;
367375
}
368376

369377
static inline

ompi/mca/osc/ucx/osc_ucx_component.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -945,14 +945,14 @@ int ompi_osc_ucx_dynamic_lock(ompi_osc_ucx_module_t *module, int target) {
945945
uint64_t remote_addr = (module->state_addrs)[target] + OSC_UCX_STATE_DYNAMIC_LOCK_OFFSET;
946946
ucp_ep_h *ep;
947947
OSC_UCX_GET_DEFAULT_EP(ep, module, target);
948-
int ret = OMPI_SUCCESS;
948+
int ret;
949949

950950
for (;;) {
951951
ret = opal_common_ucx_wpmem_cmpswp(module->state_mem,
952952
TARGET_LOCK_UNLOCKED, TARGET_LOCK_EXCLUSIVE,
953953
target, &result_value, sizeof(result_value),
954954
remote_addr, ep);
955-
if (ret != OMPI_SUCCESS) {
955+
if (OPAL_SUCCESS != ret) {
956956
OSC_UCX_VERBOSE(1, "opal_common_ucx_mem_cmpswp failed: %d", ret);
957957
return OMPI_ERROR;
958958
}
@@ -963,18 +963,18 @@ int ompi_osc_ucx_dynamic_lock(ompi_osc_ucx_module_t *module, int target) {
963963
opal_common_ucx_wpool_progress(mca_osc_ucx_component.wpool);
964964
}
965965

966-
return ret;
966+
return OMPI_SUCCESS;
967967
}
968968

969969
int ompi_osc_ucx_dynamic_unlock(ompi_osc_ucx_module_t *module, int target) {
970970
uint64_t result_value = -1;
971971
uint64_t remote_addr = (module->state_addrs)[target] + OSC_UCX_STATE_DYNAMIC_LOCK_OFFSET;
972972
ucp_ep_h *ep;
973973
OSC_UCX_GET_DEFAULT_EP(ep, module, target);
974-
int ret = OMPI_SUCCESS;
974+
int ret;
975975

976976
ret = opal_common_ucx_wpmem_fence(module->mem);
977-
if (ret != OMPI_SUCCESS) {
977+
if (OPAL_SUCCESS != ret) {
978978
OSC_UCX_VERBOSE(1, "opal_common_ucx_mem_fence failed: %d", ret);
979979
return OMPI_ERROR;
980980
}
@@ -983,8 +983,12 @@ int ompi_osc_ucx_dynamic_unlock(ompi_osc_ucx_module_t *module, int target) {
983983
UCP_ATOMIC_FETCH_OP_SWAP, TARGET_LOCK_UNLOCKED,
984984
target, &result_value, sizeof(result_value),
985985
remote_addr, ep);
986+
if (OPAL_SUCCESS != ret) {
987+
return OMPI_ERROR;
988+
}
989+
986990
assert(result_value == TARGET_LOCK_EXCLUSIVE);
987-
return ret;
991+
return OMPI_SUCCESS;
988992
}
989993

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

0 commit comments

Comments
 (0)