Skip to content

Commit bd28fa0

Browse files
committed
sessions: more coverity clean
Related to #9097 Signed-off-by: Howard Pritchard <howardp@lanl.gov>
1 parent 3557a67 commit bd28fa0

File tree

4 files changed

+35
-16
lines changed

4 files changed

+35
-16
lines changed

ompi/communicator/comm.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* Copyright (c) 2015 Mellanox Technologies. All rights reserved.
2525
* Copyright (c) 2017 IBM Corporation. All rights reserved.
2626
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
27-
* Copyright (c) 2018-2021 Triad National Security, LLC. All rights
27+
* Copyright (c) 2018-2022 Triad National Security, LLC. All rights
2828
* reserved.
2929
* $COPYRIGHT$
3030
*
@@ -1546,8 +1546,6 @@ int ompi_intercomm_create_from_groups (ompi_group_t *local_group, int local_lead
15461546
} else {
15471547
free (leader_procs);
15481548
}
1549-
1550-
rsize = remote_group->grp_proc_count;
15511549
}
15521550

15531551
/* bcast size and list of remote processes to all processes in local_comm */

ompi/communicator/comm_cid.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* Copyright (c) 2017 Mellanox Technologies. All rights reserved.
2525
* Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
2626
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
27-
* Copyright (c) 2020-2021 Triad National Security, LLC. All rights
27+
* Copyright (c) 2020-2022 Triad National Security, LLC. All rights
2828
* reserved.
2929
* $COPYRIGHT$
3030
*
@@ -369,6 +369,13 @@ static int ompi_comm_nextcid_ext_nb (ompi_communicator_t *newcomm, ompi_communic
369369
bool is_new_block = false;
370370
int rc;
371371

372+
/*
373+
* sanity check and coverity pacifier
374+
*/
375+
if (!(OMPI_COMM_CID_GROUP == mode || OMPI_COMM_CID_GROUP_NEW == mode) && (NULL == comm)) {
376+
return OMPI_ERROR;
377+
}
378+
372379
if (OMPI_COMM_CID_GROUP == mode || OMPI_COMM_CID_GROUP_NEW == mode) {
373380
/* new block belongs to the new communicator */
374381
block = &newcomm->c_contextidb;

ompi/errhandler/errcode.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
* Copyright (c) 2006 University of Houston. All rights reserved.
1414
* Copyright (c) 2010-2012 Oak Ridge National Labs. All rights reserved.
1515
* Copyright (c) 2013-2018 Cisco Systems, Inc. All rights reserved
16-
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
16+
* Copyright (c) 2013-2018 Los Alamos National Security, LLC. All rights
1717
* reserved.
1818
* Copyright (c) 2015 Research Organization for Information Science
1919
* and Technology (RIST). All rights reserved.
20-
* Copyright (c) 2018 Los Alamos National Security, LLC. All rights
20+
* Copyright (c) 2022 Triad National Security, LLC. All rights
2121
* reserved.
2222
* $COPYRIGHT$
2323
*
@@ -140,14 +140,14 @@ do { \
140140
opal_pointer_array_set_item(&ompi_mpi_errcodes, (ERRCODE), &(VAR)); \
141141
} while (0)
142142

143-
static opal_mutex_t errcode_init_lock = OPAL_MUTEX_STATIC_INIT;
143+
static opal_mutex_t errcode_lock = OPAL_MUTEX_STATIC_INIT;
144144

145145
int ompi_mpi_errcode_init (void)
146146
{
147-
opal_mutex_lock(&errcode_init_lock);
147+
opal_mutex_lock(&errcode_lock);
148148
if ( 0 != ompi_mpi_errcode_lastpredefined ) {
149149
/* Already initialized (presumably by an API call before MPI_init */
150-
opal_mutex_unlock(&errcode_init_lock);
150+
opal_mutex_unlock(&errcode_lock);
151151
return OMPI_SUCCESS;
152152
}
153153

@@ -247,7 +247,7 @@ int ompi_mpi_errcode_init (void)
247247
ompi_mpi_errcode_lastused = MPI_ERR_LASTCODE;
248248
ompi_mpi_errcode_lastpredefined = MPI_ERR_LASTCODE;
249249

250-
opal_mutex_unlock(&errcode_init_lock);
250+
opal_mutex_unlock(&errcode_lock);
251251

252252
ompi_mpi_instance_append_finalize (ompi_mpi_errcode_finalize);
253253

@@ -266,7 +266,7 @@ int ompi_mpi_errcode_finalize (void)
266266
int i;
267267
ompi_mpi_errcode_t *errc;
268268

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

360360
OBJ_DESTRUCT(&ompi_mpi_errcodes);
361361
ompi_mpi_errcode_lastpredefined = 0;
362-
opal_mutex_unlock(&errcode_init_lock);
362+
opal_mutex_unlock(&errcode_lock);
363363
return OMPI_SUCCESS;
364364
}
365365

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

370370
newerrcode = OBJ_NEW(ompi_mpi_errcode_t);
371+
372+
opal_mutex_lock(&errcode_lock);
371373
newerrcode->code = (ompi_mpi_errcode_lastused+1);
372374
newerrcode->cls = errclass;
373375
opal_pointer_array_set_item(&ompi_mpi_errcodes, newerrcode->code, newerrcode);
374-
375376
ompi_mpi_errcode_lastused++;
377+
opal_mutex_unlock(&errcode_lock);
378+
376379
return newerrcode->code;
377380
}
378381

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

383386
newerrcode = OBJ_NEW(ompi_mpi_errcode_t);
387+
388+
opal_mutex_lock(&errcode_lock);
384389
newerrcode->cls = ( ompi_mpi_errcode_lastused+1);
385390
opal_pointer_array_set_item(&ompi_mpi_errcodes, newerrcode->cls, newerrcode);
386-
387391
ompi_mpi_errcode_lastused++;
392+
opal_mutex_unlock(&errcode_lock);
393+
388394
return newerrcode->cls;
389395
}
390396

