Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORE: coverity fixes #809

Merged
merged 2 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/components/tl/sharp/tl_sharp_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ ucc_status_t ucc_tl_sharp_context_create_epilog(ucc_base_context_t *context)
return UCC_OK;
}

memset(&set.map, 0, sizeof(ucc_ep_map_t));
set.map.type = UCC_EP_MAP_FULL;
set.myrank = UCC_TL_CTX_OOB(sharp_ctx).oob_ep;
set.map.ep_num = UCC_TL_CTX_OOB(sharp_ctx).n_oob_eps;
Expand All @@ -447,6 +448,7 @@ ucc_status_t ucc_tl_sharp_context_create_epilog(ucc_base_context_t *context)
status = ucc_tl_sharp_context_init(sharp_ctx, &sharp_ctx->sharp_context,
&sharp_ctx->oob_ctx, topo);
if (status != UCC_OK) {
ucc_topo_cleanup(topo);
return status;
}

Expand Down
3 changes: 1 addition & 2 deletions src/core/ucc_coll.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ UCC_CORE_PROFILE_FUNC(ucc_status_t, ucc_collective_init,
(coll_args, request, team), ucc_coll_args_t *coll_args,
ucc_coll_req_h *request, ucc_team_h team)
{
ucc_base_coll_args_t op_args = {0};
ucc_coll_task_t *task;
ucc_base_coll_args_t op_args;
ucc_status_t status;
ucc_ee_executor_params_t params;
ucc_memory_type_t coll_mem_type;
Expand Down Expand Up @@ -194,7 +194,6 @@ UCC_CORE_PROFILE_FUNC(ucc_status_t, ucc_collective_init,
}

/* TO discuss: maybe we want to pass around user pointer ? */
op_args.mask = 0;
memcpy(&op_args.args, coll_args, sizeof(ucc_coll_args_t));
op_args.team = team;

Expand Down
5 changes: 5 additions & 0 deletions src/core/ucc_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ static ucc_status_t ucc_create_tl_contexts(ucc_context_t *ctx,
tl_lib->iface->super.name);
continue;
}
// coverity[overrun-buffer-val:FALSE]
status = tl_lib->iface->context.create(
&b_params, &ctx_config->tl_cfgs[i]->super.super, &b_ctx);
if (UCC_OK != status) {
Expand Down Expand Up @@ -645,6 +646,7 @@ ucc_status_t ucc_context_create_proc_info(ucc_lib_h lib,
ctx->cl_flags = 0;
for (i = 0; i < num_cls; i++) {
cl_lib = config->cl_cfgs[i]->cl_lib;
// coverity[overrun-buffer-val:FALSE]
status = cl_lib->iface->context.create(
&b_params, &config->cl_cfgs[i]->super.super, &b_ctx);
if (UCC_OK != status) {
Expand Down Expand Up @@ -746,6 +748,8 @@ ucc_status_t ucc_context_create_proc_info(ucc_lib_h lib,
ucc_debug("TL UCP context is not available, "
"service team can not be created");
} else {
memset(&t_params.map, 0, sizeof(ucc_ep_map_t));
memset(&t_params.params, 0, sizeof(ucc_team_params_t));
t_params.params.mask = UCC_TEAM_PARAM_FIELD_EP |
UCC_TEAM_PARAM_FIELD_EP_RANGE |
UCC_TEAM_PARAM_FIELD_OOB;
Expand Down Expand Up @@ -1070,6 +1074,7 @@ ucc_status_t ucc_context_get_attr(ucc_context_t *context,
ucc_base_ctx_attr_t attr;
ucc_tl_lib_t * tl_lib;

memset(&attr.attr, 0, sizeof(ucc_context_attr_t));
attr.attr.mask = UCC_CONTEXT_ATTR_FIELD_WORK_BUFFER_SIZE;
attr.attr.global_work_buffer_size = 0;
for (i = 0; i < context->n_tl_ctx; i++) {
Expand Down
5 changes: 4 additions & 1 deletion src/core/ucc_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static ucc_status_t ucc_cl_lib_init(const ucc_lib_params_t *user_params,
}

lib->cl_attrs = (ucc_cl_lib_attr_t *)
ucc_malloc(sizeof(ucc_cl_lib_attr_t) * n_cls, "cl_attrs");
ucc_calloc(n_cls, sizeof(ucc_cl_lib_attr_t), "cl_attrs");
if (!lib->cl_attrs) {
ucc_error("failed to allocate %zd bytes for cl_attrs",
sizeof(ucc_cl_lib_attr_t) * n_cls);
Expand All @@ -103,6 +103,7 @@ static ucc_status_t ucc_cl_lib_init(const ucc_lib_params_t *user_params,
params.mask |= UCC_LIB_PARAM_FIELD_THREAD_MODE;
params.thread_mode = UCC_THREAD_SINGLE;
}
memset(&b_params, 0, sizeof(ucc_base_lib_params_t));
ucc_copy_lib_params(&b_params.params, &params);
ucc_assert(config->cls.count >= 1);
lib->specific_cls_requested = (0 == ucc_cl_requested(config, UCC_CL_ALL));
Expand All @@ -122,6 +123,7 @@ static ucc_status_t ucc_cl_lib_init(const ucc_lib_params_t *user_params,
cl_iface->super.name);
goto error_cfg_read;
}
// coverity[overrun-buffer-val:FALSE]
status = cl_iface->lib.init(&b_params, &cl_config->super.super, &b_lib);
if (UCC_OK != status) {
if (lib->specific_cls_requested) {
Expand Down Expand Up @@ -271,6 +273,7 @@ static ucc_status_t ucc_tl_lib_init(const ucc_lib_params_t *user_params,
tl_iface->super.name);
continue;
}
// coverity[overrun-buffer-val:FALSE]
status = tl_iface->lib.init(&b_params, &tl_config->super.super,
&b_lib);
ucc_base_config_release(&tl_config->super.super);
Expand Down
14 changes: 8 additions & 6 deletions src/utils/ucc_coll_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ ucc_ep_map_from_array_generic(void **array, ucc_rank_t size,
ucc_rank_t full_size, int need_free, int is64)
{
int is_const_stride = 0;
ucc_ep_map_t map;
ucc_ep_map_t map = {0};
int64_t stride;
ucc_rank_t i;

Expand Down Expand Up @@ -550,13 +550,15 @@ void ucc_coll_str(const ucc_coll_task_t *task, char *str, size_t len,

if (task->team->context->lib->log_component.name[0] == 'C') {
/* it's not CL BASIC task */
strncpy(cl_info, task->team->context->lib->log_component.name,
sizeof(cl_info));
ucc_strncpy_safe(cl_info,
task->team->context->lib->log_component.name,
sizeof(cl_info));
ucc_coll_task_components_str(task, tl_info, &tl_info_len);
} else {
strncpy(cl_info, "CL_BASIC", sizeof(cl_info));
strncpy(tl_info , task->team->context->lib->log_component.name,
sizeof(tl_info));
ucc_strncpy_safe(cl_info, "CL_BASIC", sizeof(cl_info));
ucc_strncpy_safe(tl_info,
task->team->context->lib->log_component.name,
sizeof(tl_info));
}
ucc_coll_args_str(&task->bargs.args, team->rank, team->size, str, len);
rc = ucc_snprintf_safe(task_info, sizeof(task_info),
Expand Down