Skip to content

Commit

Permalink
UCP: Fix coverity errors
Browse files Browse the repository at this point in the history
  • Loading branch information
brminich committed Sep 18, 2024
1 parent 7b78980 commit 1d2d8fd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/ucp/rndv/rndv.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
static UCS_F_ALWAYS_INLINE int
ucp_rndv_frag_memtype(ucp_context_t *context)
{
ucs_memory_type_t frag_mem_type;

if (context->config.ext.rndv_frag_mem_types == 0) {
return UCS_MEMORY_TYPE_HOST;
}
Expand All @@ -32,7 +34,12 @@ ucp_rndv_frag_memtype(ucp_context_t *context)
* first one from the map. Anyway for proto v1 UCX_RNDV_FRAG_MEM_TYPE is
* supposed to be used.
*/
return ucs_ffs64(context->config.ext.rndv_frag_mem_types);
frag_mem_type = ucs_ffs64(context->config.ext.rndv_frag_mem_types);

ucs_assertv(frag_mem_type < UCS_MEMORY_TYPE_UNKNOWN, "frag_mem_type = %u",
frag_mem_type);

return frag_mem_type;
}

static UCS_F_ALWAYS_INLINE int
Expand Down
7 changes: 5 additions & 2 deletions src/ucp/rndv/rndv_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ ucp_proto_rndv_get_common_probe(const ucp_proto_init_params_t *init_params,
}

rpriv.frag_mem_type = frag_mem_type;
priv_size = UCP_PROTO_MULTI_EXTENDED_PRIV_SIZE(&rpriv, mpriv);
priv_size = UCP_PROTO_MULTI_EXTENDED_PRIV_SIZE(&rpriv, mpriv);
ucp_proto_common_add_proto(&params.super, &caps, &rpriv, priv_size);
}

Expand Down Expand Up @@ -288,9 +288,12 @@ static ucs_status_t
ucp_proto_rndv_get_mtype_fetch_progress(uct_pending_req_t *uct_req)
{
ucp_request_t *req = ucs_container_of(uct_req, ucp_request_t, send.uct);
const ucp_proto_rndv_bulk_priv_t *rpriv = req->send.proto_config->priv;
const ucp_proto_rndv_bulk_priv_t *rpriv;
ucs_status_t status;

/* coverity[tainted_data_downcast] */
rpriv = req->send.proto_config->priv;

if (!(req->flags & UCP_REQUEST_FLAG_PROTO_INITIALIZED)) {
status = ucp_proto_rndv_mtype_request_init(req, rpriv->frag_mem_type);
if (status != UCS_OK) {
Expand Down
4 changes: 4 additions & 0 deletions src/ucp/rndv/rndv_mtype.inl
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ ucp_proto_rndv_mtype_query_desc(const ucp_proto_query_params_t *params,
ucs_string_buffer_appendf(&strb, ", %s", tl_name);
}

/* Make coverity happy */
ucs_assertv(frag_mem_type <= UCS_MEMORY_TYPE_UNKNOWN, "frag_mem_type = %u",
frag_mem_type);

ucs_string_buffer_appendf(&strb, ", frag %s",
ucs_memory_type_names[frag_mem_type]);
}
Expand Down

0 comments on commit 1d2d8fd

Please sign in to comment.