ompi/instance/instance.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2018-2021 Triad National Security, LLC. All rights
3+
* Copyright (c) 2018-2022 Triad National Security, LLC. All rights
44
* reserved.
55
* $COPYRIGHT$
66
*
@@ -236,6 +236,7 @@ int ompi_mpi_instance_retain (void)
236236
OBJ_CONSTRUCT(&ompi_instance_f_to_c_table, opal_pointer_array_t);
237237
if (OPAL_SUCCESS != opal_pointer_array_init (&ompi_instance_f_to_c_table, 8,
238238
OMPI_FORTRAN_HANDLE_MAX, 32)) {
239+
opal_mutex_unlock (&instance_lock);
239240
return OMPI_ERROR;
240241
}
241242

@@ -964,6 +965,10 @@ static void ompi_instance_get_num_psets_complete (pmix_status_t status,
964965
if (ompi_mpi_instance_pmix_psets) {
965966
opal_argv_free (ompi_mpi_instance_pmix_psets);
966967
}
968+
if (NULL != pset_names) {
969+
free(pset_names);
970+
pset_names = NULL;
971+
}
967972
PMIX_VALUE_UNLOAD(rc,
968973
&info[n].value,
969974
(void **)&pset_names,
@@ -975,11 +980,14 @@ static void ompi_instance_get_num_psets_complete (pmix_status_t status,
975980
}
976981
ompi_mpi_instance_pmix_psets = opal_argv_split (pset_names, ',');
977982
ompi_mpi_instance_num_pmix_psets = opal_argv_count (ompi_mpi_instance_pmix_psets);
978-
free(pset_names);
979983
}
980984
}
981985

982986
done:
987+
if (NULL != pset_names) {
988+
free(pset_names);
989+
}
990+
983991
if (NULL != release_fn) {
984992
release_fn(release_cbdata);
985993
}

0 commit comments

Comments
 (0)