Skip to content

Commit 899c946

Browse files
authored
Merge pull request #9730 from hoopoepg/topic/spml-ucx-fixed-compilation-coverity-warnings
Topic/spml ucx fixed compilation coverity warnings
2 parents 4d816c6 + 125e293 commit 899c946

File tree

5 files changed

+16
-19
lines changed

5 files changed

+16
-19
lines changed

opal/mca/common/ucx/common_ucx.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,7 @@ OPAL_DECLSPEC opal_common_ucx_support_level_t opal_common_ucx_support_level(ucp_
259259

260260
/* Check for special value "any" */
261261
if (is_any_tl && is_any_device) {
262-
MCA_COMMON_UCX_VERBOSE(1, "ucx is enabled on any transport or device",
263-
*opal_common_ucx.tls);
262+
MCA_COMMON_UCX_VERBOSE(1, "ucx is enabled on any transport or device");
264263
support_level = OPAL_COMMON_UCX_SUPPORT_DEVICE;
265264
goto out;
266265
}

opal/mca/common/ucx/common_ucx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ BEGIN_C_DECLS
6161
#define MCA_COMMON_UCX_PROGRESS_LOOP(_worker) \
6262
for (unsigned iter = 0;; (++iter % opal_common_ucx.progress_iterations) \
6363
? (void) ucp_worker_progress(_worker) \
64-
: opal_progress())
64+
: (void) opal_progress())
6565

