Skip to content

Commit

Permalink
Merge pull request open-mpi#10004 from hppritcha/topic/sessons_coveri…
Browse files Browse the repository at this point in the history
…ty_cleanups1

sessions: more coverity cleanup
  • Loading branch information
hppritcha authored Mar 7, 2022
2 parents eb9b9c4 + bd28fa0 commit 4ddb5a8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 16 deletions.
4 changes: 1 addition & 3 deletions ompi/communicator/comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* Copyright (c) 2015 Mellanox Technologies. All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* Copyright (c) 2018-2021 Triad National Security, LLC. All rights
* Copyright (c) 2018-2022 Triad National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
Expand Down Expand Up @@ -1546,8 +1546,6 @@ int ompi_intercomm_create_from_groups (ompi_group_t *local_group, int local_lead
} else {
free (leader_procs);
}

rsize = remote_group->grp_proc_count;
}

/* bcast size and list of remote processes to all processes in local_comm */
Expand Down
9 changes: 8 additions & 1 deletion ompi/communicator/comm_cid.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* Copyright (c) 2017 Mellanox Technologies. All rights reserved.
* Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* Copyright (c) 2020-2021 Triad National Security, LLC. All rights
* Copyright (c) 2020-2022 Triad National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
Expand Down Expand Up @@ -369,6 +369,13 @@ static int ompi_comm_nextcid_ext_nb (ompi_communicator_t *newcomm, ompi_communic
bool is_new_block = false;
int rc;

/*
* sanity check and coverity pacifier
*/
if (!(OMPI_COMM_CID_GROUP == mode || OMPI_COMM_CID_GROUP_NEW == mode) && (NULL == comm)) {
return OMPI_ERROR;
}

if (OMPI_COMM_CID_GROUP == mode || OMPI_COMM_CID_GROUP_NEW == mode) {
/* new block belongs to the new communicator */
block = &newcomm->c_contextidb;
Expand Down
26 changes: 16 additions & 10 deletions ompi/errhandler/errcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
* Copyright (c) 2006 University of Houston. All rights reserved.
* Copyright (c) 2010-2012 Oak Ridge National Labs. All rights reserved.
* Copyright (c) 2013-2018 Cisco Systems, Inc. All rights reserved
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
* Copyright (c) 2013-2018 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2018 Los Alamos National Security, LLC. All rights
* Copyright (c) 2022 Triad National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
Expand Down Expand Up @@ -140,14 +140,14 @@ do { \
opal_pointer_array_set_item(&ompi_mpi_errcodes, (ERRCODE), &(VAR)); \
} while (0)

static opal_mutex_t errcode_init_lock = OPAL_MUTEX_STATIC_INIT;
static opal_mutex_t errcode_lock = OPAL_MUTEX_STATIC_INIT;

int ompi_mpi_errcode_init (void)
{
opal_mutex_lock(&errcode_init_lock);
opal_mutex_lock(&errcode_lock);
if ( 0 != ompi_mpi_errcode_lastpredefined ) {
/* Already initialized (presumably by an API call before MPI_init */
opal_mutex_unlock(&errcode_init_lock);
opal_mutex_unlock(&errcode_lock);
return OMPI_SUCCESS;
}

Expand Down Expand Up @@ -247,7 +247,7 @@ int ompi_mpi_errcode_init (void)
ompi_mpi_errcode_lastused = MPI_ERR_LASTCODE;
ompi_mpi_errcode_lastpredefined = MPI_ERR_LASTCODE;

opal_mutex_unlock(&errcode_init_lock);
opal_mutex_unlock(&errcode_lock);

ompi_mpi_instance_append_finalize (ompi_mpi_errcode_finalize);

Expand All @@ -266,7 +266,7 @@ int ompi_mpi_errcode_finalize (void)
int i;
ompi_mpi_errcode_t *errc;

opal_mutex_lock(&errcode_init_lock);
opal_mutex_lock(&errcode_lock);
for (i=ompi_mpi_errcode_lastpredefined+1; i<=ompi_mpi_errcode_lastused; i++) {
/*
* there are some user defined error-codes, which
Expand Down Expand Up @@ -359,7 +359,7 @@ int ompi_mpi_errcode_finalize (void)

OBJ_DESTRUCT(&ompi_mpi_errcodes);
ompi_mpi_errcode_lastpredefined = 0;
opal_mutex_unlock(&errcode_init_lock);
opal_mutex_unlock(&errcode_lock);
return OMPI_SUCCESS;
}

Expand All @@ -368,11 +368,14 @@ int ompi_mpi_errcode_add(int errclass )
ompi_mpi_errcode_t *newerrcode;

newerrcode = OBJ_NEW(ompi_mpi_errcode_t);

opal_mutex_lock(&errcode_lock);
newerrcode->code = (ompi_mpi_errcode_lastused+1);
newerrcode->cls = errclass;
opal_pointer_array_set_item(&ompi_mpi_errcodes, newerrcode->code, newerrcode);

ompi_mpi_errcode_lastused++;
opal_mutex_unlock(&errcode_lock);

return newerrcode->code;
}

Expand All @@ -381,10 +384,13 @@ int ompi_mpi_errclass_add(void)
ompi_mpi_errcode_t *newerrcode;

newerrcode = OBJ_NEW(ompi_mpi_errcode_t);

opal_mutex_lock(&errcode_lock);
newerrcode->cls = ( ompi_mpi_errcode_lastused+1);
opal_pointer_array_set_item(&ompi_mpi_errcodes, newerrcode->cls, newerrcode);

ompi_mpi_errcode_lastused++;
opal_mutex_unlock(&errcode_lock);

return newerrcode->cls;
}

Expand Down
12 changes: 10 additions & 2 deletions ompi/instance/instance.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2018-2021 Triad National Security, LLC. All rights
* Copyright (c) 2018-2022 Triad National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
Expand Down Expand Up @@ -236,6 +236,7 @@ int ompi_mpi_instance_retain (void)
OBJ_CONSTRUCT(&ompi_instance_f_to_c_table, opal_pointer_array_t);
if (OPAL_SUCCESS != opal_pointer_array_init (&ompi_instance_f_to_c_table, 8,
OMPI_FORTRAN_HANDLE_MAX, 32)) {
opal_mutex_unlock (&instance_lock);
return OMPI_ERROR;
}

Expand Down Expand Up @@ -964,6 +965,10 @@ static void ompi_instance_get_num_psets_complete (pmix_status_t status,
if (ompi_mpi_instance_pmix_psets) {
opal_argv_free (ompi_mpi_instance_pmix_psets);
}
if (NULL != pset_names) {
free(pset_names);
pset_names = NULL;
}
PMIX_VALUE_UNLOAD(rc,
&info[n].value,
(void **)&pset_names,
Expand All @@ -975,11 +980,14 @@ static void ompi_instance_get_num_psets_complete (pmix_status_t status,
}
ompi_mpi_instance_pmix_psets = opal_argv_split (pset_names, ',');
ompi_mpi_instance_num_pmix_psets = opal_argv_count (ompi_mpi_instance_pmix_psets);
free(pset_names);
}
}

done:
if (NULL != pset_names) {
free(pset_names);
}

if (NULL != release_fn) {
release_fn(release_cbdata);
}
Expand Down

0 comments on commit 4ddb5a8

Please sign in to comment.