Skip to content

Commit ea5ab14

Browse files
committed
sessions: some coverity cleanups
related to #9097 Signed-off-by: Howard Pritchard <howardp@lanl.gov>
1 parent 02020f3 commit ea5ab14

File tree

8 files changed

+37
-15
lines changed

8 files changed

+37
-15
lines changed

ompi/communicator/comm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,13 +1510,15 @@ int ompi_intercomm_create_from_groups (ompi_group_t *local_group, int local_lead
15101510
asprintf (&sub_tag, "%s-OMPIi-LC", tag);
15111511
if (OPAL_UNLIKELY(NULL == sub_tag)) {
15121512
ompi_comm_free (&local_comm);
1513+
free(leader_procs);
15131514
return OMPI_ERR_OUT_OF_RESOURCE;
15141515
}
15151516

15161517
leader_group = ompi_group_allocate_plist_w_procs (leader_procs, 2);
15171518
ompi_set_group_rank (leader_group, my_proc);
15181519
if (OPAL_UNLIKELY(NULL == leader_group)) {
15191520
free (sub_tag);
1521+
free(leader_procs);
15201522
ompi_comm_free (&local_comm);
15211523
return OMPI_ERR_OUT_OF_RESOURCE;
15221524
}
@@ -1528,6 +1530,7 @@ int ompi_intercomm_create_from_groups (ompi_group_t *local_group, int local_lead
15281530
OBJ_RELEASE(leader_group);
15291531
free (sub_tag);
15301532
if (OPAL_UNLIKELY(OMPI_SUCCESS != rc)) {
1533+
free(leader_procs);
15311534
ompi_comm_free (&local_comm);
15321535
return rc;
15331536
}

ompi/errhandler/errhandler.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,9 @@ ompi_errhandler_t *ompi_errhandler_create(ompi_errhandler_type_t object_type,
300300
}
301301
}
302302

303-
new_errhandler->eh_fort_fn = (ompi_errhandler_fortran_handler_fn_t *)func;
303+
if (NULL != new_errhandler) {
304+
new_errhandler->eh_fort_fn = (ompi_errhandler_fortran_handler_fn_t *)func;
305+
}
304306

305307
}
306308

ompi/instance/instance.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ int ompi_mpi_instance_retain (void)
275275

276276
/* initialize info */
277277
if (OMPI_SUCCESS != (ret = ompi_mpiinfo_init ())) {
278+
opal_mutex_unlock (&instance_lock);
278279
return ompi_instance_print_error ("ompi_info_init() failed", ret);
279280
}
280281

@@ -919,9 +920,6 @@ int ompi_mpi_instance_finalize (ompi_instance_t **instance)
919920
opal_mutex_lock (&instance_lock);
920921
if (0 == opal_atomic_add_fetch_32 (&ompi_instance_count, -1)) {
921922
ret = ompi_mpi_instance_finalize_common ();
922-
if (OPAL_UNLIKELY(OPAL_SUCCESS != ret)) {
923-
opal_mutex_unlock (&instance_lock);
924-
}
925923
}
926924
opal_mutex_unlock (&instance_lock);
927925

ompi/mpi/c/group_from_session_pset.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,16 @@ int MPI_Group_from_session_pset (MPI_Session session, const char *pset_name, MPI
3232

3333
if ( MPI_PARAM_CHECK ) {
3434
if (NULL == session || NULL == pset_name || NULL == newgroup) {
35-
return OMPI_ERRHANDLER_INVOKE(session, MPI_ERR_ARG, FUNC_NAME);
35+
if (NULL != session) {
36+
return OMPI_ERRHANDLER_INVOKE(session, MPI_ERR_ARG, FUNC_NAME);
37+
} else {
38+
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_ARG, FUNC_NAME);
39+
}
3640
}
3741
}
3842