6666
#define MCA_COMMON_UCX_WAIT_LOOP(_request, _worker, _msg, _completed) \
6767
do { \

oshmem/mca/memheap/base/base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ static inline int memheap_find_segnum(void *va, int pe)
199199
if (mkeys_cache) {
200200
if (mkeys_cache[pe]) {
201201
if ((va >= mkeys_cache[pe]->va_base) &&
202-
(va < mkeys_cache[pe]->va_base + mkeys_cache[pe]->len)) {
202+
((char*)va < (char*)mkeys_cache[pe]->va_base + mkeys_cache[pe]->len)) {
203203
return i;
204204
}
205205
}

oshmem/mca/spml/ucx/spml_ucx.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void mca_spml_ucx_peer_mkey_cache_init(mca_spml_ucx_ctx_t *ucx_ctx, int pe)
149149
int mca_spml_ucx_peer_mkey_cache_add(ucp_peer_t *ucp_peer, int index)
150150
{
151151
/* Allocate an array to hold the pointers to the ucx_cached_mkey */
152-
if (index >= ucp_peer->mkeys_cnt){
152+
if (index >= (int)ucp_peer->mkeys_cnt){
153153
int old_size = ucp_peer->mkeys_cnt;
154154
if (MCA_MEMHEAP_MAX_SEGMENTS <= (index + 1)) {
155155
SPML_UCX_ERROR("Failed to get new mkey for segment: max number (%d) of segment descriptor is exhausted",
@@ -184,7 +184,7 @@ int mca_spml_ucx_peer_mkey_cache_add(ucp_peer_t *ucp_peer, int index)
184184
/* Release individual mkeys */
185185
int mca_spml_ucx_peer_mkey_cache_del(ucp_peer_t *ucp_peer, int segno)
186186
{
187-
if ((ucp_peer->mkeys_cnt <= segno) || (segno < 0)) {
187+
if (((int)ucp_peer->mkeys_cnt <= segno) || (segno < 0)) {
188188
return OSHMEM_ERR_NOT_AVAILABLE;
189189
}
190190
if (NULL != ucp_peer->mkeys[segno]) {
@@ -197,7 +197,7 @@ int mca_spml_ucx_peer_mkey_cache_del(ucp_peer_t *ucp_peer, int segno)
197197
/* Release the memkey map from a ucp_peer if it has any element in memkey */
198198
void mca_spml_ucx_peer_mkey_cache_release(ucp_peer_t *ucp_peer)
199199
{
200-
int i;
200+
size_t i;
201201
if (ucp_peer->mkeys_cnt) {
202202
for(i = 0; i < ucp_peer->mkeys_cnt; i++) {
203203
assert(NULL == ucp_peer->mkeys[i]);
@@ -270,7 +270,6 @@ int mca_spml_ucx_ctx_mkey_add(mca_spml_ucx_ctx_t *ucx_ctx, int pe, uint32_t segn
270270
int mca_spml_ucx_ctx_mkey_del(mca_spml_ucx_ctx_t *ucx_ctx, int pe, uint32_t segno, spml_ucx_mkey_t *ucx_mkey)
271271
{
272272
ucp_peer_t *ucp_peer;
273-
spml_ucx_cached_mkey_t *ucx_cached_mkey;
274273
int rc;
275274
ucp_peer = &(ucx_ctx->ucp_peers[pe]);
276275
ucp_rkey_destroy(ucx_mkey->rkey);
@@ -429,8 +428,6 @@ static int oshmem_shmem_xchng(
429428
}
430429

431430

432-
static char spml_ucx_transport_ids[1] = { 0 };
433-
434431
int mca_spml_ucx_init_put_op_mask(mca_spml_ucx_ctx_t *ctx, size_t nprocs)
435432
{
436433
int res;
@@ -473,7 +470,7 @@ int mca_spml_ucx_add_procs(oshmem_group_t* group, size_t nprocs)
473470
unsigned int *wk_roffs = NULL;
474471
unsigned int *wk_rsizes = NULL;
475472
char *wk_raddrs = NULL;
476-
size_t i, j, w, n;
473+
size_t i, w, n;
477474
ucs_status_t err;
478475
ucp_address_t **wk_local_addr;
479476
unsigned int *wk_addr_len;
@@ -1011,7 +1008,7 @@ void mca_spml_ucx_ctx_destroy(shmem_ctx_t ctx)
10111008

10121009
int mca_spml_ucx_get(shmem_ctx_t ctx, void *src_addr, size_t size, void *dst_addr, int src)
10131010
{
1014-
void *rva;
1011+
void *rva = NULL;
10151012
spml_ucx_mkey_t *ucx_mkey = mca_spml_ucx_ctx_mkey_by_va(ctx, src, src_addr, &rva, &mca_spml_ucx);
10161013
assert(NULL != ucx_mkey);
10171014
mca_spml_ucx_ctx_t *ucx_ctx = (mca_spml_ucx_ctx_t *)ctx;
@@ -1038,7 +1035,7 @@ int mca_spml_ucx_get(shmem_ctx_t ctx, void *src_addr, size_t size, void *dst_add
10381035

10391036
int mca_spml_ucx_get_nb(shmem_ctx_t ctx, void *src_addr, size_t size, void *dst_addr, int src, void **handle)
10401037
{
1041-
void *rva;
1038+
void *rva = NULL;
10421039
ucs_status_t status;
10431040
spml_ucx_mkey_t *ucx_mkey = mca_spml_ucx_ctx_mkey_by_va(ctx, src, src_addr, &rva, &mca_spml_ucx);
10441041
assert(NULL != ucx_mkey);
@@ -1066,7 +1063,7 @@ int mca_spml_ucx_get_nb(shmem_ctx_t ctx, void *src_addr, size_t size, void *dst_
10661063
int mca_spml_ucx_get_nb_wprogress(shmem_ctx_t ctx, void *src_addr, size_t size, void *dst_addr, int src, void **handle)
10671064
{
10681065
unsigned int i;
1069-
void *rva;
1066+
void *rva = NULL;
10701067
ucs_status_t status;
10711068
spml_ucx_mkey_t *ucx_mkey = mca_spml_ucx_ctx_mkey_by_va(ctx, src, src_addr, &rva, &mca_spml_ucx);
10721069
assert(NULL != ucx_mkey);
@@ -1104,7 +1101,7 @@ int mca_spml_ucx_get_nb_wprogress(shmem_ctx_t ctx, void *src_addr, size_t size,
11041101

11051102
int mca_spml_ucx_put(shmem_ctx_t ctx, void* dst_addr, size_t size, void* src_addr, int dst)
11061103
{
1107-
void *rva;
1104+
void *rva = NULL;
11081105
spml_ucx_mkey_t *ucx_mkey = mca_spml_ucx_ctx_mkey_by_va(ctx, dst, dst_addr, &rva, &mca_spml_ucx);
11091106
assert(NULL != ucx_mkey);
11101107
mca_spml_ucx_ctx_t *ucx_ctx = (mca_spml_ucx_ctx_t *)ctx;
@@ -1138,7 +1135,7 @@ int mca_spml_ucx_put(shmem_ctx_t ctx, void* dst_addr, size_t size, void* src_add
11381135

11391136
int mca_spml_ucx_put_nb(shmem_ctx_t ctx, void* dst_addr, size_t size, void* src_addr, int dst, void **handle)
11401137
{
1141-
void *rva;
1138+
void *rva = NULL;
11421139
spml_ucx_mkey_t *ucx_mkey = mca_spml_ucx_ctx_mkey_by_va(ctx, dst, dst_addr, &rva, &mca_spml_ucx);
11431140
assert(NULL != ucx_mkey);
11441141
mca_spml_ucx_ctx_t *ucx_ctx = (mca_spml_ucx_ctx_t *)ctx;
@@ -1171,7 +1168,7 @@ int mca_spml_ucx_put_nb(shmem_ctx_t ctx, void* dst_addr, size_t size, void* src_
11711168
int mca_spml_ucx_put_nb_wprogress(shmem_ctx_t ctx, void* dst_addr, size_t size, void* src_addr, int dst, void **handle)
11721169
{
11731170
unsigned int i;
1174-
void *rva;
1171+
void *rva = NULL;
11751172
ucs_status_t status;
11761173
spml_ucx_mkey_t *ucx_mkey = mca_spml_ucx_ctx_mkey_by_va(ctx, dst, dst_addr, &rva, &mca_spml_ucx);
11771174
assert(NULL != ucx_mkey);

oshmem/mca/spml/ucx/spml_ucx.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,9 @@ static inline int
285285
mca_spml_ucx_peer_mkey_get(ucp_peer_t *ucp_peer, int index, spml_ucx_cached_mkey_t **out_rmkey)
286286
{
287287
*out_rmkey = NULL;
288-
if (OPAL_UNLIKELY((index >= ucp_peer->mkeys_cnt) || (MCA_MEMHEAP_MAX_SEGMENTS <= index) || (0 > index))) {
289-
SPML_UCX_ERROR("Failed to get mkey for segment: bad index = %d, MAX = %d, cached mkeys count: %d",
288+
if (OPAL_UNLIKELY((index >= (int)ucp_peer->mkeys_cnt) ||
289+
(MCA_MEMHEAP_MAX_SEGMENTS <= index) || (0 > index))) {
290+
SPML_UCX_ERROR("Failed to get mkey for segment: bad index = %d, MAX = %d, cached mkeys count: %zu",
290291
index, MCA_MEMHEAP_MAX_SEGMENTS, ucp_peer->mkeys_cnt);
291292
return OSHMEM_ERR_BAD_PARAM;
292293
}

0 commit comments

Comments
 (0)