3943
rc = ompi_group_from_pset (session, pset_name, newgroup);
40-
/* if an error occured raise it on the null session */
41-
OMPI_ERRHANDLER_RETURN (rc, session, rc, FUNC_NAME);
44+
45+
OMPI_ERRHANDLER_RETURN (rc, (NULL == session) ? MPI_SESSION_NULL : session,
46+
rc, FUNC_NAME);
4247
}

ompi/mpi/c/intercomm_merge.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ int MPI_Intercomm_merge(MPI_Comm intercomm, int high,
9797

9898
first = ompi_comm_determine_first ( intercomm, thigh );
9999
if ( MPI_UNDEFINED == first ) {
100-
return OMPI_ERRHANDLER_INVOKE(intercomm, MPI_ERR_INTERN, FUNC_NAME);
100+
rc = MPI_ERR_INTERN;
101+
goto exit;
101102
}
102103

103104
if ( first ) {

ompi/mpi/c/session_get_nth_pset.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ int MPI_Session_get_nth_pset (MPI_Session session, MPI_Info info, int n, int *le
3232

3333
if ( MPI_PARAM_CHECK ) {
3434
if (NULL == session || (NULL == pset_name && *len > 0) || n < 0) {
35-
return OMPI_ERRHANDLER_INVOKE(session, MPI_ERR_ARG, FUNC_NAME);
35+
if (NULL != session) {
36+
return OMPI_ERRHANDLER_INVOKE(session, MPI_ERR_ARG, FUNC_NAME);
37+
} else {
38+
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_ARG, FUNC_NAME);
39+
}
3640
}
3741
}
3842

3943
rc = ompi_instance_get_nth_pset (session, n, len, pset_name);
4044

41-
/* if an error occured raise it on the null session */
42-
OMPI_ERRHANDLER_RETURN (rc, MPI_SESSION_NULL, rc, FUNC_NAME);
45+
OMPI_ERRHANDLER_RETURN (rc, (NULL == session) ? MPI_SESSION_NULL : session,
46+
rc, FUNC_NAME);
4347
}

ompi/mpi/c/session_get_num_psets.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,16 @@ int MPI_Session_get_num_psets (MPI_Session session, MPI_Info info, int *npset_na
3232

3333
if ( MPI_PARAM_CHECK ) {
3434
if (NULL == session || NULL == npset_names) {
35-
return OMPI_ERRHANDLER_INVOKE(session, MPI_ERR_ARG, FUNC_NAME);
35+
if (NULL != session) {
36+
return OMPI_ERRHANDLER_INVOKE(session, MPI_ERR_ARG, FUNC_NAME);
37+
} else {
38+
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_ARG, FUNC_NAME);
39+
}
3640
}
3741
}
3842

3943
rc = ompi_instance_get_num_psets (session, npset_names);
40-
/* if an error occured raise it on the null session */
41-
OMPI_ERRHANDLER_RETURN (rc, MPI_SESSION_NULL, rc, FUNC_NAME);
44+
45+
OMPI_ERRHANDLER_RETURN (rc, (NULL == session) ? MPI_SESSION_NULL : session,
46+
rc, FUNC_NAME);
4247
}

ompi/mpi/fortran/mpif-h/session_get_pset_info_f.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void ompi_session_get_pset_info_f(MPI_Fint *session,char *pset_name, MPI_Fint *i
7878
{
7979
int c_ierr, ret;
8080
MPI_Session c_session;
81-
char *c_name;
81+
char *c_name = NULL;
8282
MPI_Info c_info;
8383

8484
c_session = PMPI_Session_f2c(*session);
@@ -96,6 +96,10 @@ void ompi_session_get_pset_info_f(MPI_Fint *session,char *pset_name, MPI_Fint *i
9696
c_ierr = PMPI_Session_get_pset_info(c_session, c_name, &c_info);
9797
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
9898

99+
if (NULL != c_name) {
100+
free (c_name);
101+
}
102+
99103
if (MPI_SUCCESS == c_ierr) {
100104
*info = PMPI_Info_c2f(c_info);
101105
}

0 commit comments

Comments
 (0)